Repository navigation
tools/code: Run the code check in check_test directly - #48654
Merged
Merged
Conversation
`//tools/code:checked` runs the code checker against the source tree through `--path`, so the tree is not a declared input. Its action key only changes with `//bazel:volatile-scm-hash`, which is derived from the tracked tree hash. The command also ends in `|| :`, so a run where the checker itself crashes still succeeds and its output is uploaded to the remote cache. Once such an output is cached, every later run on the same tree replays it and `//tools/code:check_test` fails, until the tree changes. Tag the genrule `no-remote-cache` so the check always runs locally. Signed-off-by: William Dauchy <[email protected]>
phlax
reviewed
Oct 24, 2026
phlax
left a comment
Member
There was a problem hiding this comment.
there are definitely better ways to skin this cat but for most part it wai and keeps ci fast
i would rather we address the error handling than not caching runs at all
one possibility is that we just ditch the genrule and make the sh_test test directly
Replace the `checked` genrule with the checker running inside `//tools/code:check_test`. The genrule ended in `|| :`, so a crash of the checker was a successful action whose output could be served from the remote cache to every later run on the same tree. The test now fails if the checker exits non-zero or prints anything. Bazel does not cache failed test results, so a crash is retried on the next run, while passing results are still cached and keyed on `//bazel:volatile-scm-hash`. This replaces the `no-remote-cache` tag added in the previous commit. Signed-off-by: William Dauchy <[email protected]>
checked genrulecheck_test directly
Contributor
Author
|
Agreed, that is better. I dropped the genrule and |
phlax
approved these changes
Oct 24, 2026
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.
Commit Message: tools/code: Run the code check in
check_testdirectlyAdditional Description:
The
//tools/code:checkedgenrule ran the code checker with|| :, so a crash of the checker was a successful action. Its cache key only changes with//bazel:volatile-scm-hash, so a cached crash is replayed by every later run on the same tree.On #48648, both attempts of https://github.com/envoyproxy/envoy/actions/runs/40078303704 failed
//tools/code:check_testwith identical output (ImportError: cannot import name 'version' from 'packaging'), withcheckedserved from the remote cache. The only earlier run on that tree, https://github.com/envoyproxy/envoy/actions/runs/40078213656, was cancelled during that test. How the checker crashed there is not confirmed.This removes the genrule and runs the checker in
check_testdirectly. The test fails if the checker exits non-zero or prints anything. Failed test results are not cached, so a crash is retried on the next run, and passing results are still cached on the same key.Risk Level: Low (CI only)
Testing:
buildifierontools/code/BUILD. Not built locally; relying on theformatjob of this PR.Docs Changes: N/A
Release Notes: N/A
Platform Specific Features: N/A
AI assistance: prepared with AI assistance (Cursor agent). We reviewed and understand all of it.