Skip to content

chore(ci): use commit SHA for go-build cache key#19173

Open
davdhacs wants to merge 2 commits intomasterfrom
davdhacs/gha-cache-regular-master-updates
Open

chore(ci): use commit SHA for go-build cache key#19173
davdhacs wants to merge 2 commits intomasterfrom
davdhacs/gha-cache-regular-master-updates

Conversation

@davdhacs
Copy link
Contributor

@davdhacs davdhacs commented Feb 25, 2026

The weekly rotation (date +%Yw%U) made caches drop in usefulness within a week as code and 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.

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.

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>
@openshift-ci
Copy link

openshift-ci bot commented Feb 25, 2026

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • 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.
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.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@rhacs-bot
Copy link
Contributor

rhacs-bot commented Feb 25, 2026

Images are ready for the commit at c435d9f.

To use with deploy scripts, first export MAIN_IMAGE_TAG=4.11.x-181-gc435d9f851.

@codecov
Copy link

codecov bot commented Feb 25, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 49.55%. Comparing base (a4212e1) to head (c435d9f).
⚠️ Report is 1 commits behind head on master.

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     
Flag Coverage Δ
go-unit-tests 49.55% <ø> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@davdhacs
Copy link
Contributor Author

  • 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

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
echo "TAG=3ba3ac6aafd86a09662bbee94e039be9b76227eb" >> "$GITHUB_OUTPUT"

@davdhacs davdhacs marked this pull request as ready for review February 25, 2026 06:28
@davdhacs davdhacs requested a review from a team as a code owner February 25, 2026 06:28
@davdhacs davdhacs requested a review from janisz February 25, 2026 06:28
@davdhacs davdhacs requested a review from porridge February 26, 2026 05:09
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