Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Conversation

jmagman
Copy link
Member

@jmagman jmagman commented Nov 11, 2021

Add a new --target-variant and --src-dir option to the clang-tidy linter script.
Update lint.sh to pass along the src-dir instead of the compile-commands path. The dart script will interpret this as src-dir/out/host_debug/compile_commands.json by default. Alternative --target-variant can be passed into the shell script.

$ ci/lint.sh --target-variant ios_debug

This will allow variants (is that the right word here?) other than host_debug to be run by the linter.

The recipe can then run the script for different targets
https://flutter.googlesource.com/recipes/+/refs/heads/main/recipes/engine_unopt.py#99
will become something like:

Lint(api, 'ios_debug_unopt')
def Lint(api, variant):
  checkout = GetCheckoutPath(api)
  with api.context(cwd=checkout):
    lint_cmd = checkout.join('flutter', 'ci', 'lint.sh', '--lint-all', '--target-variant', variant)
    api.step(api.test_utils.test_step_name('lint test'), [lint_cmd])

Note: in the future when the recipe is updated to use --target-variant, any outstanding PRs older than this script change will fail until merged in/rebased. I don't think it will impact future releases since they are versioned (will a beta release without this change run with that recipe? @christopherfujino )

Git pre-push hook continues to pass in --compile-commands and still works.

Other improvements:

  • --format-style=file to use .clang-format file for fixes.
  • Show all linter errors, not just the first one found.
  • Remove the --repo option, calculate that directory relative to the script path.

flutter/flutter#61661

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide and the C++, Objective-C, Java style guides.
  • I listed at least one issue that this PR fixes in the description above.
  • I added new tests to check the change I am making or feature I am adding, or Hixie said the PR is test-exempt. See testing the engine for instructions on
    writing and running engine tests.
  • I updated/added relevant documentation (doc comments with ///).
  • I signed the CLA.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@jmagman jmagman self-assigned this Nov 11, 2021
@google-cla google-cla bot added the cla: yes label Nov 11, 2021
import 'package:path/path.dart' as path;

// Path to root of the flutter/engine repository containing this script.
final String _engineRoot = path.dirname(path.dirname(path.dirname(path.dirname(path.fromUri(io.Platform.script)))));
Copy link
Member

Choose a reason for hiding this comment

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

If you're computing this here, maybe we don't need the --repo command line argument anymore. Or the other way around, if you have the --repo argument, this is just the parent directory of that, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

Was there any case where --repo needs to handle some other repo directory? I wasn't sure why it was passed in in the first place.

Copy link
Member

Choose a reason for hiding this comment

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

This pattern is probably safe here since we're always running the script from source, but it would break if the script were compiled to a snapshot and then the snapshot moved somewhere else before being run.

We can keep this and get rid of the --repo argument if that is simpler.

Copy link
Member Author

Choose a reason for hiding this comment

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

it would break if the script were compiled to a snapshot and then the snapshot moved somewhere else before being run.

If you do that and it doesn't work: Give The Script A Break 🙂

Copy link
Member Author

Choose a reason for hiding this comment

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

Removed --repo.

@@ -229,16 +229,8 @@ class ClangTidy {
if (job.result.exitCode == 0) {
continue;
}
if (job.exception != null) {
Copy link
Member Author

Choose a reason for hiding this comment

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

Updated to remove this block. It was only showing the first file linter errors because a linter failure makes the process fail, which populates the job.exception, and breaks so doesn't show the other job failures.

Copy link
Member

Choose a reason for hiding this comment

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

Nice catch

import 'package:path/path.dart' as path;

// Path to root of the flutter/engine repository containing this script.
final String _engineRoot = path.dirname(path.dirname(path.dirname(path.dirname(path.fromUri(io.Platform.script)))));
Copy link
Member

Choose a reason for hiding this comment

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

This pattern is probably safe here since we're always running the script from source, but it would break if the script were compiled to a snapshot and then the snapshot moved somewhere else before being run.

We can keep this and get rid of the --repo argument if that is simpler.

Copy link
Contributor

@christopherfujino christopherfujino left a comment

Choose a reason for hiding this comment

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

this shouldn't be an issue for beta branches, provided the engine builds were passing at the time the branch was made.

@jmagman jmagman added the waiting for tree to go green This PR is approved and tested, but waiting for the tree to be green to land. label Nov 11, 2021
@fluttergithubbot fluttergithubbot merged commit 18fc3b4 into flutter:master Nov 11, 2021
@jmagman jmagman deleted the lint-variant branch November 11, 2021 22:00
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Nov 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cla: yes waiting for tree to go green This PR is approved and tested, but waiting for the tree to be green to land.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants