Skip to content

tools/code: Run the code check in check_test directly - #48654

Merged
phlax merged 2 commits into
envoyproxy:mainfrom
wdauchy:ci-checked-no-remote-cache
Oct 24, 2026
Merged

phlax merged 2 commits into
envoyproxy:mainfrom
wdauchy:ci-checked-no-remote-cache

Conversation

@wdauchy

@wdauchy wdauchy commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Commit Message: tools/code: Run the code check in check_test directly

Additional Description:
The //tools/code:checked genrule 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_test with identical output (ImportError: cannot import name 'version' from 'packaging'), with checked served 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_test directly. 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: buildifier on tools/code/BUILD. Not built locally; relying on the format job 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.

`//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 phlax left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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]>
@wdauchy wdauchy changed the title tools/code: Do not remote cache the checked genrule tools/code: Run the code check in check_test directly Oct 24, 2026
@wdauchy

wdauchy commented Oct 24, 2026

Copy link
Copy Markdown
Contributor Author

Agreed, that is better. I dropped the genrule and check_test now runs the checker itself and fails if it exits non-zero or prints anything (80b3d13). Bazel does not cache failed tests, so a crash is retried on the next run, and passing results stay cached on //bazel:volatile-scm-hash as before. The no-remote-cache tag is gone.

@wdauchy
wdauchy requested a review from phlax October 24, 2026 12:16

@phlax phlax left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice, lgtm, thanks @wdauchy

@phlax
phlax merged commit 6b61ca0 into envoyproxy:main Oct 24, 2026
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants