[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

@ -100,19 +100,20 @@ class FirebaseTestLabCommand extends PackageLoopingCommand {
'project',
getStringArg('project'),
]);
print('');
if (exitCode == 0) {
print('\nFirebase project configured.');
print('Firebase project configured.');
return;
} else {
print(
'\nWarning: gcloud config set returned a non-zero exit code. Continuing anyway.');
logWarning(
'Warning: gcloud config set returned a non-zero exit code. Continuing anyway.');
}
}
_firebaseProjectConfigured!.complete(null);
}
@override
Future<List<String>> runForPackage(Directory package) async {
Future<PackageResult> runForPackage(Directory package) async {
if (!package
.childDirectory('example')
.childDirectory('android')
@ -120,29 +121,26 @@ class FirebaseTestLabCommand extends PackageLoopingCommand {
.childDirectory('src')
.childDirectory('androidTest')
.existsSync()) {
printSkip('No example with androidTest directory');
return PackageLoopingCommand.success;
return PackageResult.skip('No example with androidTest directory');
}
final List<String> errors = <String>[];
final Directory exampleDirectory = package.childDirectory('example');
final Directory androidDirectory =
exampleDirectory.childDirectory('android');
// Ensures that gradle wrapper exists
if (!await _ensureGradleWrapperExists(androidDirectory)) {
errors.add('Unable to build example apk');
return errors;
PackageResult.fail(<String>['Unable to build example apk']);
}
await _configureFirebaseProject();
if (!await _runGradle(androidDirectory, 'app:assembleAndroidTest')) {
errors.add('Unable to assemble androidTest');
return errors;
PackageResult.fail(<String>['Unable to assemble androidTest']);
}
final List<String> errors = <String>[];
// Used within the loop to ensure a unique GCS output location for each
// test file's run.
int resultsCounter = 0;
@ -186,7 +184,9 @@ class FirebaseTestLabCommand extends PackageLoopingCommand {
errors.add('$testName failed tests');
}
}
return errors;
return errors.isEmpty
? PackageResult.success()
: PackageResult.fail(errors);
}
/// Checks that 'gradlew' exists in [androidDirectory], and if not runs a