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

Update pre-commit formatter to use java from repo rather than path. - #54450

Merged
eseidel merged 10 commits into
flutter-team-archive:mainfrom
shorebirdtech:java_path
Aug 9, 2024
Merged

eseidel merged 10 commits into
flutter-team-archive:mainfrom
shorebirdtech:java_path

Conversation

@eseidel

@eseidel eseidel commented Aug 8, 2024 •

Copy link
Copy Markdown
Contributor

This removes the recently added requirement of contributors having
java on their path.

Also removed the mention of java being needed in setup (I don't have java
installed and have built the engine from mac for years).

Fixes flutter/flutter#152968
Fixes flutter/flutter#129221

@flutter-dashboard

Copy link
Copy Markdown

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption, contact "@test-exemption-reviewer" in the #hackers channel in Discord (don't just cc them here, they won't see it!).

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. The test exemption team is a small volunteer group, so all reviewers should feel empowered to ask for tests, without delegating that responsibility entirely to the test exemption group.

@eseidel

eseidel commented Aug 8, 2024

Copy link
Copy Markdown
Contributor Author

Ah, I thought format didn't have tests, I now see that it does, will test, sec.

@eseidel

eseidel commented Aug 8, 2024

Copy link
Copy Markdown
Contributor Author

OK, I believe this should be ready for review.

@reidbaker reidbaker left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Lots of these changes are formatting. If there is something else changed in format.dart other than lines 498 - 524 can you call them out.

@eseidel

eseidel commented Aug 8, 2024 via email

Copy link
Copy Markdown
Contributor Author

This removes the recently added requirement of contributors having
java on their path.

Also removed the mention of java being needed in setup (I don't have java
installed and have built the engine from mac for years).

Fixes flutter/flutter#152968
Fixes flutter/flutter#129221
@eseidel
eseidel requested a review from reidbaker August 8, 2024 19:08
@eseidel

eseidel commented Aug 8, 2024

Copy link
Copy Markdown
Contributor Author

Fixed to remove formatting changes. PTAL. Thanks!

@reidbaker

Copy link
Copy Markdown
Contributor

Looks like linux is failing. I cant tell why maybe we do assume that java needs to be on the path for CI?

[2024-08-08 12:25:00.567034] ERROR: ERROR: Cannot run Java, skipping Java file formatting!

https://logs.chromium.org/logs/flutter/buildbucket/cr-buildbucket/8740146003425990369/+/u/test:_test:_Check_formatting__2_/stdout

@eseidel

eseidel commented Aug 8, 2024

Copy link
Copy Markdown
Contributor Author

I can look more shortly. I suspect the path may not exist for linux and it may need to use java. I can add a bit more logging and some minimal fallback behavior.

@eseidel

eseidel commented Aug 8, 2024

Copy link
Copy Markdown
Contributor Author

I had lost the "log the path" bits in my "remove formatting changes" update. Running the bots again should give us better data.

@eseidel

eseidel commented Aug 8, 2024

Copy link
Copy Markdown
Contributor Author

Turns out the paths inside openjdk differ per platform (based on searching for other uses of such in the repo). 🤦

@eseidel

eseidel commented Aug 9, 2024

Copy link
Copy Markdown
Contributor Author

OK, so this is the problem on linux:

ERROR: Cannot find Java (/b/s/w/ir/cache/builder/src/flutter/third_party/java/openjdk/bin/java). Did you run gclient sync? Skipping Java format check.

I might have gotten the location wrong, can look more later.

@eseidel

eseidel commented Aug 9, 2024

Copy link
Copy Markdown
Contributor Author

Hmm, looks like it's not always downloaded:

  'src/flutter/third_party/java/openjdk': {
     'packages': [
       {
        'package': 'flutter/java/openjdk/${{platform}}',
        'version': 'version:17'
       }
     ],
     'condition': 'download_android_deps',
     'dep_type': 'cipd',
   },
  # Checkout Android dependencies only on platforms where we build for Android targets.
  'download_android_deps': 'host_os == "mac" or (host_os == "linux" and host_cpu == "x64")',

