Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

[flutter_plugin_tools] Track and log exclusions #4205

Merged
merged 3 commits into from
Aug 3, 2021

Conversation

stuartmorgan
Copy link
Contributor

Makes commands that use the package-looping base command track and
report exclusions. This will make it much easier to debug/audit
situations where tests aren't running when expected (e.g., when enabling
a new type of test for a package that previously had to be explicitly
excluded from that test to avoid failing for having no tests, but
forgetting to remove the package from the exclusion list).

Also fixes a latent issue with using different exclusion lists on
different commands in a single CI task when using sharding could cause
unexpected failures due to different sets of plugins being included for
each step (e.g., build+drive with an exclude list on drive could
potentially try to drive a plugin that hadn't been built in that shard)
by sharding before filtering out excluded packages.

Adds testing for sharding in general, as there was previously none.

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 relevant style guides and ran the auto-formatter. (Note that unlike the flutter/flutter repo, the flutter/plugins repo does use dart format.)
  • I signed the CLA.
  • The title of the PR starts with the name of the plugin surrounded by square brackets, e.g. [shared_preferences]
  • I listed at least one issue that this PR fixes in the description above.
  • I updated pubspec.yaml with an appropriate new version according to the pub versioning philosophy.
  • I updated CHANGELOG.md to add a description of the change.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making or feature I am adding, or Hixie said the PR is test exempt.
  • All existing and new tests are passing.

Makes commands that use the package-looping base command track and
report exclusions. This will make it much easier to debug/audit
situations where tests aren't running when expected (e.g., when enabling
a new type of test for a package that previously had to be explicitly
excluded from that test to avoid failing for having no tests, but
forgetting to remove the package from the exclusion list).

Also fixes a latent issue with using different exclusion lists on
different commands in a single CI task when using sharding could cause
unexpected failures due to different sets of plugins being included for
each step (e.g., build+drive with an exclude list on drive could
potentially try to drive a plugin that hadn't been built in that shard)
by sharding before filtering out excluded packages.

Adds testing for sharding in general, as there was previously none.
@stuartmorgan stuartmorgan requested a review from gaaclarke July 30, 2021 00:17
@google-cla google-cla bot added the cla: yes label Jul 30, 2021
@stuartmorgan
Copy link
Contributor Author

@gaaclarke Ping?

Copy link
Member

@gaaclarke gaaclarke left a comment

Choose a reason for hiding this comment

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

LGTM, there are a handful of nits, probably the biggest feedback is it looks like we are working around the lack of a concept of the Package where the word "package" can mean either a string name, a Directory, or a PackageEnumerationEntry depending on the situation.

@@ -15,6 +15,19 @@ import 'core.dart';
import 'git_version_finder.dart';
import 'process_runner.dart';

/// An entry in pacakge enumeration for APIs that need to include extra
Copy link
Member

Choose a reason for hiding this comment

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

s/pacakge/package

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

@@ -15,6 +15,19 @@ import 'core.dart';
import 'git_version_finder.dart';
import 'process_runner.dart';

/// An entry in pacakge enumeration for APIs that need to include extra
/// data about the entry.
class PackageEnumerationEntry {
Copy link
Member

Choose a reason for hiding this comment

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

It's a bit odd that this abstraction name includes the context that it is used. Couldn't this just be a Package?

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 is public throughout the entire codebase, which would make calling it just "Package" confusing; most references to packages in the tool are not enumerations, just individual entries.

The reason the context is part of the name is that the extra data is specific to enumeration—it's what it is excluded from. It's indicating that even though the package is in the enumeration, it shouldn't really be handled as part of it. (Originally I wanted to separate excluded packages out, since having them in the list is inherently somewhat confusing, but that doesn't allow for solving the sharding problem—their place in the list must be preserved.)

/// 3./4. Either of the above, but in a third_party/packages/ directory that
/// is a sibling of the packages directory. This is used for a small number
/// of packages in the flutter/packages repository.
Stream<Directory> _getAllPlugins() async* {
Stream<PackageEnumerationEntry> _getAllPackages() async* {
Copy link
Member

Choose a reason for hiding this comment

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

Here we are calling PackageEnumerationEntrys "packages" fwiw.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I felt like the type being PackageEnumerationEntry in the context of a method whose sole purpose is to enumerate packages was straightforward enough that the ambiguity wouldn't be an issue (especially given that we are following Flutter style, so use explicit types everywhere).

// getPackages, as the current naming is very confusing.
Stream<Directory> getPlugins() async* {
/// Returns the set of plugins to exclude based on the `--exclude` argument.
Set<String> _getExcludedPackages() {
Copy link
Member

Choose a reason for hiding this comment

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

getExcludedPackagePaths? getExcludedPackageNames?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, changed to getExcludedPackageNames. ("name" is actually itself a bit of a weird concept currently in the tool code currently, due to the retro-fitting of federated packages that happened at some point; I would like to someday go back and clean that up. But it's definitely better than just "package".)

@@ -185,6 +185,23 @@ void main() {
package.childDirectory('example').path,
]));
});

test('excludes subpackages when main package is excluded', () async {
createFakePlugin('a_plugin', packagesDir,
Copy link
Member

Choose a reason for hiding this comment

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

IMO this would be slightly more clear if you retained a reference to a_plugin and asserted that it didn't show up in the output. Not capturing the output to createFakePlugin makes it a bit less clear where the side effects are.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@stuartmorgan stuartmorgan merged commit 498df33 into flutter:master Aug 3, 2021
@stuartmorgan stuartmorgan deleted the exclude-restructure branch August 3, 2021 23:24
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Aug 3, 2021
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Aug 4, 2021
fotiDim pushed a commit to fotiDim/plugins that referenced this pull request Sep 13, 2021
Makes commands that use the package-looping base command track and
report exclusions. This will make it much easier to debug/audit
situations where tests aren't running when expected (e.g., when enabling
a new type of test for a package that previously had to be explicitly
excluded from that test to avoid failing for having no tests, but
forgetting to remove the package from the exclusion list).

Also fixes a latent issue with using different exclusion lists on
different commands in a single CI task when using sharding could cause
unexpected failures due to different sets of plugins being included for
each step (e.g., build+drive with an exclude list on drive could
potentially try to drive a plugin that hadn't been built in that shard)
by sharding before filtering out excluded packages.

Adds testing for sharding in general, as there was previously none.
amantoux pushed a commit to amantoux/plugins that referenced this pull request Sep 27, 2021
Makes commands that use the package-looping base command track and
report exclusions. This will make it much easier to debug/audit
situations where tests aren't running when expected (e.g., when enabling
a new type of test for a package that previously had to be explicitly
excluded from that test to avoid failing for having no tests, but
forgetting to remove the package from the exclusion list).

Also fixes a latent issue with using different exclusion lists on
different commands in a single CI task when using sharding could cause
unexpected failures due to different sets of plugins being included for
each step (e.g., build+drive with an exclude list on drive could
potentially try to drive a plugin that hadn't been built in that shard)
by sharding before filtering out excluded packages.

Adds testing for sharding in general, as there was previously none.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants