Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ jobs:
os: macos-15-intel
- target: x86_64-unknown-linux-gnu
os: ubuntu-22.04
- target: aarch64-unknown-linux-gnu
os: ubuntu-22.04-arm
runs-on: ${{ matrix.os }}
timeout-minutes: 45
steps:
Expand Down Expand Up @@ -87,7 +89,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [macos-14, macos-15-intel, ubuntu-22.04]
os: [macos-14, macos-15-intel, ubuntu-22.04, ubuntu-22.04-arm]
runs-on: ${{ matrix.os }}
timeout-minutes: 15
env:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ diffr main...HEAD -- src/ # merge-base comparison

## Installation

CLI and terminal UI (Apple Silicon macOS, Intel macOS, and x64 Linux):
CLI and terminal UI (Apple Silicon macOS, Intel macOS, and x64/ARM64 Linux):

```sh
brew install devdotfast/tap/diffr
Expand Down
3 changes: 3 additions & 0 deletions diffr-ts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ Keep these files in sync:

## Release

Linux ARM64 fetch support requires a release containing an `aarch64-unknown-linux-gnu`
archive and regenerated pins; the bundled 0.1.5 pins do not include it.

After tagging the matching Rust release and building with `cargo build --locked`,
run from `diffr-ts`. New pins select the CLI-only release archives; older pins
continue to use the full archives:
Expand Down
2 changes: 1 addition & 1 deletion diffr-ts/bin/fetch.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { fileURLToPath } from "node:url";
import { parseArgs } from "node:util";

const root = resolve(dirname(fileURLToPath(import.meta.url)), "..");
const targets = { "darwin-arm64": "aarch64-apple-darwin", "darwin-x64": "x86_64-apple-darwin", "linux-x64": "x86_64-unknown-linux-gnu" };
const targets = { "darwin-arm64": "aarch64-apple-darwin", "darwin-x64": "x86_64-apple-darwin", "linux-x64": "x86_64-unknown-linux-gnu", "linux-arm64": "aarch64-unknown-linux-gnu" };

try {
await main();
Expand Down
2 changes: 1 addition & 1 deletion diffr-ts/scripts/pin.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { fileURLToPath } from "node:url";
const here = dirname(fileURLToPath(import.meta.url));
const root = join(here, "..");
const version = JSON.parse(readFileSync(join(root, "package.json"), "utf8")).version;
const targets = ["aarch64-apple-darwin", "x86_64-apple-darwin", "x86_64-unknown-linux-gnu"];
const targets = ["aarch64-apple-darwin", "x86_64-apple-darwin", "x86_64-unknown-linux-gnu", "aarch64-unknown-linux-gnu"];
const artifact = "diffr-cli";
const sha256 = {};
for (const target of targets) {
Expand Down
23 changes: 20 additions & 3 deletions diffr-ts/src/fetch.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ import { join } from "node:path";

const fetchScript = join(import.meta.dir, "..", "bin", "fetch.mjs");
const { version } = JSON.parse(readFileSync(join(import.meta.dir, "..", "package.json"), "utf8"));
const targets: Record<string, string> = { "darwin-arm64": "aarch64-apple-darwin", "darwin-x64": "x86_64-apple-darwin", "linux-x64": "x86_64-unknown-linux-gnu" };
const targets: Record<string, string> = { "darwin-arm64": "aarch64-apple-darwin", "darwin-x64": "x86_64-apple-darwin", "linux-x64": "x86_64-unknown-linux-gnu", "linux-arm64": "aarch64-unknown-linux-gnu" };
const target = targets[`${process.platform}-${process.arch}`];
const dirs: string[] = [];
afterEach(() => {
for (const dir of dirs.splice(0)) rmSync(dir, { recursive: true, force: true });
});

function fixture(entry = "diffr", artifact?: string) {
function fixture(entry = "diffr", artifact?: string, platform = process.platform, arch = process.arch) {
const target = targets[`${platform}-${arch}`];
if (!target) throw new Error("Fetch tests require a supported release platform");
const dir = mkdtempSync(join(tmpdir(), "diffr-fetch-test-"));
dirs.push(dir);
Expand All @@ -25,9 +26,11 @@ function fixture(entry = "diffr", artifact?: string) {
const pins = join(dir, "pins.json");
writeFileSync(pins, JSON.stringify({ version, artifact, sha256: { [target]: hash } }));
const mock = join(dir, "mock.mjs");
// Intercept only the network boundary, leaving the actual CLI and tar intact.
// Mock the platform and network, leaving the actual CLI and tar intact.
writeFileSync(mock, `
import { readFileSync, writeFileSync } from "node:fs";
Object.defineProperty(process, "platform", { value: ${JSON.stringify(platform)} });
Object.defineProperty(process, "arch", { value: ${JSON.stringify(arch)} });
globalThis.fetch = async (url) => {
writeFileSync(${JSON.stringify(join(dir, "requested"))}, url);
if (process.env.FETCH_FAILURE) throw new Error("offline");
Expand Down Expand Up @@ -120,6 +123,20 @@ test("missing option values fail clearly", () => {
expect(f.run(["--into"]).code).toBe(1);
});

test("Linux ARM64 downloads and stamps the aarch64 release", () => {
const f = fixture("diffr", "diffr-cli", "linux", "arm64");
const result = f.run(["--required"]);
expect(result.code, result.err).toBe(0);
expect(readFileSync(join(f.dir, "requested"), "utf8")).toBe(
`https://github.com/devdotfast/diffr/releases/download/${version}/diffr-cli-${version}-aarch64-unknown-linux-gnu.tar.gz`,
);
expect(readFileSync(join(f.into, "diffr"), "utf8")).toBe(f.content);
expect(JSON.parse(readFileSync(join(f.into, "diffr.stamp.json"), "utf8"))).toEqual({
version, target: "aarch64-unknown-linux-gnu",
});
expect(f.run(["--check"], true).code).toBe(0);
});

test("CLI-only pins download the CLI archive", () => {
const f = fixture("diffr", "diffr-cli");
const result = f.run(["--required"]);
Expand Down
13 changes: 9 additions & 4 deletions scripts/release.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import subprocess
import tarfile

TARGETS = ("aarch64-apple-darwin", "x86_64-apple-darwin", "x86_64-unknown-linux-gnu")
TARGETS = ("aarch64-apple-darwin", "x86_64-apple-darwin", "x86_64-unknown-linux-gnu", "aarch64-unknown-linux-gnu")
ROOT = Path(__file__).resolve().parent.parent


Expand Down Expand Up @@ -55,9 +55,14 @@ def formula(version, output):
end

on_linux do
depends_on arch: :x86_64
url "{url}-x86_64-unknown-linux-gnu.tar.gz"
sha256 "{checksums[archive_name(version, 'x86_64-unknown-linux-gnu')]}"
on_arm do
url "{url}-aarch64-unknown-linux-gnu.tar.gz"
sha256 "{checksums[archive_name(version, 'aarch64-unknown-linux-gnu')]}"
end
on_intel do
url "{url}-x86_64-unknown-linux-gnu.tar.gz"
sha256 "{checksums[archive_name(version, 'x86_64-unknown-linux-gnu')]}"
end
end

def install
Expand Down
Loading