Skip to content

Conversation

@gmackall
Copy link
Member

@gmackall gmackall commented Feb 14, 2024

Adds a kotlin linting step to the linux analyze check, using a version of ktlint hosted on CIPD.

Configured to disallow trailing commas, because of (and now acting as a test for) #145718. Because of this configuration the PR also removes some trailing commas in some kotlin files.

Also checks in a baseline file.

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, including Features we expect every widget to implement.
  • I signed the CLA.
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is test-exempt.
  • All existing and new tests are passing.

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

@gmackall
Copy link
Member Author

gmackall commented Feb 14, 2024

Example of the linting working: https://ci.chromium.org/ui/p/flutter/builders/try/Linux%20analyze/73795/overview

 Found lint violations in Kotlin files:
║  20:13:09.867 [main] INFO com.pinterest.ktlint.cli.internal.KtlintCommandLine -- Enable default patterns [**/*.kt, **/*.kts]
║ /b/s/w/ir/x/w/flutter/examples/api/android/app/src/main/kotlin/dev/flutter/flutter_api_samples/MainActivity.kt:1:9: Package name must not contain underscore (standard:package-name)
║ /b/s/w/ir/x/w/flutter/dev/tracing_tests/android/app/src/main/kotlin/com/example/tracing_tests/MainActivity.kt:1:9: Package name must not contain underscore (standard:package-name)
║ /b/s/w/ir/x/w/flutter/dev/manual_tests/android/app/src/main/kotlin/dev/flutter/manual_tests/MainActivity.kt:1:9: Package name must not contain underscore (standard:package-name)
║ /b/s/w/ir/x/w/flutter/dev/benchmarks/platform_channels_benchmarks/android/app/src/main/kotlin/com/example/platform_channels_benchmarks/MainActivity.kt:5:9: Package name must not contain underscore (standard:package-name)
║ /b/s/w/ir/x/w/flutter/dev/a11y_assessments/android/app/src/main/kotlin/com/example/a11y_assessments/MainActivity.kt:1:9: Package name must not contain underscore (standard:package-name)
║ /b/s/w/ir/x/w/flutter/dev/integration_tests/deferred_components_test/android/app/src/main/kotlin/io/flutter/integration/deferred_components_test/MainActivity.kt:1:9: Package name must not contain underscore (standard:package-name)
║ /b/s/w/ir/x/w/flutter/dev/integration_tests/android_embedding_v2_smoke_test/android/app/src/main/kotlin/com/example/android_embedding_v2_smoke_test/MainActivity.kt:1:9: Package name must not contain underscore (standard:package-name)
║ /b/s/w/ir/x/w/flutter/dev/integration_tests/abstract_method_smoke_test/android/app/src/main/kotlin/com/example/abstract_method_smoke_test/MainActivity.kt:1:9: Package name must not contain underscore (standard:package-name)
║ /b/s/w/ir/x/w/flutter/dev/integration_tests/spell_check/android/app/src/main/kotlin/com/example/sc_int_test/MainActivity.kt:1:9: Package name must not contain underscore (standard:package-name)
║ /b/s/w/ir/x/w/flutter/dev/integration_tests/non_nullable/android/app/src/main/kotlin/com/example/non_nullable/MainActivity.kt:1:9: Package name must not contain underscore (standard:package-name)
║ 
║ Summary error count (descending) by rule:
║   standard:package-name: 10

Just need to figure out

  1. whether ktlint should live on CIPD, or continue to be downloaded, and
  2. If the place where the baseline is is fine.

@gmackall
Copy link
Member Author

Baseline is also working, as the check passes now with it included

@gmackall
Copy link
Member Author

gmackall commented Feb 14, 2024

@reidbaker FYI this is the pr in the state we discussed getting it to, where the decision just needs to be made if the linting tool should be on CIPD, or downloaded (current state) like the packages repo https://github.com/flutter/packages/blob/abb04bb89cca97e653764a60bde0ee4e816db322/script/tool/lib/src/format_command.dart#L39

(mod making some of the paths/executability of the file platform agnostic)

