Skip to content

ci: only save caches from main - #4051

Merged
Max Smythe (maxsmythe) merged 2 commits into
agent-substrate:mainfrom
BenTheElder:ci-cache-main-only
Nov 21, 2026
Merged

Max Smythe (maxsmythe) merged 2 commits into
agent-substrate:mainfrom
BenTheElder:ci-cache-main-only

Conversation

@BenTheElder

@BenTheElder Benjamin Elder (BenTheElder) commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

Part of #3721. Follows #3722.

PR and merge queue runs could save caches, but those entries are only visible to their own ref, and the repo is at the 10GB cache limit, so they evict main's. Now only main saves, and everything else restores main's.

  • run-tests uses its own Go cache keyed on the commit, like e2e already does, instead of setup-go's, which saves from any ref and only when go.sum changes.
  • verify gets its own cache for the tools it builds and golangci-lint results, keyed on the commit like the others.
  • cargo and microVM assets restore everywhere and save from main on a miss.

AI use: AI drafted the change. I reviewed it.

PR and merge queue entries are only visible to their own ref, and evict main's under the 10GB repo limit.

verify gets its own cache for the tools it builds and golangci-lint results.

Signed-off-by: Benjamin Elder <bentheelder@google.com>

@maxsmythe Max Smythe (maxsmythe) left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI found some questions :)

Comment thread .github/workflows/pr-workflow.yaml Outdated
~/.cache/go-build
~/.cache/golangci-lint
~/go/pkg/mod
key: verify-go-${{ runner.os }}-${{ hashFiles('**/go.sum') }}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 should-fix 🟡 – Go deletes build cache entries whose mtime is more than 5 days old, and this cache is only written by a main run with a new go.sum. go.sum often goes longer than that without changing. After that, the first go command in each run trims most of the restored ~/.cache/go-build, and verify rebuilds its tools. Keying on the commit like unit-go and e2e-go avoids it.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed, keyed on the commit now

Comment thread .github/workflows/pr-workflow.yaml Outdated
sudo apt-get install -y -qq --no-install-recommends clang libclang-dev
hack/test-dynamic-modules.sh
- name: Save cargo cache
if: ${{ !cancelled() && github.ref == 'refs/heads/main' && steps.cargo-cache.outputs.cache-hit != 'true' }}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 should-fix 🟡 – !cancelled() saves after dynamic module tests fails. This key is written once per Cargo.lock, so a partial target stays until the lockfile changes again. The step also runs when an earlier step fails and the restore is skipped, and then it errors on the empty key. Dropping !cancelled() matches what actions/cache did. The verify save below pins a failed run's cache the same way.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed, the cargo save only runs on success now

path: |
~/.cache/go-build
~/go/pkg/mod
key: unit-go-${{ runner.os }}-${{ github.sha }}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 question 🟢 – On main today the setup-go cache is about 3GB and each e2e-go cache about 2.4GB, so every main commit will write over half the 10GB limit. Does that leave enough room for verify-go, cargo and the microVM assets to survive eviction between commits?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

eviction is by last access, and verify-go, cargo and the microVM assets are restored on every PR run, so the previous commit's unit-go / e2e-go / verify-go go first. the risk is one commit's caches getting near 10GB, we'll see the real sizes once main saves them (no super great way to do this before merge)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now that main has saved them: unit-go is 1.4GB, verify-go 1.7GB and e2e-go 1.7GB, so ~4.8GB per commit plus ~1GB of codeql. we're at 9.4GB, cargo and the microVM assets survived, and the old 3GB setup-go entry was evicted.

go trims build cache entries unused for 5 days, and a cache keyed on go.sum often outlives that.

the cargo save also ran after an earlier step failed and skipped the restore, with an empty key.

Signed-off-by: Benjamin Elder <bentheelder@google.com>

@maxsmythe Max Smythe (maxsmythe) left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@maxsmythe
Max Smythe (maxsmythe) added this pull request to the merge queue Nov 20, 2026
Merged via the queue into agent-substrate:main with commit 60a3d1a Nov 21, 2026
9 checks passed
@BenTheElder
Benjamin Elder (BenTheElder) deleted the ci-cache-main-only branch November 21, 2026 04:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants