-
Notifications
You must be signed in to change notification settings - Fork 9.8k
[script/tool] speed up the pub get portion of the analyze command #3982
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, just minor comments.
@@ -64,6 +65,14 @@ class AnalyzeCommand extends PluginCommand { | |||
} | |||
|
|||
final List<Directory> packageDirectories = await getPackages().toList(); | |||
final List<String> packagePaths = | |||
packageDirectories.map((Directory dir) => dir.path).toList(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
toSet()
? You're only using this for inclusion testing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will change
// runs 'pub get' there as part of handling the parent directory. | ||
return directory.basename == 'example' && | ||
packagePaths.contains(directory.parent.path); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was hoping we could just use getPlugins
instead of doing the filtering, but it looks like flutter/packages has some other nested constructions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I would prefer something more semantic here as well. The logic for how these are computed - getPlugins() and getPackages() - seems complicated, and I wasn't comfortable modifying it.
It looks like plugins
actually returns packages? And packages
returns packages plus their example directories?
I would have assumed that getPlugins()
would return the directory containing the n dart packages that make up a plugin - like url_launcher/
, url_launcher_platform_interface/
, url_launcher_macos/
, ...
I'll want a call like that - the top level plugin directory - for a follow up PR, where I'm going to try and speed up the analysis portion of the analyze call.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like plugins actually returns packages? And packages returns packages plus there example directories?
I suspect what happened is that this was written for flutter/plugins, then expanded for use in flutter/packages without renaming. Fixing the fact that "plugins" is used to refer to packages in general in the tool (including the --plugins
argument) is on my list.
plugin1Dir.path), | ||
])); | ||
}); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you also add a test of a package with a sub-package that's not example
, to make sure nobody makes the "simplification" that I was about to suggest before checking flutter/packages?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have one like that already - the analyzes all packages
test - but I can add one where the 2nd package is named 'example' but not contained by the 1st package.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some comments - code changes to follow separately.
@@ -64,6 +65,14 @@ class AnalyzeCommand extends PluginCommand { | |||
} | |||
|
|||
final List<Directory> packageDirectories = await getPackages().toList(); | |||
final List<String> packagePaths = | |||
packageDirectories.map((Directory dir) => dir.path).toList(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will change
// runs 'pub get' there as part of handling the parent directory. | ||
return directory.basename == 'example' && | ||
packagePaths.contains(directory.parent.path); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I would prefer something more semantic here as well. The logic for how these are computed - getPlugins() and getPackages() - seems complicated, and I wasn't comfortable modifying it.
It looks like plugins
actually returns packages? And packages
returns packages plus their example directories?
I would have assumed that getPlugins()
would return the directory containing the n dart packages that make up a plugin - like url_launcher/
, url_launcher_platform_interface/
, url_launcher_macos/
, ...
I'll want a call like that - the top level plugin directory - for a follow up PR, where I'm going to try and speed up the analysis portion of the analyze call.
plugin1Dir.path), | ||
])); | ||
}); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have one like that already - the analyzes all packages
test - but I can add one where the 2nd package is named 'example' but not contained by the 1st package.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
* master: (131 commits) [in_app_purchase] fix "autoConsume" param in "buyConsumable" (flutter#3957) [video_player_web] fix: set autoplay to false during initialization (flutter#3985) [multiple_web] Adapt web PlatformView widgets to work slotted. (flutter#3964) [url_launcher] Add iOS unit and UI tests (flutter#3987) [image_picker] Change storage location for camera captures to internal cache on Android, to comply with new Google Play storage requirements. (flutter#3956) [script/tool] Use 'dart pub' instead of deprecated 'pub' (flutter#3991) [video_player] Add iOS unit and UI tests (flutter#3986) Add pubspec convention checks (flutter#3984) Enable pubspec dependency sorting lint (flutter#3983) [image_picker] Migrate maven repo from jcenter to mavenCentral (flutter#3915) [video_player] Update README.md (flutter#3975) [script/tool] speed up the pub get portion of the analyze command (flutter#3982) Revert commit e742a7b (flutter#3976) Added support to request list of purchases (flutter#3944) [google_maps_flutter] Add iOS unit and UI tests (flutter#3978) Added Windows to the description (flutter#3936) use 'flutter pub get' for both dart and flutter packages (flutter#3973) [camera] android-rework part 3: Android exposure related features (flutter#3797) Remove exoplayer workaround from everything but video_player (flutter#3980) Allow reverts when checking versions (flutter#3981) ...
This PR speeds up the
analyze
command for the plugins tool. We were running pub get twice for all 42 example directories (flutter pub get automatically runs pub get for an example/ child directory when running pub get for the parent). The analyze command was spending 60% of it's time running flutter pub get; after this change the overall command should be about 25% faster.List which issues are fixed by this PR. You must list at least one issue.
If you had to change anything in the flutter/tests repo, include a link to the migration guide as per the breaking change policy.
Pre-launch Checklist
dart format
. See plugin_tool format)[shared_preferences]
///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.