Title: perf(ci): replace -X ldflags with go:embed for version data by davdhacs · Pull Request #19643 · stackrox/stackrox · GitHub
Open Graph Title: perf(ci): replace -X ldflags with go:embed for version data by davdhacs · Pull Request #19643 · stackrox/stackrox
X Title: perf(ci): replace -X ldflags with go:embed for version data by davdhacs · Pull Request #19643 · stackrox/stackrox
Description: Description Go's link ActionID includes -X ldflags verbatim. Today go-tool.sh passes per-commit values (full git describe output with commit count and SHA), so every commit invalidates the link cache for all binaries. This PR stabilizes build ldflags by using only the base tag (git describe --abbrev=0) in -X flags. Per-commit values (full version string, git short SHA) are written to untracked files and loaded at runtime via lazy go:embed + sync.Once. Depends on #19617 for the test-side ldflags fix. How it works go-tool.sh: ldflags use base tag for MainVersion (stable across commits). For builds only, writes MAIN_VERSION and GIT_SHORT_SHA_VERSION as untracked files. version_data.go: GetMainVersion() and GetGitShortSha() lazily read from embed.FS on first call. For tests (where files don't exist), falls back to ldflag values. EMPTY_SHA_VERSION: committed empty file satisfies the //go:embed *_SHA_VERSION glob when dynamic files are absent (fresh clone, go vet, tests). 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 modified existing tests How I validated my change CI green on seed run (all 11 unit-test jobs pass) local-roxctl-tests confirms version info is set correctly for builds go build and go vet work without go-tool.sh (embed glob matches EMPTY_SHA_VERSION) Partially generated by AI.
Open Graph Description: Description Go's link ActionID includes -X ldflags verbatim. Today go-tool.sh passes per-commit values (full git describe output with commit count and SHA), so every commit invalidates the link...
X Description: Description Go's link ActionID includes -X ldflags verbatim. Today go-tool.sh passes per-commit values (full git describe output with commit count and SHA), so every commit invalidates the ...
Opengraph URL: https://github.com/stackrox/stackrox/pull/19643
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:c635b32a-0458-3066-f8a5-ee266eee5d62 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | C92C:770CB:3C1E29:526A01:6A4D9FB5 |
| html-safe-nonce | c1c2e9c4f8e2fd06bfd49ab32b76c9292d896f4f7807a21cde9ff1d537a86695 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDOTJDOjc3MENCOjNDMUUyOTo1MjZBMDE6NkE0RDlGQjUiLCJ2aXNpdG9yX2lkIjoiNjU4MTcxNDk1OTcwODU2MTMzMyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | ec7ef3de348654db7965169d06e62d065819fcf6cefcdd78dd105780aa8d364b |
| hovercard-subject-tag | pull_request:3454871692 |
| 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/19643/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 | Description Go's link ActionID includes -X ldflags verbatim. Today go-tool.sh passes per-commit values (full git describe output with commit count and SHA), so every commit invalidates the link... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 06b8a6144231bf3a234f1c2e9993861e07ce98a905912b114aa386c2d7e84b33 |
| 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 | 7f13faa65cccc9b729d674da83335d5dcfdfd193 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width