Skip to content

Commit 68ff911

Browse files
authored
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>
1 parent 4543c38 commit 68ff911

File tree

9 files changed

+44
-19
lines changed

9 files changed

+44
-19
lines changed

.github/workflows/firehose.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,5 @@ jobs:
4141
if: ${{ matrix.sdk == 'stable' }}
4242

4343
- run: dart test
44+
env:
45+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/health.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,11 @@ on:
141141
default: "\"\""
142142
type: string
143143
required: false
144+
health_yaml_name:
145+
description: The name of the workflow file.
146+
default: '""'
147+
type: string
148+
required: false
144149

145150
jobs:
146151
changelog:
@@ -156,6 +161,7 @@ jobs:
156161
ignore_changelog: ${{ inputs.ignore_changelog }}
157162
ignore_packages: ${{ inputs.ignore_packages }}
158163
checkout_submodules: ${{ inputs.checkout_submodules }}
164+
health_yaml_name: ${{ inputs.health_yaml_name }}
159165

160166
license:
161167
if: ${{ contains(inputs.checks, 'license') }}
@@ -170,6 +176,7 @@ jobs:
170176
ignore_license: ${{ inputs.ignore_license }}
171177
ignore_packages: ${{ inputs.ignore_packages }}
172178
checkout_submodules: ${{ inputs.checkout_submodules }}
179+
health_yaml_name: ${{ inputs.health_yaml_name }}
173180

174181
coverage:
175182
if: ${{ contains(inputs.checks, 'coverage') }}
@@ -187,6 +194,7 @@ jobs:
187194
ignore_packages: ${{ inputs.ignore_packages }}
188195
checkout_submodules: ${{ inputs.checkout_submodules }}
189196
experiments: ${{ inputs.experiments }}
197+
health_yaml_name: ${{ inputs.health_yaml_name }}
190198

191199
breaking:
192200
if: ${{ contains(inputs.checks, 'breaking') }}
@@ -201,6 +209,7 @@ jobs:
201209
ignore_breaking: ${{ inputs.ignore_breaking }}
202210
ignore_packages: ${{ inputs.ignore_packages }}
203211
checkout_submodules: ${{ inputs.checkout_submodules }}
212+
health_yaml_name: ${{ inputs.health_yaml_name }}
204213

205214
do-not-submit:
206215
if: ${{ contains(inputs.checks, 'do-not-submit') }}
@@ -215,6 +224,7 @@ jobs:
215224
ignore_donotsubmit: ${{ inputs.ignore_donotsubmit }}
216225
ignore_packages: ${{ inputs.ignore_packages }}
217226
checkout_submodules: ${{ inputs.checkout_submodules }}
227+
health_yaml_name: ${{ inputs.health_yaml_name }}
218228

219229
leaking:
220230
if: ${{ contains(inputs.checks, 'leaking') }}
@@ -229,6 +239,7 @@ jobs:
229239
ignore_leaking: ${{ inputs.ignore_leaking }}
230240
ignore_packages: ${{ inputs.ignore_packages }}
231241
checkout_submodules: ${{ inputs.checkout_submodules }}
242+
health_yaml_name: ${{ inputs.health_yaml_name }}
232243

233244
comment:
234245
needs: [changelog, license, coverage, breaking, do-not-submit, leaking]

.github/workflows/health_base.yaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,11 @@ on:
102102
default: '""'
103103
type: string
104104
required: false
105+
health_yaml_name:
106+
description: The name of the workflow file.
107+
default: '""'
108+
type: string
109+
required: false
105110

106111
jobs:
107112
health:
@@ -189,7 +194,8 @@ jobs:
189194
--ignore_breaking ${{ inputs.ignore_breaking }} \
190195
--ignore_leaking ${{ inputs.ignore_leaking }} \
191196
--ignore_donotsubmit ${{ inputs.ignore_donotsubmit }} \
192-
--experiments ${{ inputs.experiments }}
197+
--experiments ${{ inputs.experiments }} \
198+
--health_yaml_name ${{ inputs.health_yaml_name }}
193199
194200
- 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
195201
if: ${{ '$action_state' == 1 }}

.github/workflows/health_internal.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,6 @@ jobs:
2020
warn_on: license,coverage,breaking,leaking
2121
ignore_license: 'pkgs/firehose/test_data'
2222
ignore_coverage: 'pkgs/firehose/bin,pkgs/firehose/test_data'
23+
health_yaml_name: 'health_internal.yaml'
2324
permissions:
2425
pull-requests: write

pkgs/firehose/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.12.0
2+
3+
- Make the location of the health.yaml workflow configurable.
4+
15
## 0.11.0
26

