Skip to content

feat: add cross-compile build scripts and smoke tests [2/4] - #47

Merged
wyattjoh merged 1 commit into
mainfrom
wyattjoh/cross-compile
Mar 20, 2026
Merged

feat: add cross-compile build scripts and smoke tests [2/4]#47
wyattjoh merged 1 commit into
mainfrom
wyattjoh/cross-compile

Conversation

@wyattjoh

@wyattjoh wyattjoh commented Mar 20, 2026

Copy link
Copy Markdown
Contributor

Summary

#43 sets up the monorepo with a wrapper shim that resolves platform-specific binaries, but we can only build a binary for the local machine today. To actually ship npx clerk, we need to produce binaries for every platform users run on.

This PR adds the cross-compilation pipeline:

  • scripts/build.ts -- compiles the CLI via bun build --compile for 8 platform targets (darwin-arm64, darwin-x64, linux-arm64, linux-arm64-musl, linux-x64, linux-x64-musl, windows-x64, windows-arm64), with binary format verification using file output
  • scripts/releaser/targets.ts -- single source of truth for target definitions, Bun target mappings, and verify patterns
  • build-binaries.yml -- reusable CI workflow that matrix-builds all targets on the appropriate runner OS
  • smoke-test.yml -- reusable CI workflow that runs the compiled binary on native runners to catch runtime issues (e.g. missing shared libraries) before publishing

Also extends root lint/format scripts to cover the new scripts/ directory and adds *.bun-build to .gitignore.

Merge instructions

This is part of a 4-PR stack (#43, #47, #45, #46). After squash-merging this PR, retarget #45 to main before deleting this branch, then:

git fetch origin main
git rebase origin/main wyattjoh/release-infra
git push --force-with-lease origin wyattjoh/release-infra

Then merge #45, and repeat.

Test plan

  • CI passes: format:check, lint, build, test
  • bun run build:compile:all completes for the local platform target
  • Review build-binaries.yml matrix against targets.ts definitions

Summary by CodeRabbit

  • Chores
    • Added automated multi-platform binary build and reusable smoke-test workflows.
    • Extended official build outputs to macOS, Linux (glibc/musl), and Windows across arm64/x64.
    • Added a cross-compile build tool that compiles, validates, and packages platform-specific binaries.
    • Updated dev scripts and tooling to include additional format/lint steps and a Bun engine requirement.
    • Ignored local compile artifacts from source control.

@wyattjoh

Copy link
Copy Markdown
Contributor Author

PR Stack -- Supersedes #31

PR Description
1 #43 Monorepo restructure (merged)
2 #47 Cross-compile build + smoke tests -- ← this PR
3 #45 Release infrastructure (changesets)
4 #46 Release documentation + LICENSE

Review in parallel, merge sequentially. Squash-merge each PR, retarget the next PR to main before deleting the branch, then rebase.

@coderabbitai

coderabbitai Bot commented Mar 20, 2026

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: cfe4d5ad-e838-44bb-8e31-9b961b931cff

📥 Commits

Reviewing files that changed from the base of the PR and between cb764f6 and fb82e61.

📒 Files selected for processing (6)
  • .github/workflows/build-binaries.yml
  • .github/workflows/smoke-test.yml
  • .gitignore
  • package.json
  • scripts/build.ts
  • scripts/releaser/targets.ts

📝 Walkthrough

Walkthrough

Adds reusable GitHub Actions workflows .github/workflows/build-binaries.yml (Build Binaries; workflow_call with version, ref, artifact-prefix) and .github/workflows/smoke-test.yml (Smoke Test; workflow_call with version, artifact-prefix, preset, computes a matrix and validates artifact versions). Adds scripts/build.ts to cross-compile CLI binaries with Bun and scripts/releaser/targets.ts exporting target metadata. Updates package.json scripts and engines.bun constraint. Adds .gitignore rule to ignore *.bun-build artifacts.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main change: adding cross-compile build scripts and smoke tests as part of a multi-PR stack.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

@brkalow

brkalow commented Mar 20, 2026

Copy link
Copy Markdown
Member

@wyattjoh Is this an invalid target or a platform-specific issue?

Building win32-arm64 (bun-windows-arm64)...
  FAIL: error: Unsupported compile target: bun-windows-aarch64-v1.3.6

@wyattjoh

Copy link
Copy Markdown
Contributor Author

Not an invalid target -- bun-windows-arm64 is supported in newer Bun versions (works on 1.3.11+, which is what CI uses via oven-sh/setup-bun@v2 without a pinned version). The error on 1.3.6 is because that release predates Windows ARM64 cross-compilation support.

The build script (scripts/build.ts) is only invoked in CI via the build-binaries.yml workflow, which always gets the latest Bun. It's not part of the normal local dev loop (bun run build / bun test), so this shouldn't affect local development on older Bun versions.

That said, we could pin a minimum Bun version in CI or add a version check to the build script if you'd prefer an explicit guard. What do you think?

@brkalow

brkalow commented Mar 20, 2026

Copy link
Copy Markdown
Member

@wyattjoh makes sense! Maybe we can do a min version check in the script. I was assuming I'd be able to use that to build the CLI locally and install the binary, similar to @jfoshee's PR. Happy to use a different flow for that too

@wyattjoh
wyattjoh force-pushed the wyattjoh/cross-compile branch from 3bcc5ea to cb764f6 Compare March 20, 2026 19:53
Add scripts to cross-compile the CLI binary for 8 platform targets
(linux/darwin/windows × x64/arm64), plus reusable CI workflows for
building and smoke-testing binaries across stable/canary/snapshot channels.
@wyattjoh
wyattjoh force-pushed the wyattjoh/cross-compile branch from cb764f6 to fb82e61 Compare March 20, 2026 19:59
@wyattjoh

Copy link
Copy Markdown
Contributor Author

Replaced the runtime version check with "engines": { "bun": ">=1.3.10" } in the root package.json. oven-sh/setup-bun already reads this field to select the Bun version in CI. Bun doesn't enforce it locally yet (oven-sh/bun#5846), but the error from Bun itself (Unsupported compile target) is clear enough when running an older version.

For building locally: bun run build:compile (single target, your platform) works on any recent Bun. bun run build:compile:all is the cross-compile script that needs 1.3.10+ for the bun-windows-arm64 target.

@wyattjoh
wyattjoh merged commit 94bc738 into main Mar 20, 2026
2 checks passed
@wyattjoh
wyattjoh deleted the wyattjoh/cross-compile branch March 20, 2026 20:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants