ci(desktop): check the native driver on macOS and ship it in releases (ENG-1533)

Merged
KD
2d ago
+200-29

What

  • spec.yml gets a native job on blacksmith-6vcpu-macos-26: cargo fmt --check, cargo clippy -D warnings, cargo test, a release build of the desktop driver for both Mac architectures, and a load of the arm64 build, also through the engine's loader test. It is in the spec gate's needs, so it gates merges.
  • release.yml builds the driver on macOS and puts it into @e2e-dev/desktop-darwin-arm64 and @e2e-dev/desktop-darwin-x64 before the release and nightly jobs publish.
  • pnpm run canary also builds the driver into both platform packages, so a canary needs a Mac with rustup.

Last of four PRs for ENG-1533 (#2322, #2323, #2324, #2325), based on the testbed in #2324. #2322 is merged; this PR merges after #2323 and #2324.

Why

Without this, nothing checks the Rust crate on a pull request, and a release would publish the platform packages with no driver in them. Their prepublishOnly refuses that, so the release would fail instead.

How it works

  1. spec.yml, native job: sets up Node 26, installs rustup when the runner has none, and puts the pinned toolchain's cargo first on PATH, so neither a rustup that put none there (Homebrew's) nor a standalone cargo without both targets builds the driver. rust-toolchain.toml pins the toolchain, and rustup installs it on first use. The job runs fmt, clippy, and cargo test, checks that each platform package's THIRD_PARTY_LICENSES.md matches Cargo.lock (native-licenses.ts --check), builds both addons with build-native.ts as the release does, checks each one's architecture with lipo -archs (only an Intel Mac could load the x64 one), and loads the arm64 addon in Node, so a build that does not load fails the pull request. It then installs the workspace, builds @e2e-dev/core, and runs the engine's loader test (tests/unit/driver.test.ts) on that addon with REQUIRE_DESKTOP_NATIVE=1, which fails the test where it would otherwise skip, so loadNativeDriver runs on a real build in CI.
  2. release.yml, nightly-due job: a small Linux job that, on a scheduled run, checks whether main moved since the last nightly. It runs on every event, a push included, where the check is skipped: a skipped job would skip release too, since a job's implicit success() covers every job above it. The native job builds unless a scheduled run found nothing to ship, so a quiet night starts no macOS runner, and nightly runs only when one is due.
  3. release.yml, native job: sets up Node 26, since build-native.ts is TypeScript run directly, then builds both addons with scripts/build-native.ts, checks each one's architecture with lipo -archs, and uploads them as the desktop-native artifact, kept one day. The release and nightly jobs need it, and a comment there says why. The publishing job stays on a GitHub-hosted Linux runner, which npm Trusted Publishing requires, so the build cannot run there.
  4. release and nightly download the artifact to ${{ runner.temp }}/desktop-native, outside the checkout, so changesets/action cannot stage the binaries into the version commit. Then they run packages/desktop/scripts/place-native.ts. It copies each addon into its platform package as a new file (an addon overwritten in place gets the next process that loads it killed) and writes the .build.json stamp with that package's version, which prepublishOnly (scripts/check-native.ts) checks. In nightly this runs after the snapshot version step, so the stamp names the snapshot version. download-artifact is pinned by SHA (v8.0.2), as every action is.
  5. The root package.json adds build:desktop-native, and canary runs it after the build. CONTRIBUTING.md says a canary needs rustup on a Mac, and AGENTS.md lists the native job, the release step, and the canary's need.

Issue

Refs ENG-1533

Verified

Ran it locally: yes, the commands the jobs run. The workflows run only on GitHub: the native job in this PR's checks is its first run, and the release jobs run after merge.

  • The commands the jobs run pass on a Mac: cargo fmt --check, cargo clippy --locked --all-targets -- -D warnings, cargo test --locked, node ../scripts/build-native.ts for both targets, and the load step ({ accessibility: true, screenRecording: true }).
  • check-native.ts passes on a package with a fresh build and stamp, and fails when the addon is missing.
  • The loader test with REQUIRE_DESKTOP_NATIVE=1 passes on a built addon and fails with the addon moved away; without the variable it is skipped. actionlint passes on spec.yml and release.yml, and lipo -archs reads arm64 and x86_64 from the two builds here.
  • build-native.ts run twice in a row over the same output: the addon loads after each build (screenLocked() answers). The x64 addon is built in both jobs but loaded by none: no x64 Mac runner is in use.

Before the first release, a maintainer publishes both platform packages once by hand and adds a trusted publisher for each on npmjs, as for any new package.

šŸ¤– Generated with Claude Code