chore(ci): disable buildvcs for builds and tests#19201
chore(ci): disable buildvcs for builds and tests#19201
Conversation
|
Skipping CI for Draft Pull Request. |
|
Images are ready for the commit at 6f7378f. 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 #19201 +/- ##
==========================================
- Coverage 49.56% 49.55% -0.01%
==========================================
Files 2675 2675
Lines 201820 201820
==========================================
- Hits 100023 100011 -12
- Misses 94340 94349 +9
- Partials 7457 7460 +3
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:
|
There was a problem hiding this comment.
Hey - I've found 1 issue, and left some high level feedback:
- Using
go-mod-with-buildvcs/go-build-with-buildvcsas cache key prefixes while the intent is to disablebuildvcsis confusing; consider renaming these prefixes to reflect the post-change behavior so it’s easier to compare and reason about cache behavior over time. - The change to always run the cache save step with PR-specific keys will increase cache writes and storage churn; if this is intended to be temporary, consider centralizing the feature flag (e.g., a single workflow-level input or environment toggle) so it’s easy to turn off or scope down (e.g., to a subset of workflows or branches) after the experiment.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Using `go-mod-with-buildvcs` / `go-build-with-buildvcs` as cache key prefixes while the intent is to *disable* `buildvcs` is confusing; consider renaming these prefixes to reflect the post-change behavior so it’s easier to compare and reason about cache behavior over time.
- The change to always run the cache save step with PR-specific keys will increase cache writes and storage churn; if this is intended to be temporary, consider centralizing the feature flag (e.g., a single workflow-level input or environment toggle) so it’s easy to turn off or scope down (e.g., to a subset of workflows or branches) after the experiment.
## Individual Comments
### Comment 1
<location path=".github/actions/cache-go-dependencies/action.yaml" line_range="20-29" />
<code_context>
+ # TEMPORARY: always save with PR-specific keys for cache testing.
</code_context>
<issue_to_address>
**suggestion:** Cache comment mentions PR-specific keys, but the keys themselves are not PR-scoped.
These cache keys:
- `go-mod-with-buildvcs-${{ hashFiles('**/go.sum') }}`
- `go-build-with-buildvcs-${{ github.job }}-${{ steps.cache-paths.outputs.GOARCH }}-${{ steps.cache-paths.outputs.TAG }}`
are not PR-scoped (they lack something like `github.ref_name` or `github.event.pull_request.number`), so caches will be shared across branches/PRs with the same hash/job/arch/TAG. Either update the keys to include a PR identifier if the intent is truly PR-specific caches, or adjust the comment to describe the broader sharing behavior accurately.
Suggested implementation:
```
# TEMPORARY: always save with broader cache keys (shared across branches/PRs) for cache testing.
```
If the intention is to truly scope caches per PR instead of sharing them across branches/PRs, you should also modify the `key:` (and optionally `restore-keys:`) fields for:
- `go-mod-with-buildvcs-${{ hashFiles('**/go.sum') }}`
- `go-build-with-buildvcs-${{ github.job }}-${{ steps.cache-paths.outputs.GOARCH }}-${{ steps.cache-paths.outputs.TAG }}`
to include a PR identifier such as `${{ github.ref_name }}` or `${{ github.event.pull_request.number }}` where those keys are defined elsewhere in this file.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| # TEMPORARY: always save with PR-specific keys for cache testing. | ||
| - name: Cache Go Dependencies (save) | ||
| if: inputs.save == 'true' && (github.event_name == 'push' && github.ref_name == github.event.repository.default_branch) | ||
| uses: actions/cache@v5 | ||
| with: | ||
| path: ${{ steps.cache-paths.outputs.GOMODCACHE }} | ||
| key: go-mod-v1-${{ hashFiles('**/go.sum') }} | ||
| restore-keys: go-mod-v1- | ||
|
|
||
| - name: Cache Go Dependencies (restore) | ||
| if: ${{ !(inputs.save == 'true' && (github.event_name == 'push' && github.ref_name == github.event.repository.default_branch)) }} | ||
| uses: actions/cache/restore@v5 | ||
| with: | ||
| path: ${{ steps.cache-paths.outputs.GOMODCACHE }} | ||
| key: go-mod-v1-${{ hashFiles('**/go.sum') }} | ||
| restore-keys: go-mod-v1- | ||
| key: go-mod-with-buildvcs-${{ hashFiles('**/go.sum') }} | ||
| restore-keys: go-mod-with-buildvcs- | ||
|
|
||
| - name: Cache Go Build (save) | ||
| if: inputs.save == 'true' && (github.event_name == 'push' && github.ref_name == github.event.repository.default_branch) | ||
| uses: actions/cache@v5 |
There was a problem hiding this comment.
suggestion: Cache comment mentions PR-specific keys, but the keys themselves are not PR-scoped.
These cache keys:
go-mod-with-buildvcs-${{ hashFiles('**/go.sum') }}go-build-with-buildvcs-${{ github.job }}-${{ steps.cache-paths.outputs.GOARCH }}-${{ steps.cache-paths.outputs.TAG }}
are not PR-scoped (they lack something like github.ref_name or github.event.pull_request.number), so caches will be shared across branches/PRs with the same hash/job/arch/TAG. Either update the keys to include a PR identifier if the intent is truly PR-specific caches, or adjust the comment to describe the broader sharing behavior accurately.
Suggested implementation:
# TEMPORARY: always save with broader cache keys (shared across branches/PRs) for cache testing.
If the intention is to truly scope caches per PR instead of sharing them across branches/PRs, you should also modify the key: (and optionally restore-keys:) fields for:
go-mod-with-buildvcs-${{ hashFiles('**/go.sum') }}go-build-with-buildvcs-${{ github.job }}-${{ steps.cache-paths.outputs.GOARCH }}-${{ steps.cache-paths.outputs.TAG }}
to include a PR identifier such as ${{ github.ref_name }} or ${{ github.event.pull_request.number }} where those keys are defined elsewhere in this file.
Description
Change: turn off Go's buildvcs version control injection
buildvcs=true/auto has been the Go default since Go 1.18 (2022). With
auto, when the .git repo files are found during the build, the build stampsvcs.revision,vcs.time, andvcs.modifiedinto every binary's BuildInfo. This data is hashed into the GOCACHE key. So every commit produces different keys even when no source files changed — invalidating large parts of both the build and test result caches.No code in the repository reads this VCS data (version info is managed separately via status.sh; there are no
debug.ReadBuildInfo()calls).Result: Disabling buildvcs improves Go build and test cache hit rates.
Local measurement
7 binaries (central, sensor/kubernetes, sensor/upgrader, migrator, roxctl, compliance, config-controller), after an empty commit (no source changes, only VCS data differs):
With
buildvcs=true, a new commit recompiles all main packages and invalidates all test result caches — even when no source files changed. Withbuildvcs=false, build and test caches are fully reused.Reproduce locally
References
https://tip.golang.org/doc/go1.18#go-version