Repository navigation
ci: test and run the binary on arm64; arm64-first builds - #2
Conversation
release.go has built darwin/arm64 and linux/arm64 for a while, but CI and the release gates ran on ubuntu-latest only, so the arm64 binaries were cross-compiled and never executed, and the tests never ran on arm64. (#1) - ci.yml and release.yml get an arm64 job on GitHub's free hosted runners, ubuntu-24.04-arm and macos-latest (Apple Silicon): go test -race, then build and run the binary. The release is published only after it passes. The other gates are architecture-independent and still run once, on ubuntu-latest. - make build defaults to GOARCH=arm64, overridable, and unexported so that generate and test run on the host. release.go and the README's install section list arm64 first. The Homebrew formula already picks the arm64 archive under on_arm and the amd64 one under on_intel, for macOS and Linux; nothing to change there.
250bed5 to
42b09b2
Compare
alfaha
left a comment
There was a problem hiding this comment.
Went through the diff and the CI run. Looks good to me. The arm64 jobs really do run natively: the logs show linux/arm64 on Linux aarch64 and darwin/arm64 on Darwin arm64, and both pass with -race. I also checked locally that unexport GOARCH keeps make test / make generate on the host arch when you override GOARCH.
A few notes inline, nothing blocking. The CHANGELOG one is the only one we'll actually have to deal with.
| # Override for anything else, e.g. `make build GOARCH=amd64`, or with GOARCH in the | ||
| # environment. Only the binary is cross-built: make would otherwise export GOARCH to | ||
| # every recipe, and generate and test have to run on the host. | ||
| GOARCH ?= arm64 |
There was a problem hiding this comment.
One thing to be aware of: on an amd64 machine make build now produces an arm64 binary, and running it just gives exec format error. The only clue is the echo line. That's what #1 asked for, and the README says how to override it, so I'm fine leaving it. Just flagging it in case someone on an Intel box hits it.
| # public repositories: ubuntu-24.04-arm is Linux on arm64, macos-latest Apple | ||
| # Silicon. Only what depends on the architecture runs here; the other gates are | ||
| # the same everywhere and run once, in build. | ||
| arm64: |
There was a problem hiding this comment.
This job is the same block as the one in release.yml, copy for copy. It's short, so OK for now, but the two will drift (someone bumps setup-go or adds a step in one and forgets the other). If we touch it again, a small reusable workflow would fix that.
| release: | ||
| # arm64 artefacts are published only once their tests and binary have run on | ||
| # arm64. | ||
| needs: arm64 |
There was a problem hiding this comment.
Good, nothing gets published before arm64 passes. Side effect: a release now waits on macos-latest, which was the slowest job in the PR run (~7 min vs ~3.5 for build). Fine for releases, I think.
| @@ -1,5 +1,14 @@ | |||
| # Changelog | |||
|
|
|||
| ## Unreleased | |||
There was a problem hiding this comment.
theazz#69 also adds an ## Unreleased section at the top, so these two will conflict. I ran a trial merge of both branches: CHANGELOG.md conflicts, README merges cleanly. Whichever lands second needs the two Unreleased sections combined by hand. Easy, just expect it when we sync from upstream.
# Conflicts: # CHANGELOG.md
The arm64 half of #1; the JSON half went upstream as theazz#69.
release.goalready builds darwin/arm64 and linux/arm64, but CI and the release gates ran onubuntu-latestonly. The arm64 binaries were cross-compiled and never executed, and the tests never ran on arm64.arm64job inci.ymlandrelease.yml. It runs on GitHub's free hosted runners:ubuntu-24.04-arm(Linux arm64) andmacos-latest(Apple Silicon). It runsgo test ./... -race, then builds and runs the binary. Inrelease.ymlthe publishing jobneedsit, so nothing ships until arm64 has passed. The other gates (gofmt, vet, generate, govulncheck, actionlint) don't depend on the architecture and still run once onubuntu-latest.make builddefaults toGOARCH=arm64. It can be overridden withmake build GOARCH=amd64. It isunexported, sogenerateandteststill run on the host.release.goand in the README's install section.on_armand the amd64 one underon_intel, on macOS and Linux.update_homebrew_formula.pyonly rewrites the version and checksum per URL.An earlier version of this PR routed jobs to a self-hosted Mac. That was dropped: hosted runners give the same arm64 coverage with no machine to trust and no org setup. Nothing here depends on the fork, so this could also go upstream.