@reidbaker
reidbaker requested a review from matanlurey August 9, 2024 13:56
Comment thread ci/bin/format.dart
final bool plural = failed.length > 1;
if (fixing) {
error('Fixing ${failed.length} Java file${plural ? 's' : ''}'
message('Fixing ${failed.length} Java file${plural ? 's' : ''}'

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is just changing to match what the C++ formatter does in this case.

@eseidel

eseidel commented Aug 9, 2024

Copy link
Copy Markdown
Contributor Author

Looks like this is ready (as far as the bots are concerned), but I'm in no rush to land. Looks like you CC'd matan, so I'll happily wait for additional reviews (or feel free to click squash and merge once reviewed).

@reidbaker

Copy link
Copy Markdown
Contributor

Looks like this is ready (as far as the bots are concerned), but I'm in no rush to land. Looks like you CC'd matan, so I'll happily wait for additional reviews (or feel free to click squash and merge once reviewed).

I added matan because I thought you would need 2 contributors to approve but you are a contributor. Feel free to land and consider matan fyi.

@eseidel

eseidel commented Aug 9, 2024

Copy link
Copy Markdown
Contributor Author

I'll wait for the bots to green again (after I removed the prints) and then press squash. Thanks!

@eseidel
eseidel merged commit 19d858e into flutter-team-archive:main Aug 9, 2024
@eseidel
eseidel deleted the java_path branch August 9, 2024 15:16

@matanlurey matanlurey left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Aug 9, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Aug 9, 2024
auto-submit Bot pushed a commit to flutter/flutter that referenced this pull request Aug 9, 2024
flutter-team-archive/engine@c9ec468...4d5b1df

2024-08-09 [email protected] Roll Skia from 31c432c02665 to 13b4fee1ba99 (1 revision) (flutter-team-archive/engine#54470)
2024-08-09 [email protected]  Update pre-commit formatter to use java from repo rather than path. (flutter-team-archive/engine#54450)
2024-08-09 [email protected] Remove swiftshader from the license script excludes list (flutter-team-archive/engine#54412)
2024-08-09 [email protected] Roll Dart SDK from 1cc09f3f3642 to 35bc5c866149 (1 revision) (flutter-team-archive/engine#54468)
2024-08-09 [email protected] Roll Skia from 0bedf6746d9e to 31c432c02665 (1 revision) (flutter-team-archive/engine#54467)
2024-08-09 [email protected] Roll Dart SDK from 9222e4c96f4d to 1cc09f3f3642 (2 revisions) (flutter-team-archive/engine#54465)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-engine-flutter-autoroll
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 Flutter: 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
Comment thread DEPS
}
],
'condition': 'download_android_deps',
# Always download the JDK since java is required for running the formatter.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

DBC: This should continue to be controlled by a variable. It can default to true for local dev, but then CI builds that don't need it can still set it to false.

@eseidel

eseidel commented Aug 10, 2024 via email

Copy link
Copy Markdown
Contributor Author

@zanderso

Copy link
Copy Markdown
Contributor

What does DBC mean? Would you like action from me? Thanks!

Oh, sorry. It means drive-by comment. As a follow-up, if you wouldn't mind doing the following, it would be helpful:

  1. Add a new gclient var next to download_android_deps called something like download_jdk and default it to true.
  2. In the json files under ci/builders, wherever you see download_android_deps set to false, also set download_jdk to false.

This will save on repo checkout time on the CI bots. Thanks!

@eseidel

eseidel commented Aug 16, 2024

Copy link
Copy Markdown
Contributor Author

This is still in my inbox (I've not forgotten), but it may be a while before I code again.

@reidbaker reidbaker mentioned this pull request Aug 16, 2024
5 of 8 tasks
DBowen33 pushed a commit to DBowen33/flutter that referenced this pull request Aug 16, 2024
…3182)

flutter-team-archive/engine@c9ec468...4d5b1df

2024-08-09 [email protected] Roll Skia from 31c432c02665 to 13b4fee1ba99 (1 revision) (flutter-team-archive/engine#54470)
2024-08-09 [email protected]  Update pre-commit formatter to use java from repo rather than path. (flutter-team-archive/engine#54450)
2024-08-09 [email protected] Remove swiftshader from the license script excludes list (flutter-team-archive/engine#54412)
2024-08-09 [email protected] Roll Dart SDK from 1cc09f3f3642 to 35bc5c866149 (1 revision) (flutter-team-archive/engine#54468)
2024-08-09 [email protected] Roll Skia from 0bedf6746d9e to 31c432c02665 (1 revision) (flutter-team-archive/engine#54467)
2024-08-09 [email protected] Roll Dart SDK from 9222e4c96f4d to 1cc09f3f3642 (2 revisions) (flutter-team-archive/engine#54465)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-engine-flutter-autoroll
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 Flutter: 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
auto-submit Bot pushed a commit that referenced this pull request Aug 19, 2024
Buchimi pushed a commit to Buchimi/flutter that referenced this pull request Sep 2, 2024
…3182)

flutter-team-archive/engine@c9ec468...4d5b1df

2024-08-09 [email protected] Roll Skia from 31c432c02665 to 13b4fee1ba99 (1 revision) (flutter-team-archive/engine#54470)
2024-08-09 [email protected]  Update pre-commit formatter to use java from repo rather than path. (flutter-team-archive/engine#54450)
2024-08-09 [email protected] Remove swiftshader from the license script excludes list (flutter-team-archive/engine#54412)
2024-08-09 [email protected] Roll Dart SDK from 1cc09f3f3642 to 35bc5c866149 (1 revision) (flutter-team-archive/engine#54468)
2024-08-09 [email protected] Roll Skia from 0bedf6746d9e to 31c432c02665 (1 revision) (flutter-team-archive/engine#54467)
2024-08-09 [email protected] Roll Dart SDK from 9222e4c96f4d to 1cc09f3f3642 (2 revisions) (flutter-team-archive/engine#54465)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-engine-flutter-autoroll
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 Flutter: 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
@knopp

knopp commented Jan 20, 2025

Copy link
Copy Markdown
Contributor

This seems to break engine build on Linux/Arm64

flutter/flutter#157576

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Development

Successfully merging this pull request may close these issues.

flutter/engine should not require oracle's java installed to commit Enable the Java format check unit tests

5 participants