Skip to content

analyzer code presubmit checks #53578

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
1 of 7 tasks
srawlins opened this issue Sep 20, 2023 · 6 comments
Open
1 of 7 tasks

analyzer code presubmit checks #53578

srawlins opened this issue Sep 20, 2023 · 6 comments
Assignees
Labels
area-infrastructure Use area-infrastructure for SDK infrastructure issues, like continuous integration bot changes.

Comments

@srawlins
Copy link
Member

srawlins commented Sep 20, 2023

We brought up recently checks that we might want to make presubmit (on upload) checks for analyzer, Hopefully we can make some of these only trigger when certain files are changed:

  • touching pkg/analyzer/messages.yaml: run pkg/analyzer/tool/messages/messages_test.dart
  • touching pkg/analyzer/messages.yaml: check that Dart error code has been generated (dart pkg/analyzer/tool/messages/generate.dart)
  • touching pkg/analyzer/messages.yaml: check that Dart error code has been generated (dart pkg/analyzer/tool/diagnostics/generate.dart)
  • touching pkg/analyzer/lib/src/error/error_code_values.g.dart or pkg/linter/lib/src/rules.dart: run verify_error_fix_status.
  • touching pkg/{analyzer/analysis_server}/test files: check that test_all.dart files are updated.
  • touching pkg/{analyzer,analysis_server,linter,...} files: check that files are sorted.
  • touching any file in pkg/linter/lib/src/rules files: check that machine.json is not outdated.

CC @bwilkerson @scheglov @kallentu @pq @keertip

@srawlins srawlins added the area-infrastructure Use area-infrastructure for SDK infrastructure issues, like continuous integration bot changes. label Sep 20, 2023
@kallentu
Copy link
Member

These are great. I want these checks so badly.

Some other ones that I've burned time on:

  • Touching pkg/analyzer/messages.yaml sometimes needs a regeneration of the diagnostics if you change the documentation: dart run pkg/analyzer/tool/diagnostics/generate.dart.

  • Also, adding a new diagnostic in pkg/analyzer/messages.yaml, making sure that pkg/analysis_server/lib/src/services/correction/error_fix_status.yaml is updated. (I run python3 tools/test.py -n analyzer-unittest-asserts-release-linux pkg/analysis_server/test/verify_error_fix_status_test)

@pq
Copy link
Member

pq commented Sep 20, 2023

Emphatic 💯💯💯.

My understanding is that presubmits are largely written in python but hopefully we can (performantly) call out to dart so we don't have to duplicate logic we've already got?

@whesse, @athomas: maybe you could advise?

@bwilkerson
Copy link
Member

We do need to be careful not to add to much time to the presubmits. We might want to time some of these tests to ensure that they're all reasonable. Of course, it won't be as big an issue if they can run only when a specific file has been modified.

@scheglov
Copy link
Contributor

I agree that any additional checks that we add should be fast, or we don't add them.
I already manually comment out a few, such as

    // verify_diagnostics.main();
    // verify_docs.main();
    // verify_tests.main();

and pkg/analysis_server/test/benchmarks_test.dart

Because they take too much time, and I care about these checks only when I'm ready to sent CL.
No while I'm doing some work on element model that might affect many test, so I often run all of them.

Sometimes this causes me an issue that something fails on bots because I forgot to check.
But more often it would not, and I will just waste time running these checks.

@sortie
Copy link
Contributor

sortie commented Sep 25, 2023

All this logic sounds like it would fit very well into PRESUBMIT.py. It gives you a list of file paths, so it's easy to make the checks conditional, and you can shell out to dart easily. I think you're already totally empowered to just add in the logic exactly as it makes sense for you and send it to us for review. I'm happy to assist if you need help :)

The comment about expensiveness does matter, though at least if the checks are conditional on file paths, then at least they're only paid for by the relevant teams :)

@srawlins
Copy link
Member Author

On my laptop, verify_sorted_test.dart takes 20 seconds, which validates that files in all of our packages are sorted. Breaking into smaller tests, like just validating pkg/analyzer cuts down the time. pkg/analyzer takes 9 seconds, pkg/analysis_server takes 9 seconds.

messages_test.dart takes 2 seconds.
verify_tests_test.dart takes 3 seconds.
verify_error_fix_status_test.dart takes ~0 seconds.

@srawlins srawlins self-assigned this Oct 5, 2023
copybara-service bot pushed a commit that referenced this issue Oct 16, 2023
See the issue below, and the code comments, for the further plans.
I plan on adding whichever ones we find useful, as long as I can
keep them performant. This one is performant, and we can discuss
possible problematic checks on the issue.

Work towards #53578

Change-Id: Ie3980e6194e46574a01ad3e0bd8e36f7ac248917
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/329620
Reviewed-by: Brian Wilkerson <[email protected]>
Reviewed-by: Sigmund Cherem <[email protected]>
Reviewed-by: Phil Quitslund <[email protected]>
Reviewed-by: Kallen Tu <[email protected]>
Reviewed-by: Konstantin Shcheglov <[email protected]>
Commit-Queue: Samuel Rawlins <[email protected]>
Reviewed-by: Jonas Termansen <[email protected]>
copybara-service bot pushed a commit that referenced this issue Dec 15, 2023
Work towards #53578

Change-Id: Ia07d999abc2fcf4b8195c9f7688799bc099a1d88
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/341385
Reviewed-by: Phil Quitslund <[email protected]>
Reviewed-by: Alexander Thomas <[email protected]>
Reviewed-by: Jonas Termansen <[email protected]>
Commit-Queue: Samuel Rawlins <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-infrastructure Use area-infrastructure for SDK infrastructure issues, like continuous integration bot changes.
Projects
None yet
Development

No branches or pull requests

6 participants