Skip to content
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

feat: adding gradlew version to the doctor output #2255

Merged
merged 10 commits into from
Jun 18, 2024

Conversation

erickzanardo
Copy link
Contributor

Description

This PR is a first step in the path to Fix #1821.

It simply adds the version of the gradlew version in shorebird doctor.

In follow up PRs I plan to capture errors when running gradle, check if the error where a Unsupported class file major version XX one and if so, display a message to user explaining that this caused by the java version, that they can check the used java version and gralde version, and use the gradle compatibilty matrix to check which java version they should use.

Type of Change

  • ✨ New feature (non-breaking change which adds functionality)
  • 🛠️ Bug fix (non-breaking change which fixes an issue)
  • ❌ Breaking change (fix or feature that would cause existing functionality to change)
  • 🧹 Code refactor
  • ✅ Build configuration change
  • 📝 Documentation
  • 🗑️ Chore
  • 🧪 Tests

Copy link

codecov bot commented Jun 17, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (4400b0e) to head (dac8f13).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main     #2255   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          186       186           
  Lines         5862      5877   +15     
=========================================
+ Hits          5862      5877   +15     
Flag Coverage Δ
shorebird_cli 100.00% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@erickzanardo erickzanardo enabled auto-merge (squash) June 17, 2024 18:20
packages/shorebird_cli/lib/src/executables/gradlew.dart Outdated Show resolved Hide resolved
packages/shorebird_cli/lib/src/executables/gradlew.dart Outdated Show resolved Hide resolved
@@ -58,9 +58,7 @@ Gradlew get gradlew => read(gradlewRef);
class Gradlew {
String get executable => platform.isWindows ? 'gradlew.bat' : 'gradlew';

/// Return the set of product flavors configured for the app at [projectPath].
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice refactor!

Comment on lines 345 to 364
group('when gradlew exists', () {
group(
'when on linux',
() {
setUp(() {
when(() => platform.isLinux).thenReturn(true);
when(() => platform.isMacOS).thenReturn(false);
when(() => platform.isWindows).thenReturn(false);
File(
p.join(tempDir.path, 'android', 'gradlew'),
).createSync(recursive: true);
});

test('returns true', () {
expect(
runWithOverrides(() => gradlew.exists(tempDir.path)),
isTrue,
);
});
},
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can use testOn for these instead of mocking platform.isOS, now that we're running tests on all supported OSes.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, are the macos tests at all different from the linux tests? Can we have a single test for both?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed to use testOn and kept a single test for macos and linux

() {
expect(gradlew.exists(tempDir.path), isTrue);
},
testOn: 'linux || mac-os',
Copy link
Contributor

Choose a reason for hiding this comment

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

Neat, I didn't know OS1 || OS2 was supported syntax

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, me neither, I just learned. Apparently testOn uses this package: https://pub.dev/packages/boolean_selector

Comment on lines 390 to 392
when(() => platform.isLinux).thenReturn(true);
when(() => platform.isMacOS).thenReturn(false);
when(() => platform.isWindows).thenReturn(false);
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here re: testOn

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This one I am not sure if it is worth to run in all platforms, since all is being tested is the parsing of the output, which shouldn't change (at least the relevant part for us), no matter which platform we are.

And if I change to testOn, then I will need to write one test for each platform (or at least of for unix based and one for windows), because we need to mock the executable (which you can see a couple of lines above) path differently.

Lmk if this makes sense

Copy link
Contributor

Choose a reason for hiding this comment

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

You don't need to write one for each platform. I'm just suggesting that we use a consistent method of targeting a platform for a test.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

right, changed to use testOn on all tests.

Copy link
Contributor

@bryanoltman bryanoltman left a comment

Choose a reason for hiding this comment

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

I'd leave a comment about the version test that's not happening on windows (specifically that it's just to test the parsing of the output, and the output should be the same on all platforms)

@erickzanardo erickzanardo merged commit 3e08a4d into main Jun 18, 2024
11 checks passed
@erickzanardo erickzanardo deleted the feat/adding-gradlew-version-to-doctor branch June 18, 2024 18:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

fix: Unsupported class file major version 65 when running shorebird init on Linux
3 participants