chore(ci): use commit SHA for go-build cache key#19173
chore(ci): use commit SHA for go-build cache key#19173
Conversation
The weekly rotation (`date +%Yw%U`) made caches drop to 50% relevant within a week as dependencies changed. Using `github.sha` ensures each master push creates a fresh cache entry, improving cache hit quality for PR builds that restore from the latest master cache. Partially generated by AI. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Skipping CI for Draft Pull Request. |
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- The expression
echo "TAG=${{ github.sha }}"inside therunscript won’t be interpolated by GitHub Actions; instead, passgithub.shaviaenv(orwith) and reference it as"TAG=$GITHUB_SHA"in the shell to ensure the cache key is set correctly.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The expression `echo "TAG=${{ github.sha }}"` inside the `run` script won’t be interpolated by GitHub Actions; instead, pass `github.sha` via `env` (or `with`) and reference it as `"TAG=$GITHUB_SHA"` in the shell to ensure the cache key is set correctly.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
|
Images are ready for the commit at c435d9f. To use with deploy scripts, first |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #19173 +/- ##
==========================================
- Coverage 49.56% 49.55% -0.01%
==========================================
Files 2675 2675
Lines 201820 201820
==========================================
- Hits 100033 100018 -15
- Misses 94332 94343 +11
- Partials 7455 7459 +4
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Strange that this is suggested. It is not true as confirmed in the logs: https://github.com/stackrox/stackrox/actions/runs/22383687632/job/64789749598?pr=19173#step:5:23 |
The weekly rotation (
date +%Yw%U) made caches drop in usefulness within a week as code and dependencies changed. Usinggithub.shaensures each master push creates a fresh cache entry, improving cache hit quality for PR builds that restore from the latest master cache.Example runs:
~6 day old cache (23 commits in master; 11538 go source lines changed; 127 changed lines in go.mod files):
https://github.com/stackrox/stackrox/actions/runs/22299402991/job/64503285263#step:5:95
2026-02-23T09:05:54Z.
21m 3s job time
Cache hit for restore-key: go-build-v1-pre-build-cli-amd64-2026w07(cache entry saved Feb 17 19:42 UTC)
Same-day cache (1 commit in master; 34 go source lines changed; 0 changed lines in go.mod files):
https://github.com/stackrox/stackrox/actions/runs/22304627732/job/64520656630#step:5:96
2026-02-23T11:42:34Z.
5m 12s job time
Cache hit for: go-build-v1-pre-build-cli-amd64-2026w08(cache entry saved Feb 23 09:25 UTC)
1 day old (14 commits in master; 564 go source lines changed; 0 changed lines in go.mod files):
https://github.com/stackrox/stackrox/actions/runs/22384241635/job/64791416091?pr=19174#step:5:93
2026-02-25T05:53:38Z.
5m 44s job time
Cache hit for: go-build-v1-pre-build-cli-amd64-2026w08(cache entry saved Feb 23 09:25 UTC)
Partially generated by AI.