@gmackall gmackall mentioned this pull request Feb 27, 2024
8 tasks
auto-submit bot pushed a commit to flutter/cocoon that referenced this pull request Feb 29, 2024
@gmackall
Copy link
Member Author

Support for adding a dependency on ktlint just landed in https://flutter-review.googlesource.com/c/recipes/+/56760/, so this should be unblocked now. Just need to test to make sure its getting invoked properly, then clean up and get out of draft

@gmackall
Copy link
Member Author

cc @keyonghan (sorry for the continued questions on this!)
I'm trying to depend on ktlint in cipd now in this pr

dependencies: >-
        [
          {"dependency": "ktlint", "version": "version:version_1_1_1"}
        ]

and seeing an error that the version tag doesn't exist
https://logs.chromium.org/logs/flutter/buildbucket/cr-buildbucket/8752187117714240737/+/u/Install_ktlint/ensure_installed/stdout
but I thought that I had created it correctly here
https://chrome-infra-packages.appspot.com/p/flutter/ktlint/linux-amd64/+/version_1_1_1

Did I perhaps mess something up in this step?

@keyonghan
Copy link
Contributor

cc @keyonghan (sorry for the continued questions on this!) I'm trying to depend on ktlint in cipd now in this pr

dependencies: >-
        [
          {"dependency": "ktlint", "version": "version:version_1_1_1"}
        ]

and seeing an error that the version tag doesn't exist https://logs.chromium.org/logs/flutter/buildbucket/cr-buildbucket/8752187117714240737/+/u/Install_ktlint/ensure_installed/stdout but I thought that I had created it correctly here https://chrome-infra-packages.appspot.com/p/flutter/ktlint/linux-amd64/+/version_1_1_1

Did I perhaps mess something up in this step?

You need a full tag name: version:version_1_1_1.

@keyonghan
Copy link
Contributor

So instead of a reference, a tag may be more suitable for this case. (I need to update the doc again).

cipd set-ref flutter/ktlint/linux-amd64 -tag version:version_1_1_1 -version InstanceID

@gmackall
Copy link
Member Author

So instead of a reference, a tag may be more suitable for this case. (I need to update the doc again).

cipd set-ref flutter/ktlint/linux-amd64 -tag version:version_1_1_1 -version InstanceID

Hmm so I originally ran

cipd set-ref flutter/ktlint/linux-amd64 -ref version_1_1_1 -version cuHnxtuMe-YkvqnXhXeWPq3i_0TZv4ykCWmDQVxN7f8C

Changing ref to tag gives me an error that the flag doesn't exist

mackall-macbookpro:flutter_tools mackall$ cipd set-ref flutter/ktlint/linux-amd64 -tag=version:version_1_1_1 -version cuHnxtuMe-YkvqnXhXeWPq3i_0TZv4ykCWmDQVxN7f8C
flag provided but not defined: -tag
Moves a ref to point to a given version.

