From 4eb8943bb46f87de75c6f49b84984aead93d842b Mon Sep 17 00:00:00 2001 From: Moritz Date: Wed, 6 Aug 2025 14:40:54 +0200 Subject: [PATCH 1/6] Make health file name configurab;e --- .github/workflows/health.yaml | 11 +++++++++++ .github/workflows/health_base.yaml | 6 ++++++ .github/workflows/health_internal.yaml | 1 + pkgs/firehose/CHANGELOG.md | 4 ++++ pkgs/firehose/bin/health.dart | 24 ++++++++++++------------ pkgs/firehose/lib/src/health/health.dart | 6 +++--- pkgs/firehose/test/health_test.dart | 2 +- 7 files changed, 38 insertions(+), 16 deletions(-) diff --git a/.github/workflows/health.yaml b/.github/workflows/health.yaml index 967fa916..359175e9 100644 --- a/.github/workflows/health.yaml +++ b/.github/workflows/health.yaml @@ -141,6 +141,11 @@ on: default: "\"\"" type: string required: false + health_yaml_name: + description: The name of the workflow file. + default: '""' + type: string + required: false jobs: changelog: @@ -156,6 +161,7 @@ jobs: ignore_changelog: ${{ inputs.ignore_changelog }} ignore_packages: ${{ inputs.ignore_packages }} checkout_submodules: ${{ inputs.checkout_submodules }} + health_yaml_name: ${{ inputs.health_yaml_name }} license: if: ${{ contains(inputs.checks, 'license') }} @@ -170,6 +176,7 @@ jobs: ignore_license: ${{ inputs.ignore_license }} ignore_packages: ${{ inputs.ignore_packages }} checkout_submodules: ${{ inputs.checkout_submodules }} + health_yaml_name: ${{ inputs.health_yaml_name }} coverage: if: ${{ contains(inputs.checks, 'coverage') }} @@ -187,6 +194,7 @@ jobs: ignore_packages: ${{ inputs.ignore_packages }} checkout_submodules: ${{ inputs.checkout_submodules }} experiments: ${{ inputs.experiments }} + health_yaml_name: ${{ inputs.health_yaml_name }} breaking: if: ${{ contains(inputs.checks, 'breaking') }} @@ -201,6 +209,7 @@ jobs: ignore_breaking: ${{ inputs.ignore_breaking }} ignore_packages: ${{ inputs.ignore_packages }} checkout_submodules: ${{ inputs.checkout_submodules }} + health_yaml_name: ${{ inputs.health_yaml_name }} do-not-submit: if: ${{ contains(inputs.checks, 'do-not-submit') }} @@ -215,6 +224,7 @@ jobs: ignore_donotsubmit: ${{ inputs.ignore_donotsubmit }} ignore_packages: ${{ inputs.ignore_packages }} checkout_submodules: ${{ inputs.checkout_submodules }} + health_yaml_name: ${{ inputs.health_yaml_name }} leaking: if: ${{ contains(inputs.checks, 'leaking') }} @@ -229,6 +239,7 @@ jobs: ignore_leaking: ${{ inputs.ignore_leaking }} ignore_packages: ${{ inputs.ignore_packages }} checkout_submodules: ${{ inputs.checkout_submodules }} + health_yaml_name: ${{ inputs.health_yaml_name }} comment: needs: [changelog, license, coverage, breaking, do-not-submit, leaking] diff --git a/.github/workflows/health_base.yaml b/.github/workflows/health_base.yaml index 0b72b9e7..26aea3cc 100644 --- a/.github/workflows/health_base.yaml +++ b/.github/workflows/health_base.yaml @@ -102,6 +102,11 @@ on: default: '""' type: string required: false + health_yaml_name: + description: The name of the workflow file. + default: '""' + type: string + required: false jobs: health: @@ -190,6 +195,7 @@ jobs: --ignore_leaking ${{ inputs.ignore_leaking }} \ --ignore_donotsubmit ${{ inputs.ignore_donotsubmit }} \ --experiments ${{ inputs.experiments }} + --health_yaml_name ${{ inputs.health_yaml_name }} - run: test -f current_repo/output/comment.md || echo $'The ${{ inputs.check }} workflow has encountered an exception and did not complete.' >> current_repo/output/comment.md if: ${{ '$action_state' == 1 }} diff --git a/.github/workflows/health_internal.yaml b/.github/workflows/health_internal.yaml index 2a8d4ed9..1b7d7b8e 100644 --- a/.github/workflows/health_internal.yaml +++ b/.github/workflows/health_internal.yaml @@ -20,5 +20,6 @@ jobs: warn_on: license,coverage,breaking,leaking ignore_license: 'pkgs/firehose/test_data' ignore_coverage: 'pkgs/firehose/bin,pkgs/firehose/test_data' + health_yaml_name: 'health_internal.yaml' permissions: pull-requests: write diff --git a/pkgs/firehose/CHANGELOG.md b/pkgs/firehose/CHANGELOG.md index b5ee5080..151e54a1 100644 --- a/pkgs/firehose/CHANGELOG.md +++ b/pkgs/firehose/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.12.0 + +- Make the location of the health.yaml workflow configurable. + ## 0.11.0 - Bump dart_apitool which can now report leak locations. diff --git a/pkgs/firehose/bin/health.dart b/pkgs/firehose/bin/health.dart index bb8799a2..f43525bb 100644 --- a/pkgs/firehose/bin/health.dart +++ b/pkgs/firehose/bin/health.dart @@ -43,6 +43,11 @@ void main(List arguments) async { 'flutter_packages', defaultsTo: [], help: 'The Flutter packages in this repo', + ) + ..addOption( + 'health_yaml_name', + help: 'The name of the workflow file containing the health checks, ' + 'to know to rerun all checks if that file is changed.', ); for (var check in Check.values) { argParser.addMultiOption( @@ -62,22 +67,17 @@ void main(List arguments) async { .map((c) => MapEntry(c, _listNonEmpty(parsedArgs, 'ignore_${c.name}')))); final experiments = _listNonEmpty(parsedArgs, 'experiments'); final coverageWeb = parsedArgs.flag('coverage_web'); + var healthYamlName = parsedArgs.option('health_yaml_name'); + final healthYamlNames = + healthYamlName != null ? {healthYamlName} : {'health.yaml', 'health.yml'}; if (warnOn.toSet().intersection(failOn.toSet()).isNotEmpty) { throw ArgumentError('The checks for which warnings are displayed and the ' 'checks which lead to failure must be disjoint.'); } - await Health( - Directory.current, - check, - warnOn, - failOn, - coverageWeb, - ignorePackages, - ignoredFor, - experiments, - GithubApi(), - flutterPackages, - ).healthCheck(); + await Health(Directory.current, check, warnOn, failOn, coverageWeb, + ignorePackages, ignoredFor, experiments, GithubApi(), flutterPackages, + healthYamlNames: healthYamlNames) + .healthCheck(); } List _listNonEmpty(ArgResults parsedArgs, String key) => diff --git a/pkgs/firehose/lib/src/health/health.dart b/pkgs/firehose/lib/src/health/health.dart index c1d28674..4dac61be 100644 --- a/pkgs/firehose/lib/src/health/health.dart +++ b/pkgs/firehose/lib/src/health/health.dart @@ -53,6 +53,7 @@ class Health { Directory? base, String? comment, this.log = printLogger, + required this.healthYamlNames, }) : ignoredPackages = toGlobs(ignoredPackages), flutterPackageGlobs = toGlobs(flutterPackages), ignoredFor = @@ -94,6 +95,7 @@ class Health { final Directory baseDirectory; final List experiments; final Logger log; + final Set healthYamlNames; late final String dartExecutable; late final String? flutterExecutable; @@ -395,9 +397,7 @@ ${unchangedFilesPaths.isNotEmpty ? unchangedMarkdown : ''} 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')); + .any((file) => healthYamlNames.contains(path.basename(file.filename))); Future changelogCheck() async { var filePaths = await packagesWithoutChangelog( diff --git a/pkgs/firehose/test/health_test.dart b/pkgs/firehose/test/health_test.dart index d030a971..853b36bb 100644 --- a/pkgs/firehose/test/health_test.dart +++ b/pkgs/firehose/test/health_test.dart @@ -170,7 +170,7 @@ class FakeHealth extends Health { super.base, super.comment, super.log, - }); + }) : super(healthYamlNames: {}); @override String getCurrentVersionOfPackage(Package package) => From a9dbfad7e3f257051c619adcec54c2f0b40a6361 Mon Sep 17 00:00:00 2001 From: Moritz Date: Wed, 6 Aug 2025 14:45:11 +0200 Subject: [PATCH 2/6] rev pubspec --- pkgs/firehose/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/firehose/pubspec.yaml b/pkgs/firehose/pubspec.yaml index c56ac761..dbe943c8 100644 --- a/pkgs/firehose/pubspec.yaml +++ b/pkgs/firehose/pubspec.yaml @@ -1,6 +1,6 @@ name: firehose description: A tool to automate publishing of Pub packages from GitHub actions. -version: 0.11.0 +version: 0.12.0 repository: https://github.com/dart-lang/ecosystem/tree/main/pkgs/firehose environment: From d160592fa667de3eeb97c8430fc45d5a31db1465 Mon Sep 17 00:00:00 2001 From: Moritz Date: Wed, 6 Aug 2025 16:08:48 +0200 Subject: [PATCH 3/6] add log --- pkgs/firehose/lib/src/health/health.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/pkgs/firehose/lib/src/health/health.dart b/pkgs/firehose/lib/src/health/health.dart index 4dac61be..7506ae37 100644 --- a/pkgs/firehose/lib/src/health/health.dart +++ b/pkgs/firehose/lib/src/health/health.dart @@ -121,6 +121,7 @@ class Health { log(' ignoredFor: $ignoredFor'); log(' baseDirectory: $baseDirectory'); log(' experiments: $experiments'); + log(' healthYamlNames: $healthYamlNames'); log('Checking for $checkName'); if (!github.prLabels.contains('skip-$checkName-check')) { final firstResult = await checkFor(check)(); From 5cd59900f26ebff9d637bdd01f25e06ae28e83c0 Mon Sep 17 00:00:00 2001 From: Moritz Date: Wed, 6 Aug 2025 16:11:24 +0200 Subject: [PATCH 4/6] add line sep --- .github/workflows/health_base.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/health_base.yaml b/.github/workflows/health_base.yaml index 26aea3cc..f3498ef1 100644 --- a/.github/workflows/health_base.yaml +++ b/.github/workflows/health_base.yaml @@ -194,7 +194,7 @@ jobs: --ignore_breaking ${{ inputs.ignore_breaking }} \ --ignore_leaking ${{ inputs.ignore_leaking }} \ --ignore_donotsubmit ${{ inputs.ignore_donotsubmit }} \ - --experiments ${{ inputs.experiments }} + --experiments ${{ inputs.experiments }} \ --health_yaml_name ${{ inputs.health_yaml_name }} - run: test -f current_repo/output/comment.md || echo $'The ${{ inputs.check }} workflow has encountered an exception and did not complete.' >> current_repo/output/comment.md From 366c187074c5113b54e45c34395597edb857c6a9 Mon Sep 17 00:00:00 2001 From: Moritz Date: Wed, 6 Aug 2025 16:28:20 +0200 Subject: [PATCH 5/6] Fix test --- pkgs/firehose/test/health_test.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/firehose/test/health_test.dart b/pkgs/firehose/test/health_test.dart index 853b36bb..7c6b7207 100644 --- a/pkgs/firehose/test/health_test.dart +++ b/pkgs/firehose/test/health_test.dart @@ -79,7 +79,7 @@ Future main() async { check, fakeGithubApi([ GitFile( - '.github/workflows/health.yaml', + '.github/workflows/my_health.yaml', FileStatus.added, directory, ), @@ -170,7 +170,7 @@ class FakeHealth extends Health { super.base, super.comment, super.log, - }) : super(healthYamlNames: {}); + }) : super(healthYamlNames: {'my_health.yaml'}); @override String getCurrentVersionOfPackage(Package package) => From 56b757c8a333b3995f94e1579c486dceaedc0d1d Mon Sep 17 00:00:00 2001 From: Moritz Date: Wed, 6 Aug 2025 16:35:46 +0200 Subject: [PATCH 6/6] add token --- .github/workflows/firehose.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/firehose.yml b/.github/workflows/firehose.yml index 49c02f16..d8878393 100644 --- a/.github/workflows/firehose.yml +++ b/.github/workflows/firehose.yml @@ -41,3 +41,5 @@ jobs: if: ${{ matrix.sdk == 'stable' }} - run: dart test + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}