Repository navigation
ci: cache the Nix store so nix develop jobs stop rebuilding Python 3.15.1 - #40
Merged
Merged
Conversation
…15.1 Building python3-3.15.1 took about 7 of the 8 minutes of the bats job in run 40116258703, because the derivation is not in cache.nixos.org. Cache /nix with nix-community/cache-nix-action, keyed by runner, flake.nix, flake.lock and nix/. The six nix develop jobs share one key; only the bats job on a push to main saves it, so pull requests read the main cache without writing their own and the repository cache quota holds one entry per lock state. A miss falls back to the unchanged build. Refs #38 Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Closed
5 tasks
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.
Closes #38
概要
nix developを使う CI ジョブが毎回 5〜9 分かかるのは,自前でビルドしている Python 3.15.1 が cache.nixos.org になく,ジョブごとにソースからコンパイルしているためでした.Nix のストア(/nix)を GitHub Actions のキャッシュに載せ,2 回目以降はビルド済みのものを使います.原因の確認
run 40116258703 の
batsジョブでは,python3-3.15.1.drvのビルドが 17:28:51 から 17:35:48 までの約 7 分で,ジョブ全体(約 8 分)の大半でした.bats のテスト本体(47 件)は約 13 秒です.変更
.github/workflows/ci.ymlのみ.test,bats,render,execpolicy,shell-lint,nix-checkの各ジョブで,Install Nixの直後にnix-community/cache-nix-actionを追加.nix-<os>-<arch>-<hash>.hashFiles('flake.nix', 'flake.lock', 'nix/**')を含むので,これらが変わると作り直されるbatsジョブだけ.PR は main のキャッシュを読むだけで,自分では書かない(PR のキャッシュは merge ref に閉じ,main から使えず,10GB の上限も圧迫するため)/nixだけ./etc/nix/nix.confや~/.cache/nixは含まれず,/nix/varから復元されるのはdb.sqliteのみ7df957e,v7)で固定.外部サービスや token は使わず,権限はcontents: readのままaction の選択
nix-community/cache-nix-actionとDeterminateSystems/magic-nix-cache-actionを比べ,前者を選びました.flake.lockとnix/の内容を鍵に入れる受け入れ条件を直接満たせるid-token: writeが要り,テレメトリも送る.パスごとに別エントリを作り,キャッシュ一覧も散らかるcontents: readのまま使え,/nixを 1 エントリにまとめる所要時間
batstestrenderexecpolicyshell-lintnix-checkレビュー(Opus サブエージェント 1 回)
github.jobを含め,ほぼ同じ内容の/nixを 6 エントリ保存していた.10GB の上限で追い出しが起きやすいため,鍵を共有しbatsだけが保存する形にしたtimeout-minutes: 20に含まれる.5〜9 分のビルドとテストのあとに数 GB の圧縮とアップロードが続くので,初回に timeout する可能性がある.マージ後の最初の main の run で所要時間を確認するbatsだけなので,batsが失敗か取り消しになると,その鍵のキャッシュは作られない既知の警告
zizmor が
./.github/actions/install-agent-harnessの記法について 3 件の警告を出すが,既存の記述であり今回は触っていない.🤖 Generated with Claude Code