-
Notifications
You must be signed in to change notification settings - Fork 6k
clang-tidy: Added an environment variable that allows fix to print the generated diff. #37024
Conversation
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat (don't just cc him here, he won't see it! He's on Discord!). If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix? Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
1b32c5d
to
08f1f58
Compare
08f1f58
to
f0b6515
Compare
# FLUTTER_LINT_PRINT_FIX will make it so that fix is executed and the generated | ||
# diff is printed to stdout if clang-tidy fails. This is helpful for enabling | ||
# new lints. | ||
if [[ -z "${FLUTTER_LINT_PRINT_FIX}" ]]; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of using an environment variable, I think it would be simpler to just test for the presence of --fix
in $@
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did that at first, but that makes it hard to use with the bots since $@
is changed in the bot configuration. This way you can just edit lint.sh file temporarily with FLUTTER_LINT_PRINT_FIX=1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, okay, I get it (I think). So the workflow is to modify the script on a PR branch to get the presubmit checks to generate the diff?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, that's the best I could come up with for now. Alternatively we could always execute with --fix
but I worry about execution time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally, we'd have something like flutter/flutter#114085, to pass the --fix flag only in presubmit. In the meantime, I think this change is okay. Would you mind adding a TODO in the code for me that links to that issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We definitely care about postsubmit cycle time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I wouldn't say they have equal weight though. Given that if there is a failure, turning this on and running again takes ~1hr to get results, it might be worth running it always. So the calculus as-to wether this should be turned on always or not should be: (likelihood of violation * 1hr) - ((1 - likelihood of violation) * 5min).
Let me run some tests locally since that 5 minute I just pulled out of my butt. Maybe it isn't so bad to always have it on. Also, maybe the real solution to performance isn't turning off something that is helpful and saves time but to do better sharding. I discuss this in the post-mortem I just sent. Now that I talk about this I think it's better to having this turn on always, assuming it doesn't add a crazy amount of time. I'll measure it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just ran it locally with a diff that was checking 47 files, there was a 12.5% increase in execution time so ~7.5 minutes longer to execute for one that takes ~1 hr.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, here is my suggestion:
- We add a new builder that runs only in pre-submit.
- It passes the --fix flag
- It only runs when .clang-tidy or engine tree source files have changed.
The new builder definition (one example) would looks something like this: #37082
The missing piece is a new parameter to the engine_lint.py recipe to trigger the logic in this PR around the --fix
flag, which would go here:
https://flutter.googlesource.com/recipes/+/refs/heads/main/recipes/engine/engine_lint.proto#8
and here
https://flutter.googlesource.com/recipes/+/refs/heads/main/recipes/engine/engine_lint.py#55
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should land this as is for now. This was helpful for me for now. Let's see about turning it on by default if we get feedback from the team that addressing the lints across multiple platforms is a pain. In normal usage this might not be a big deal and more for when migrating new lint flags. Once we land sharding we'll have some more breathing room to do the fix if we want since it is reducing the number of files linted from ~800 to ~600 that should still leave us ahead.
Another consideration that I just thought about is that the bots do some caching of the engine checkout to make the setup step for each run go faster. @godofredoc is there anything that could go wrong if a test step modifies the engine source checkout? Presumably, the test step should at least restore the repo to its original state, but is that sufficient? |
Git caches are maintained in [cache]/git and copied to [cache]/builder/src during the bot_update step. Changes to [cache]/builder/src are discarded at the end of the build execution with no impact to [cache]/git. The changes that impact git caches are changes to the DEPS file where repositories with different commit histories are cloned using the same name. E.g. changing github.com/flutter/buildroot to github.com/godofredoc/buildroot and using commits that only exist on the godofredo's fork to run presubmits. |
…114855) * 55ed37fb4 Roll Skia from dec7a930c0b7 to aef6d301c0b5 (4 revisions) (flutter/engine#37393) * e7d7edab9 clang-tidy: Added an environment variable that allows fix to print the (flutter/engine#37024)
…lutter#114855) * 55ed37fb4 Roll Skia from dec7a930c0b7 to aef6d301c0b5 (4 revisions) (flutter/engine#37393) * e7d7edab9 clang-tidy: Added an environment variable that allows fix to print the (flutter/engine#37024)
…lutter#114855) * 55ed37fb4 Roll Skia from dec7a930c0b7 to aef6d301c0b5 (4 revisions) (flutter/engine#37393) * e7d7edab9 clang-tidy: Added an environment variable that allows fix to print the (flutter/engine#37024)
This helps with migrating new linter checks that have fixes implemented. Turning this on allows the bots to print out the diff that can be patched locally across all platform CI checks.
issue: flutter/flutter#113848
Pre-launch Checklist
writing and running engine tests.
///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.