37
- Bump dart_apitool which can now report leak locations.

pkgs/firehose/bin/health.dart

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ void main(List<String> arguments) async {
4343
'flutter_packages',
4444
defaultsTo: [],
4545
help: 'The Flutter packages in this repo',
46+
)
47+
..addOption(
48+
'health_yaml_name',
49+
help: 'The name of the workflow file containing the health checks, '
50+
'to know to rerun all checks if that file is changed.',
4651
);
4752
for (var check in Check.values) {
4853
argParser.addMultiOption(
@@ -62,22 +67,17 @@ void main(List<String> arguments) async {
6267
.map((c) => MapEntry(c, _listNonEmpty(parsedArgs, 'ignore_${c.name}'))));
6368
final experiments = _listNonEmpty(parsedArgs, 'experiments');
6469
final coverageWeb = parsedArgs.flag('coverage_web');
70+
var healthYamlName = parsedArgs.option('health_yaml_name');
71+
final healthYamlNames =
72+
healthYamlName != null ? {healthYamlName} : {'health.yaml', 'health.yml'};
6573
if (warnOn.toSet().intersection(failOn.toSet()).isNotEmpty) {
6674
throw ArgumentError('The checks for which warnings are displayed and the '
6775
'checks which lead to failure must be disjoint.');
6876
}
69-
await Health(
70-
Directory.current,
71-
check,
72-
warnOn,
73-
failOn,
74-
coverageWeb,
75-
ignorePackages,
76-
ignoredFor,
77-
experiments,
78-
GithubApi(),
79-
flutterPackages,
80-
).healthCheck();
77+
await Health(Directory.current, check, warnOn, failOn, coverageWeb,
78+
ignorePackages, ignoredFor, experiments, GithubApi(), flutterPackages,
79+
healthYamlNames: healthYamlNames)
80+
.healthCheck();
8181
}
8282

8383
List<String> _listNonEmpty(ArgResults parsedArgs, String key) =>

pkgs/firehose/lib/src/health/health.dart

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ class Health {
5353
Directory? base,
5454
String? comment,
5555
this.log = printLogger,
56+
required this.healthYamlNames,
5657
}) : ignoredPackages = toGlobs(ignoredPackages),
5758
flutterPackageGlobs = toGlobs(flutterPackages),
5859
ignoredFor =
@@ -94,6 +95,7 @@ class Health {
9495
final Directory baseDirectory;
9596
final List<String> experiments;
9697
final Logger log;
98+
final Set<String> healthYamlNames;
9799

98100
late final String dartExecutable;
99101
late final String? flutterExecutable;
@@ -119,6 +121,7 @@ class Health {
119121
log(' ignoredFor: $ignoredFor');
120122
log(' baseDirectory: $baseDirectory');
121123
log(' experiments: $experiments');
124+
log(' healthYamlNames: $healthYamlNames');
122125
log('Checking for $checkName');
123126
if (!github.prLabels.contains('skip-$checkName-check')) {
124127
final firstResult = await checkFor(check)();
@@ -395,9 +398,7 @@ ${unchangedFilesPaths.isNotEmpty ? unchangedMarkdown : ''}
395398
bool healthYamlChanged(List<GitFile> files) => files
396399
.where((file) =>
397400
[FileStatus.added, FileStatus.modified].contains(file.status))
398-
.any((file) =>
399-
file.filename.endsWith('health.yaml') ||
400-
file.filename.endsWith('health.yml'));
401+
.any((file) => healthYamlNames.contains(path.basename(file.filename)));
401402

402403
Future<HealthCheckResult> changelogCheck() async {
403404
var filePaths = await packagesWithoutChangelog(

pkgs/firehose/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: firehose
22
description: A tool to automate publishing of Pub packages from GitHub actions.
3-
version: 0.11.0
3+
version: 0.12.0
44
repository: https://github.com/dart-lang/ecosystem/tree/main/pkgs/firehose
55

66
environment:

pkgs/firehose/test/health_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ Future<void> main() async {
7979
check,
8080
fakeGithubApi([
8181
GitFile(
82-
'.github/workflows/health.yaml',
82+
'.github/workflows/my_health.yaml',
8383
FileStatus.added,
8484
directory,
8585
),
@@ -170,7 +170,7 @@ class FakeHealth extends Health {
170170
super.base,
171171
super.comment,
172172
super.log,
173-
});
173+
}) : super(healthYamlNames: {'my_health.yaml'});
174174

175175
@override
176176
String getCurrentVersionOfPackage(Package package) =>

0 commit comments

Comments
 (0)