fix quickstyle: prefer repo tools and cache goimports#116
Merged
Conversation
quickstyle now prefers repo-managed tool binaries via `make which-*` (e.g. gotools), avoiding failures in stackrox2 when PATH/GOPATH contain stale tools (notably roxvet panics due to Go version mismatch). It also auto-installs goimports (pinned to the repo’s golang.org/x/tools version when available) into a workflow cache so “goimports: command not found” doesn’t break runs, and documents the helper functions for maintainability. AI: implemented the tool-resolution logic, caching/install behavior, and the added helper-function documentation. User: provided the requirements, validated behavior by running quickstyle, and reviewed/accepted the change. rh-pre-commit.version: 2.3.2 rh-pre-commit.check-secrets: ENABLED
Contributor
Author
|
This change is part of the following stack: Change managed by git-spice. |
janisz
approved these changes
Dec 16, 2025
janisz
left a comment
There was a problem hiding this comment.
Tested! It's working for me:
before I have a lot of similar panics
# go.uber.org/zap/internal/exit
panic: assertion failed [recovered]
panic: assertion failed
now:
quickstyle
[INFO] 4 files changed from master, 4 changed since the last successful quickstyle run.
[INFO] Adding missing newlines...
[INFO] Running go style checks...
[INFO] golangci-lint
0 issues.
[INFO] imports
[INFO] blanks
[INFO] fmt
[INFO] roxvet
[INFO] staticcheck
[WARN] Skipping staticcheck, doesn't appear to be supported in the repo.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Updated
quickstyleto be more reliable in StackRox repos by resolving Go tooling via repo-managed binaries when available and by ensuring required tools exist.Why
Running
quickstyleagainststackroxrepo could fail for non-style reasons.Before this change
roxvetfromGOPATH/bin:quickstylewould use$(go env GOPATH)/bin/roxvetif present. If it was built with an older Go version than the target repo’s toolchain, it could error with “package requires newer Go version …” and/or panic (e.g.pkgbits unsupported version: 2).goimports:quickstylecalledgoimportsdirectly without ensuring it exists, so environments withoutgoimportsonPATHfailed withgoimports: command not found.stackroxmanage tools under.gotools/bin(viamake which-*), butquickstyledidn’t prefer those canonical binaries, so results depended on whatever was installed globally.This change makes
quickstyleprefer repo toolchain wiring (viamake which-*) and provides a workflow-managed fallback forgoimports.Changes
make which-<tool>when available (e.g. gotools-basedroxvet,golangci-lint).GOPATH/bin/roxvet(Go major/minor mismatch) and rebuild it when possible.goimportsis available by installing it into a workflow cache (pinned to the repo’sgolang.org/x/toolsversion when available) and reusing it.How I validated my change
stackroxby running:cd ../stackrox && ../workflow/bin/quickstylegoimports: command not foundroxvet(and uses/rebuilds a compatibleroxvet)Example run after the changes:
AI / human attribution
make which-*+ fallbacks),goimportscaching/installation behavior, and helper-function documentation.