Make health file name configurable (#364)
We run all the checks on all files every time the health workflow file is changed - so far that name was hardcoded. This enables it for other names, such as `health_internal.yaml` for this repo. The checks in this PR show that it works :)
---
<details>
<summary>Contribution guidelines:</summary><br>
- See our [contributor guide](https://github.com/dart-lang/.github/blob/main/CONTRIBUTING.md) for general expectations for PRs.
- Larger or significant changes should be discussed in an issue before creating a PR.
- Contributions to our repos should follow the [Dart style guide](https://dart.dev/guides/language/effective-dart) and use `dart format`.
- Most changes should add an entry to the changelog and may need to [rev the pubspec package version](https://github.com/dart-lang/sdk/blob/main/docs/External-Package-Maintenance.md#making-a-change).
- Changes to packages require [corresponding tests](https://github.com/dart-lang/.github/blob/main/CONTRIBUTING.md#Testing).
Note that many Dart repos have a weekly cadence for reviewing PRs - please allow for some latency before initial review feedback.
</details>
diff --git a/.github/workflows/firehose.yml b/.github/workflows/firehose.yml
index 49c02f1..d887839 100644
--- a/.github/workflows/firehose.yml
+++ b/.github/workflows/firehose.yml
@@ -41,3 +41,5 @@
if: ${{ matrix.sdk == 'stable' }}
- run: dart test
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
diff --git a/.github/workflows/health.yaml b/.github/workflows/health.yaml
index 967fa91..359175e 100644
--- a/.github/workflows/health.yaml
+++ b/.github/workflows/health.yaml
@@ -141,6 +141,11 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 0b72b9e..f3498ef 100644
--- a/.github/workflows/health_base.yaml
+++ b/.github/workflows/health_base.yaml
@@ -102,6 +102,11 @@
default: '""'
type: string
required: false
+ health_yaml_name:
+ description: The name of the workflow file.
+ default: '""'
+ type: string
+ required: false
jobs:
health:
@@ -189,7 +194,8 @@
--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
if: ${{ '$action_state' == 1 }}
diff --git a/.github/workflows/health_internal.yaml b/.github/workflows/health_internal.yaml
index 2a8d4ed..1b7d7b8 100644
--- a/.github/workflows/health_internal.yaml
+++ b/.github/workflows/health_internal.yaml
@@ -20,5 +20,6 @@
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 b5ee508..151e54a 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 bb8799a..f43525b 100644
--- a/pkgs/firehose/bin/health.dart
+++ b/pkgs/firehose/bin/health.dart
@@ -43,6 +43,11 @@
'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 @@
.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<String> _listNonEmpty(ArgResults parsedArgs, String key) =>
diff --git a/pkgs/firehose/lib/src/health/health.dart b/pkgs/firehose/lib/src/health/health.dart
index c1d2867..7506ae3 100644
--- a/pkgs/firehose/lib/src/health/health.dart
+++ b/pkgs/firehose/lib/src/health/health.dart
@@ -53,6 +53,7 @@
Directory? base,
String? comment,
this.log = printLogger,
+ required this.healthYamlNames,
}) : ignoredPackages = toGlobs(ignoredPackages),
flutterPackageGlobs = toGlobs(flutterPackages),
ignoredFor =
@@ -94,6 +95,7 @@
final Directory baseDirectory;
final List<String> experiments;
final Logger log;
+ final Set<String> healthYamlNames;
late final String dartExecutable;
late final String? flutterExecutable;
@@ -119,6 +121,7 @@
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)();
@@ -395,9 +398,7 @@
bool healthYamlChanged(List<GitFile> 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<HealthCheckResult> changelogCheck() async {
var filePaths = await packagesWithoutChangelog(
diff --git a/pkgs/firehose/pubspec.yaml b/pkgs/firehose/pubspec.yaml
index c56ac76..dbe943c 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:
diff --git a/pkgs/firehose/test/health_test.dart b/pkgs/firehose/test/health_test.dart
index d030a97..7c6b720 100644
--- a/pkgs/firehose/test/health_test.dart
+++ b/pkgs/firehose/test/health_test.dart
@@ -79,7 +79,7 @@
check,
fakeGithubApi([
GitFile(
- '.github/workflows/health.yaml',
+ '.github/workflows/my_health.yaml',
FileStatus.added,
directory,
),
@@ -170,7 +170,7 @@
super.base,
super.comment,
super.log,
- });
+ }) : super(healthYamlNames: {'my_health.yaml'});
@override
String getCurrentVersionOfPackage(Package package) =>