[flutter_plugin_tools] Add a summary for successful runs (#4118)

Add a summary to the end of successful runs for everything using the new looping base command, similar to what we do for summarizing failures. This will make it easy to manually check results for PRs that we know should be changing the set of run packages (adding a new package, adding a new test type to a package, adding a new test type to the tool), as well as spot-checking when we see unexpected results (e.g., looking back and why a PR didn't fail CI when we discover that it should have).

To support better surfacing skips, this restructures the return value of `runForPackage` to have "skip" as one of the options. As a result of it being a return value, packages that used `printSkip` to indicate that *parts* of the command were being skipped have been changed to no longer do that.

Fixes https://github.com/flutter/flutter/issues/85626
This commit is contained in:
stuartmorgan
2021-07-01 16:25:21 -07:00
committed by GitHub
parent 92d6214984
commit edeb10a752
19 changed files with 817 additions and 274 deletions

View File

@ -111,18 +111,15 @@ class VersionCheckCommand extends PackageLoopingCommand {
Future<void> initializeRun() async {}
@override
Future<List<String>> runForPackage(Directory package) async {
final List<String> errors = <String>[];
Future<PackageResult> runForPackage(Directory package) async {
final Pubspec? pubspec = _tryParsePubspec(package);
if (pubspec == null) {
errors.add('Invalid pubspec.yaml.');
return errors; // No remaining checks make sense.
// No remaining checks make sense, so fail immediately.
return PackageResult.fail(<String>['Invalid pubspec.yaml.']);
}
if (pubspec.publishTo == 'none') {
printSkip('${indentation}Found "publish_to: none".');
return PackageLoopingCommand.success;
return PackageResult.skip('Found "publish_to: none".');
}
final Version? currentPubspecVersion = pubspec.version;
@ -130,10 +127,12 @@ class VersionCheckCommand extends PackageLoopingCommand {
printError('${indentation}No version found in pubspec.yaml. A package '
'that intentionally has no version should be marked '
'"publish_to: none".');
errors.add('No pubspec.yaml version.');
return errors; // No remaining checks make sense.
// No remaining checks make sense, so fail immediately.
PackageResult.fail(<String>['No pubspec.yaml version.']);
}
final List<String> errors = <String>[];
if (!await _hasValidVersionChange(package, pubspec: pubspec)) {
errors.add('Disallowed version change.');
}
@ -142,7 +141,9 @@ class VersionCheckCommand extends PackageLoopingCommand {
errors.add('pubspec.yaml and CHANGELOG.md have different versions');
}
return errors;
return errors.isEmpty
? PackageResult.success()
: PackageResult.fail(errors);
}
@override
@ -210,7 +211,7 @@ ${indentation}HTTP response: ${pubVersionFinderResponse.httpResponse.body}
if (previousVersion == Version.none) {
print('${indentation}Unable to find previous version '
'${getBoolArg(_againstPubFlag) ? 'on pub server' : 'at git base'}.');
printWarning(
logWarning(
'${indentation}If this plugin is not new, something has gone wrong.');
return true;
}