-
Notifications
You must be signed in to change notification settings - Fork 174
perf(ci): replace ldflags version injection with generated source file #19138
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
4616131
904957a
541b2f8
3036436
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,37 +14,38 @@ runs: | |
| echo "GOCACHE=$(go env GOCACHE)" >> "$GITHUB_OUTPUT" | ||
| echo "GOMODCACHE=$(go env GOMODCACHE)" >> "$GITHUB_OUTPUT" | ||
| echo "GOARCH=$(go env GOARCH)" >> "$GITHUB_OUTPUT" | ||
| echo "TAG=$(date +%Yw%U)" >> "$GITHUB_OUTPUT" | ||
| TAG="${{ contains(github.event.pull_request.labels.*.name, 'ci-save-cache') && github.event.pull_request.number || '' }}" | ||
| echo "TAG=${TAG:-$(date +%Yw%U)}" >> "$GITHUB_OUTPUT" | ||
| shell: bash | ||
|
|
||
| # Save caches only on pushes to the default branch. | ||
| # All other events (PRs, etc.) restore only. | ||
| # Save caches on pushes to the default branch, or on PRs with the | ||
| # ci-save-cache label (for testing cache-affecting changes on branches). | ||
| - name: Cache Go Dependencies (save) | ||
| if: inputs.save == 'true' && (github.event_name == 'push' && github.ref_name == github.event.repository.default_branch) | ||
| if: inputs.save == 'true' && (github.event_name == 'push' && github.ref_name == github.event.repository.default_branch || contains(github.event.pull_request.labels.*.name, 'ci-save-cache')) | ||
| uses: actions/cache@v5 | ||
| with: | ||
| path: ${{ steps.cache-paths.outputs.GOMODCACHE }} | ||
|
Comment on lines
+24
to
27
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. issue: Condition uses github.event.pull_request.* without guarding against non-PR events. The |
||
| 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)) }} | ||
| if: ${{ !(inputs.save == 'true' && (github.event_name == 'push' && github.ref_name == github.event.repository.default_branch || contains(github.event.pull_request.labels.*.name, 'ci-save-cache'))) }} | ||
| uses: actions/cache/restore@v5 | ||
| with: | ||
| path: ${{ steps.cache-paths.outputs.GOMODCACHE }} | ||
| key: go-mod-v1-${{ hashFiles('**/go.sum') }} | ||
| restore-keys: go-mod-v1- | ||
|
|
||
| - name: Cache Go Build (save) | ||
| if: inputs.save == 'true' && (github.event_name == 'push' && github.ref_name == github.event.repository.default_branch) | ||
| if: inputs.save == 'true' && (github.event_name == 'push' && github.ref_name == github.event.repository.default_branch || contains(github.event.pull_request.labels.*.name, 'ci-save-cache')) | ||
| uses: actions/cache@v5 | ||
| with: | ||
| path: ${{ steps.cache-paths.outputs.GOCACHE }} | ||
| key: go-build-v1-${{ github.job }}-${{ steps.cache-paths.outputs.GOARCH }}-${{ steps.cache-paths.outputs.TAG }} | ||
| restore-keys: go-build-v1-${{ github.job }}-${{ steps.cache-paths.outputs.GOARCH }}- | ||
|
|
||
| - name: Cache Go Build (restore) | ||
| if: ${{ !(inputs.save == 'true' && (github.event_name == 'push' && github.ref_name == github.event.repository.default_branch)) }} | ||
| if: ${{ !(inputs.save == 'true' && (github.event_name == 'push' && github.ref_name == github.event.repository.default_branch || contains(github.event.pull_request.labels.*.name, 'ci-save-cache'))) }} | ||
| uses: actions/cache/restore@v5 | ||
| with: | ||
| path: ${{ steps.cache-paths.outputs.GOCACHE }} | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,17 @@ | ||
| package internal | ||
|
|
||
| // Version variables with fallback defaults for ad-hoc builds (e.g. `go build` | ||
| // without the build infrastructure). When building via go-tool.sh, these are | ||
| // overridden by the generated zversion.go init() function. | ||
| var ( | ||
| // MainVersion is the Rox version. | ||
| MainVersion string //XDef:STABLE_MAIN_VERSION | ||
| MainVersion string | ||
| // CollectorVersion is the collector version to be used by default. | ||
| CollectorVersion string //XDef:STABLE_COLLECTOR_VERSION | ||
| CollectorVersion string | ||
| // FactVersion is the fact version to be used by default. | ||
| FactVersion string //XDef:STABLE_FACT_VERSION | ||
| FactVersion string | ||
| // ScannerVersion is the scanner version to be used with this Rox version. | ||
| ScannerVersion string //XDef:STABLE_SCANNER_VERSION | ||
| // GitShortSha is the (short) Git SHA that was built. | ||
| GitShortSha string //XDef:STABLE_GIT_SHORT_SHA | ||
| ScannerVersion string | ||
| // GitShortSha is the short git commit SHA. | ||
| GitShortSha string | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue (bug_risk): Using github.event.pull_request.* unguarded can fail on non-PR events.
This job runs on both push and PR events, but
github.event.pull_requestonly exists for PRs. On a push, accessinggithub.event.pull_request.labelsor.numberwill fail expression evaluation. Please guard this with a check likegithub.event_name == 'pull_request'(or a ternary that returns an empty value when not a PR) so push workflows don’t break.