ci: cache native builds, merge per-platform artifacts, cancel superseded runs#375
Merged
Conversation
The native binaries are a pure function of the src/main/native sources, yet
every workflow invocation recompiled all of them from scratch: each PR push
triggered three parallel full rebuilds (pre-merge + test-graalvm +
test-packaging), and a release tag four more.
build-natives.yaml now caches each platform's output tree keyed on
hashFiles('**/src/main/native/**') plus the workflow itself; on a hit every
toolchain/compile step is skipped and the job only verifies and re-publishes.
Per-module verify/upload steps are collapsed into one verify step and one
merged artifact per platform (natives-windows, natives-macos,
natives-linux-{x64,aarch64}), so the ~25 copy-pasted download steps in each
of the 7 consumer jobs become a single 'pattern: natives-*' download.
pre-merge.yaml also gains a concurrency group cancelling superseded PR runs
(pushes to main are never cancelled: their run saves the shared caches).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Native binaries were recompiled from scratch on every workflow invocation, even for pure-Kotlin PRs:
build-natives.yaml3× in parallel (pre-merge + test-graalvm + test-packaging) = 12 native-build runner jobs per pushsrc/main/native/**download-artifactsteps (~1400 duplicated YAML lines across 8 jobs)pre-merge.yamlhad no concurrency group, so superseded runs kept burning runnersChanges
build-natives.yamlhashFiles('**/src/main/native/**', '.github/workflows/build-natives.yaml'); on a hit, all toolchain/compile/fetch steps are skipped — the job only verifies the restored tree and re-publishes (~1-2 min instead of 10-20)natives-windows,natives-macos,natives-linux-{x64,aarch64}(paths repo-root-relative)natives-v1can be bumped to force a rebuildConsumers (7 workflows) — the download blocks become a single step:
The "Verify all natives present" EXPECTED checks in pre-merge/publish-maven are kept as-is.
pre-merge.yaml— concurrency group withcancel-in-progresson PR events only (main pushes are never cancelled: they save the caches every other run keys off, since tag runs can read default-branch caches — releases hit the cache built on main).CLAUDE.md — "Adding a Native JNI Module" procedure updated: a new module needs a gated build step + verify entries in
build-natives.yamlonly; consumer workflows need no changes anymore.Net: -1806 lines of YAML, and after this PR's first run populates the caches, an unchanged-natives PR spends ~5 min of runner time on natives instead of ~1.5-2 h aggregate.
Validation
actionlintclean (only pre-existing shellcheck warnings)