Repository navigation
Push Spack packages to the build cache as they are built - #4716
Draft
garth-wells wants to merge 12 commits into
Draft
garth-wells wants to merge 12 commits into
garth-wells wants to merge 12 commits into
Conversation
Enable autopush on the build cache mirror so each package built from source is pushed straight after it installs. A run that is cancelled (e.g. superseded on a pull request) or times out keeps what it built, rather than losing everything before the post-install push. The DOLFINx packages built at the current commit are excluded from pushes, as they are never reused. The existing push steps are kept: they copy in packages taken from Spack's public cache, attach the base image and update the index. Autopush, like the RHEL workflow's push step, is skipped for pull requests from forks, which have a read-only token. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With autopush, every package built from source is already in the cache, so the push steps only rebuilt the index. Recent runs took no packages from Spack's public cache, so there is nothing to copy in. Replace the push steps with 'buildcache update-index'. Exclude intel-oneapi-compilers from pushes: autopush ignores a package's 'redistribute' setting, which 'buildcache push' honoured, so it would otherwise be uploaded to the public cache. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Rebuilding the index scans the whole cache, and running it on every leg of every run was a regression from the push steps it replaced, which rebuilt it only after an upload. Check whether any pushable package was built from source first, and move the step to the end of the ci.yml job so the tests do not wait for it. Move the push exclusions into the environment files next to the mirror definition. Exclude develop specs and their dependents with 'dev_path=*' rather than naming two of them: no develop spec is reused, so none is worth pushing. Compute the fork pull request check once per workflow, move 'spack debug report' out of the cache step so fork runs keep it, and fix a stale comment on fail-fast. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Legs rebuilding the index concurrently could overwrite each other's updates: each lists the cache and uploads a whole index, so the last upload wins even if its listing is older. Legs now upload a marker when they pushed something, and a follow-up job rebuilds the index once, in a concurrency group shared by both Spack workflows. A failure of built_from_source.py now fails its step, instead of being hidden by the command substitution in a test. Add the file header. Turn off Spack's public build cache in setup-spack: recent runs took none of their packages from it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Move the reusable index workflow into each Spack workflow as a job, and run the built-from-source check via 'spack python -c', removing two files. Concurrency groups are repository-wide, so index rebuilds still serialise across both workflows. Run the check and the index job with always() rather than !cancelled(), so packages autopush sent before a cancellation are indexed and reused. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
'spack python -c' compiles its argument as a single interactive statement, so the multi-statement check failed with a SyntaxError. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Lets a maintainer force an index rebuild, e.g. after a failed or skipped update, by running the workflow by hand. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The OCI index rebuild fetches every package's manifest and config. That is network-bound, but Spack sizes its pool to the CPU count (4 on a standard runner): a full rebuild took 34.5 min. Use 32 workers, past which ghcr.io throughput falls off, and raise the connection timeout from 10 s to 60 s, since one fetch that exhausts its retries aborts the whole rebuild. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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.
Spack CI pushed packages to
ghcr.io/fenics/spack-buildcacheonly afterspack installfinished. The push steps hadif: !cancelled(), so a run that was cancelled or timed out lost everything it had built. On pull requests this happens on every new commit, which makes cold-cache rebuilds (e.g. after apackages_refbump) slow to warm the cache.This enables Spack's mirror
autopushinci.ymlandci-spack.yml, so each package is pushed as soon as it is built from source.Changes
spack mirror set --autopush local-buildcache, only when the run can push. ACACHE_PUSHenv flag, computed once per workflow, excludes pull requests from forks, which have a read-only token.github-actions-buildcache. Not needed: in the latest run of each workflow, 0 of the ~175 cache-installed packages came from the public cache. That mirror is now turned off (buildcache: falseinsetup-spack).update-buildcache-indexjob in each workflow that runs once per workflow run, after the matrix legs:spack python -ccheck. It looks for the.spack/binary_distributionfile that cache installs carry, and applies the mirror's push filters. A leg that built something sets the job outputbuilt_from_source=true. Legs only ever settrue, so one that built nothing cannot overwrite it.true.always(), so a cancelled run still indexes what autopush pushed before the cancellation. A job killed by its timeout does not reach the check.spack-buildcache-index. Group names are repository-wide, so rebuilds are serialised across the two workflows. Rebuilds running at the same time could overwrite each other's updates, because each one lists the cache and uploads a whole index.dev_path=*and^dev_path=*ingh-actions-env-test.yml. Develop specs are never reused, and the old flow uploaded several of them.intel-oneapi-compilersingh-actions-rh.yml.buildcache pushskips non-redistributable packages, but autopush ignoresredistribute, so without this it would upload the Intel compilers to the public registry.Trade-offs
Testing
trueafter a source build andfalsewhen all installs carried the cache marker. This was tested as a standalone script, before it was moved inline; the inline form was checked only for parsing and Python syntax.actionlintreported nothing new before the index job and check were moved inline. It has not been re-run since.AI assistance: I used Claude Code (Claude Opus 5.5) to draft parts of this PR. I reviewed, edited, tested, and take responsibility for the final contribution.
🤖 Generated with Claude Code