Title: perf(ci): replace ldflags version injection with generated source file by davdhacs · Pull Request #19138 · stackrox/stackrox · GitHub
Open Graph Title: perf(ci): replace ldflags version injection with generated source file by davdhacs · Pull Request #19138 · stackrox/stackrox
X Title: perf(ci): replace ldflags version injection with generated source file by davdhacs · Pull Request #19138 · stackrox/stackrox
Description: Replace the //XDef: + ldflags mechanism for injecting version data with a generated zversion.go file, following the same pattern Go itself uses for zbootstrap.go. This eliminates all -X ldflags for version stamping. Previously, go-tool.sh would grep for //XDef: annotations in Go source, match them to status.sh output, and pass the values via -X ldflags to the linker. This caused the linker cache to be invalidated on every version change (including GitShortSha which changed on every commit). Now, go-tool.sh generates pkg/version/internal/zversion.go with an init() function that sets the version variables. The file is only written when content changes (skip-if-same), so rebuilds with the same version produce zero cache churn -- neither the compile cache nor the link cache is invalidated. Additional changes: Add -buildvcs=false to suppress Go's automatic VCS stamping, which also changes on every commit and invalidates the main package cache Replace internal.GitShortSha with getGitCommitFromMainVersion() that extracts the SHA from MainVersion at runtime (e.g. "4.11.x-143-g4982da58fd" -> "4982da58fd") Remove STABLE_GIT_SHORT_SHA from status.sh (no longer needed) Allow GHA cache saves on PRs with ci-save-cache label Cache impact with -trimpath (already used): Compile cache: 100% stable across commits with unchanged source Link cache: stable when version string unchanged (skip-if-same) No ldflags in the build at all (only -s -w for stripping) Description change me! User-facing documentation CHANGELOG.md is updated OR update is not needed documentation PR is created and is linked above OR is not needed Testing and quality the change is production ready: the change is GA, or otherwise the functionality is gated by a feature flag CI results are inspected Automated testing added unit tests added e2e tests added regression tests added compatibility tests modified existing tests How I validated my change change me!
Open Graph Description: Replace the //XDef: + ldflags mechanism for injecting version data with a generated zversion.go file, following the same pattern Go itself uses for zbootstrap.go. This eliminates all -X ldflags for...
X Description: Replace the //XDef: + ldflags mechanism for injecting version data with a generated zversion.go file, following the same pattern Go itself uses for zbootstrap.go. This eliminates all -X ldflags for...
Opengraph URL: https://github.com/stackrox/stackrox/pull/19138
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:f03d8677-74d7-9d31-ce7f-2b59ef01ab1e |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | B98A:78281:657A1E:90CEAE:6A4CA9E8 |
| html-safe-nonce | fd4d319625d6df5e8caee235bae44753740d92067cdb2dcabc2e36ed66e44d8c |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCOThBOjc4MjgxOjY1N0ExRTo5MENFQUU6NkE0Q0E5RTgiLCJ2aXNpdG9yX2lkIjoiODU3MTk1NjczMjU2MDcxNDIxNiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 1d29dfa69ace7b5a8c6fe88277421547f72dc44d8a1896733a8228457664e16c |
| hovercard-subject-tag | pull_request:3317382148 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/stackrox/stackrox/pull/19138/files |
| twitter:image | https://avatars.githubusercontent.com/u/105243888?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/105243888?s=400&v=4 |
| og:image:alt | Replace the //XDef: + ldflags mechanism for injecting version data with a generated zversion.go file, following the same pattern Go itself uses for zbootstrap.go. This eliminates all -X ldflags for... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 3d11bb817438277de2a940854450e83a7d32b6aeb5014e9e6b00a6423900251c |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/stackrox/stackrox git https://github.com/stackrox/stackrox.git |
| octolytics-dimension-user_id | 40638982 |
| octolytics-dimension-user_login | stackrox |
| octolytics-dimension-repository_id | 434017296 |
| octolytics-dimension-repository_nwo | stackrox/stackrox |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 434017296 |
| octolytics-dimension-repository_network_root_nwo | stackrox/stackrox |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | ae90d426644ca15e89bacceb72e51f4e9dbf85f7 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width