diff --git a/.github/workflows/health.yaml b/.github/workflows/health.yaml index 240a32dc..ace435e7 100644 --- a/.github/workflows/health.yaml +++ b/.github/workflows/health.yaml @@ -43,9 +43,7 @@ on: # stable release of the Dart SDK. sdk: description: >- - The channel, or a specific version from a channel, to install - ('2.19.0','stable', 'beta', 'dev'). Using one of the three channels - will give you the latest version published to that channel. + The Dart SDK version, either a semver or one of `dev`, `stable` etc. default: "stable" required: false type: string diff --git a/.github/workflows/health_base.yaml b/.github/workflows/health_base.yaml index ce80de9a..d3eaef42 100644 --- a/.github/workflows/health_base.yaml +++ b/.github/workflows/health_base.yaml @@ -54,7 +54,7 @@ on: required: false flutter_packages: description: List of packages depending on Flutter. - default: '' + default: "\"\"" required: false type: string ignore_license: diff --git a/pkgs/firehose/lib/src/health/coverage.dart b/pkgs/firehose/lib/src/health/coverage.dart index 5f6681e1..cb08daba 100644 --- a/pkgs/firehose/lib/src/health/coverage.dart +++ b/pkgs/firehose/lib/src/health/coverage.dart @@ -29,11 +29,6 @@ class Coverage { this.experiments, ); - Future compareCoverages( - List files, Directory base) async { - return compareCoveragesFor(files, base); - } - CoverageResult compareCoveragesFor(List files, Directory base) { var repository = Repository(directory); var packages = repository.locatePackages(ignore: ignoredPackages); diff --git a/pkgs/firehose/lib/src/health/health.dart b/pkgs/firehose/lib/src/health/health.dart index 35a38cab..14440c0e 100644 --- a/pkgs/firehose/lib/src/health/health.dart +++ b/pkgs/firehose/lib/src/health/health.dart @@ -52,22 +52,10 @@ class Health { Directory? base, String? comment, this.log = printLogger, - }) : ignoredPackages = ignoredPackages - .map((e) { - print('IGNORED:PACKAGE $e'); - return e; - }) - .map((pattern) => Glob(pattern, recursive: true)) - .toList(), - flutterPackages = flutterPackages - .map((pattern) => Glob(pattern, recursive: true)) - .toList(), - ignoredFilesForCoverage = ignoredCoverage - .map((pattern) => Glob(pattern, recursive: true)) - .toList(), - ignoredFilesForLicense = ignoredLicense - .map((pattern) => Glob(pattern, recursive: true)) - .toList(), + }) : ignoredPackages = toGlobs(ignoredPackages), + flutterPackages = toGlobs(flutterPackages), + ignoredFilesForCoverage = toGlobs(ignoredCoverage), + ignoredFilesForLicense = toGlobs(ignoredLicense), baseDirectory = base ?? Directory('../base_repo'), commentPath = comment ?? path.join( @@ -75,6 +63,10 @@ class Health { 'output', 'comment.md', ); + + static List toGlobs(List ignoredPackages) => + ignoredPackages.map((pattern) => Glob(pattern, recursive: true)).toList(); + final GithubApi github; final Check check; @@ -214,10 +206,6 @@ ${changeForPackage.entries.map((e) => '|${e.key.name}|${e.value.toMarkdownRow()} Future leakingCheck() async { var filesInPR = await listFilesInPRorAll(ignoredPackages); - // DO-NOT-SUBMIT - print('Files: ${filesInPR.map((e) => e.filename).join(', ')}'); - print( - 'Files: ${filesInPR.map((e) => e.filename).where((element) => element.contains('swiftgen')).join(', ')}'); final leaksForPackage = >{}; for (var package in packagesContaining(filesInPR)) { log('Look for leaks in $package'); @@ -318,14 +306,12 @@ ${unchangedFilesPaths.isNotEmpty ? unchangedMarkdown : ''} ); } - bool healthYamlChanged(List files) { - return files - .where((file) => - [FileStatus.added, FileStatus.modified].contains(file.status)) - .any((file) => - file.filename.endsWith('health.yaml') || - file.filename.endsWith('health.yml')); - } + bool healthYamlChanged(List files) => files + .where((file) => + [FileStatus.added, FileStatus.modified].contains(file.status)) + .any((file) => + file.filename.endsWith('health.yaml') || + file.filename.endsWith('health.yml')); Future changelogCheck() async { var filePaths = await packagesWithoutChangelog( @@ -388,10 +374,7 @@ ${filesWithDNS.map((e) => e.filename).map((e) => '|$e|').join('\n')} Future> listFilesInPRorAll(List ignore) async { final files = await github.listFilesForPR(directory, ignore); - if (healthYamlChanged(files)) { - return await _getAllFiles(ignore); - } - return files; + return healthYamlChanged(files) ? await _getAllFiles(ignore) : files; } Future> _getAllFiles(List ignored) async => @@ -413,7 +396,7 @@ ${filesWithDNS.map((e) => e.filename).map((e) => '|$e|').join('\n')} ); var files = await listFilesInPRorAll(ignoredPackages); - var coverageResult = await coverage.compareCoverages(files, directory); + var coverageResult = coverage.compareCoveragesFor(files, directory); var markdownResult = ''' | File | Coverage | diff --git a/pkgs/firehose/test/health_test.dart b/pkgs/firehose/test/health_test.dart index a30e65d3..0c830cd5 100644 --- a/pkgs/firehose/test/health_test.dart +++ b/pkgs/firehose/test/health_test.dart @@ -62,8 +62,10 @@ Future main() async { ), timeout: const Timeout(Duration(minutes: 2)), ); + test( - 'Check health workflow "${check.name}" against golden files', + 'Check health workflow "${check.name}" against golden files ' + 'with health.yaml changed itself', () async => await checkGolden( check, fakeGithubApi([