usage:  cipd set-ref <package or package prefix> [options]
  -cache-dir string
    	Directory for the shared cache (can also be set by CIPD_CACHE_DIR env var).
  -json-output path
    	A path to write operation results to.
  -log-level value
    	The logging level. Valid options are: debug, info, warning, error. (default info)
  -ref ref
    	A ref to point to the package instance (can be used multiple times).
  -service-account-json string
    	Path to JSON file with service account credentials to use. Or specify ":gce" to use GCE's default service account.
  -service-url string
    	Backend URL. If provided via an "ensure" file, the URL in the file takes precedence. (default https://chrome-infra-packages.appspot.com)
  -verbose
    	Enable more logging (deprecated, use -log-level=debug).
  -version string
    	Package version to point the ref to. (default "<version>")

I also assume that I'm not going to have permission currently either way, so I'll open another access request

@gmackall
Copy link
Member Author

Oh wait its probably supposed to be also set-ref -> set-tag, that works (at least up until permissions)

@gmackall
Copy link
Member Author

Okay nevermind, I was setting the version wrong 🤦. Sorry about that! Looks like the step is succeeding now https://ci.chromium.org/ui/p/flutter/builders/try/Linux%20analyze/76227/overview

@gmackall gmackall marked this pull request as ready for review April 2, 2024 20:39
@gmackall gmackall requested a review from a team April 2, 2024 20:41
auto-submit bot pushed a commit to flutter/cocoon that referenced this pull request Apr 2, 2024
Add doc how to add a tag to a cipd instance.

Context: flutter/flutter#143478
@gmackall gmackall added the autosubmit Merge PR when tree becomes green via auto submit App label Apr 3, 2024
@auto-submit
Copy link
Contributor

auto-submit bot commented Apr 3, 2024

auto label is removed for flutter/flutter/143478, due to - The status or check suite Google testing has failed. Please fix the issues identified (or deflake) before re-applying this label.

@auto-submit auto-submit bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Apr 3, 2024
@gmackall gmackall added the autosubmit Merge PR when tree becomes green via auto submit App label Apr 3, 2024
@auto-submit
Copy link
Contributor

auto-submit bot commented Apr 3, 2024

auto label is removed for flutter/flutter/143478, due to - The status or check suite Google testing has failed. Please fix the issues identified (or deflake) before re-applying this label.

@auto-submit auto-submit bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Apr 3, 2024
@gmackall
Copy link
Member Author

gmackall commented Apr 3, 2024

I'm pretty certain this does not affect g3 in any way (it only affects ci config, benchmarks, and a test file), so I'm going to override the google testing. I'm sorry if I was wrong 🙏

@gmackall gmackall added the autosubmit Merge PR when tree becomes green via auto submit App label Apr 3, 2024
@auto-submit auto-submit bot merged commit 29ed214 into flutter:master Apr 3, 2024
@reidbaker
Copy link
Contributor

I'm pretty certain this does not affect g3 in any way (it only affects ci config, benchmarks, and a test file), so I'm going to override the google testing. I'm sorry if I was wrong 🙏

Post submit test passed https://critique.corp.google.com/cl/621639365

engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Apr 4, 2024
auto-submit bot pushed a commit to flutter/packages that referenced this pull request Apr 4, 2024
flutter/flutter@e868e2b...ac2ca93

2024-04-04 [email protected] Roll Flutter Engine from aadf522e3c98 to 4303dc0d7a73 (1 revision) (flutter/flutter#146262)
2024-04-04 [email protected] Roll Flutter Engine from c57c8665b4eb to aadf522e3c98 (1 revision) (flutter/flutter#146261)
2024-04-04 [email protected] Roll Flutter Engine from ca7596642cfd to c57c8665b4eb (1 revision) (flutter/flutter#146259)
2024-04-04 [email protected] Roll Flutter Engine from 83c037c449b5 to ca7596642cfd (1 revision) (flutter/flutter#146258)
2024-04-04 [email protected] Roll Flutter Engine from 614154012e93 to 83c037c449b5 (1 revision) (flutter/flutter#146255)
2024-04-04 [email protected] Roll Flutter Engine from 41da00ac46bc to 614154012e93 (1 revision) (flutter/flutter#146250)
2024-04-04 [email protected] Roll Flutter Engine from 18fdcad40332 to 41da00ac46bc (6 revisions) (flutter/flutter#146246)
2024-04-04 [email protected] Roll pub packages (flutter/flutter#146245)
2024-04-03 [email protected] Add tests for theme_extension.1.dart API example. (flutter/flutter#145819)
2024-04-03 [email protected] Roll Flutter Engine from 349608d2b008 to 18fdcad40332 (6 revisions) (flutter/flutter#146240)
2024-04-03 [email protected] Add `missing_code_block_language_in_doc_comment` lint. (flutter/flutter#145354)
2024-04-03 [email protected] Magnifier cleanup (flutter/flutter#143558)
2024-04-03 [email protected] Set up Kotlin linting step in ci with ktlint (flutter/flutter#143478)
2024-04-03 [email protected] Roll Flutter Engine from 1a9e48ab1c9a to 349608d2b008 (1 revision) (flutter/flutter#146230)
2024-04-03 [email protected] Update ownership to GitHub handles (flutter/flutter#146221)
2024-04-03 [email protected] Roll Flutter Engine from d065763b1a63 to 1a9e48ab1c9a (1 revision) (flutter/flutter#146226)
2024-04-03 [email protected] Refactor fuchsia_precache (flutter/flutter#145978)
2024-04-03 [email protected] Roll Flutter Engine from b1c23addaec5 to d065763b1a63 (1 revision) (flutter/flutter#146218)
2024-04-03 [email protected] `computeDryBaseline` for rendering / widgets RenderBoxes (flutter/flutter#146143)
2024-04-03 [email protected] Roll Flutter Engine from 7b28ae1d15cb to b1c23addaec5 (1 revision) (flutter/flutter#146214)
2024-04-03 [email protected] Fix TextStyle.lerp() to properly interpolate text shadows (flutter/flutter#145666)
2024-04-03 [email protected] Renderflex cross intrinsic size with baseline alignment (flutter/flutter#146185)
2024-04-03 [email protected] Roll Flutter Engine from 56fa2c33a5f7 to 7b28ae1d15cb (1 revision) (flutter/flutter#146208)
2024-04-03 [email protected] Refactor customer_testing (flutter/flutter#145911)
2024-04-03 [email protected] Add `DropdownMenu` cursor behavior sample (flutter/flutter#146133)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC [email protected],[email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
@whesse
Copy link
Contributor

whesse commented Apr 8, 2024

This new test is breaking on the Dart CI, where we run the flutter analysis test with tip-of-tree Dart SDK.
Whatever is added to the Flutter recipes to install klint also needs to be added to the Dart script at https://dart.googlesource.com/sdk/+/refs/heads/main/tools/bots/flutter/analyze_flutter_flutter.sh

Alternatively, if there is a command-line option or environment variable to set to disable the klint checks, or if these could be made a separate test script, rather than adding them into the existing analyze.dart test, which otherwise just requires a normal framework installation.

@gmackall
Copy link
Member Author

gmackall commented Apr 8, 2024

This new test is breaking on the Dart CI, where we run the flutter analysis test with tip-of-tree Dart SDK. Whatever is added to the Flutter recipes to install klint also needs to be added to the Dart script at https://dart.googlesource.com/sdk/+/refs/heads/main/tools/bots/flutter/analyze_flutter_flutter.sh

Alternatively, if there is a command-line option or environment variable to set to disable the klint checks, or if these could be made a separate test script, rather than adding them into the existing analyze.dart test, which otherwise just requires a normal framework installation.

I'm fine reverting this and moving the new portion of the test to a different check/shard.

We should also definitely add documentation noting that this check is copied and run in the dart ci as well. Are there other tests that also get copied? Is there a testowner that should be added for this check? I'm not particularly sure how one could know of or anticipate this problem.

@gmackall
Copy link
Member Author

gmackall commented Apr 8, 2024

Can I ask why you run this test in the dart ci, with the latest dart? It seems like a significant portion of the checks it makes are functionality I wouldn't expect to be run anywhere else, or to be particularly tied to dart versions (things like 'Links for creating GitHub issues', 'Unexpected binaries...', 'All tool test files end in _test.dart...', etc).

@whesse
Copy link
Contributor

whesse commented Apr 8, 2024

We only want to run any changes in the Dart analyzer and linter against the framework code, and this is the Flutter framework test that does that. We could extract just the relevant parts into commands run directly in our script, but then it has the danger of getting out-of-sync with what the flutter framework runs. But it does make sense to skip all of the non-relevant tests run by analyze.sh.

OK, looking at it, I agree that we should extract the analyzer tests out to a separate set, since there are so many non-relevant tests in this suite. Either this suite could be split into two parts, or some option added to only run the analysis tests (but also on gallery and code snippets), or we would have to clone all the analysis test code into our script, with the disadvantages of code clones. So I don't think you should revert.

copybara-service bot pushed a commit to dart-lang/sdk that referenced this pull request Apr 12, 2024
The bots/flutter/analyze_flutter_flutter.sh script calls Flutter's
[flutter]/dev/bots/analyze.dart test script.

More tests have been added to that Flutter script, that test
Flutter style guide policies and Kotlin lints. Avoid running
all these tests, that do not depend on the Dart SDK being tested.
Only run the tests from Flutter's analyze.dart test that use
the Dart SDK analyzer.

Bug: flutter/flutter#143478
Change-Id: I12142a019a8cbeb70b40ca028d13325303e8db61
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/362483
Reviewed-by: Alexander Thomas <[email protected]>
TecHaxter pushed a commit to TecHaxter/flutter_packages that referenced this pull request May 22, 2024
flutter/flutter@e868e2b...ac2ca93

2024-04-04 [email protected] Roll Flutter Engine from aadf522e3c98 to 4303dc0d7a73 (1 revision) (flutter/flutter#146262)
2024-04-04 [email protected] Roll Flutter Engine from c57c8665b4eb to aadf522e3c98 (1 revision) (flutter/flutter#146261)
2024-04-04 [email protected] Roll Flutter Engine from ca7596642cfd to c57c8665b4eb (1 revision) (flutter/flutter#146259)
2024-04-04 [email protected] Roll Flutter Engine from 83c037c449b5 to ca7596642cfd (1 revision) (flutter/flutter#146258)
2024-04-04 [email protected] Roll Flutter Engine from 614154012e93 to 83c037c449b5 (1 revision) (flutter/flutter#146255)
2024-04-04 [email protected] Roll Flutter Engine from 41da00ac46bc to 614154012e93 (1 revision) (flutter/flutter#146250)
2024-04-04 [email protected] Roll Flutter Engine from 18fdcad40332 to 41da00ac46bc (6 revisions) (flutter/flutter#146246)
2024-04-04 [email protected] Roll pub packages (flutter/flutter#146245)
2024-04-03 [email protected] Add tests for theme_extension.1.dart API example. (flutter/flutter#145819)
2024-04-03 [email protected] Roll Flutter Engine from 349608d2b008 to 18fdcad40332 (6 revisions) (flutter/flutter#146240)
2024-04-03 [email protected] Add `missing_code_block_language_in_doc_comment` lint. (flutter/flutter#145354)
2024-04-03 [email protected] Magnifier cleanup (flutter/flutter#143558)
2024-04-03 [email protected] Set up Kotlin linting step in ci with ktlint (flutter/flutter#143478)
2024-04-03 [email protected] Roll Flutter Engine from 1a9e48ab1c9a to 349608d2b008 (1 revision) (flutter/flutter#146230)
2024-04-03 [email protected] Update ownership to GitHub handles (flutter/flutter#146221)
2024-04-03 [email protected] Roll Flutter Engine from d065763b1a63 to 1a9e48ab1c9a (1 revision) (flutter/flutter#146226)
2024-04-03 [email protected] Refactor fuchsia_precache (flutter/flutter#145978)
2024-04-03 [email protected] Roll Flutter Engine from b1c23addaec5 to d065763b1a63 (1 revision) (flutter/flutter#146218)
2024-04-03 [email protected] `computeDryBaseline` for rendering / widgets RenderBoxes (flutter/flutter#146143)
2024-04-03 [email protected] Roll Flutter Engine from 7b28ae1d15cb to b1c23addaec5 (1 revision) (flutter/flutter#146214)
2024-04-03 [email protected] Fix TextStyle.lerp() to properly interpolate text shadows (flutter/flutter#145666)
2024-04-03 [email protected] Renderflex cross intrinsic size with baseline alignment (flutter/flutter#146185)
2024-04-03 [email protected] Roll Flutter Engine from 56fa2c33a5f7 to 7b28ae1d15cb (1 revision) (flutter/flutter#146208)
2024-04-03 [email protected] Refactor customer_testing (flutter/flutter#145911)
2024-04-03 [email protected] Add `DropdownMenu` cursor behavior sample (flutter/flutter#146133)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC [email protected],[email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autosubmit Merge PR when tree becomes green via auto submit App

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants