Skip to content

Commit c995170

Browse files
authored
Add more fine grained ignore capabilities to health workflow (#329)
Add generalized ignore-per-checks. --- - [x] I’ve reviewed the contributor guide and applied the relevant portions to this PR. <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 5ca7c41 commit c995170

File tree

11 files changed

+130
-93
lines changed

11 files changed

+130
-93
lines changed

.github/workflows/health.yaml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,11 @@ name: Health
2828
# upload_coverage: false
2929
# flutter_packages: "pkgs/my_flutter_package"
3030
# ignore_license: "**.g.dart"
31+
# ignore_changelog: ""
3132
# ignore_coverage: "**.mock.dart,**.g.dart"
33+
# ignore_breaking: ""
34+
# ignore_leaking: ""
35+
# ignore_donotsubmit: ""
3236
# ignore_packages: "pkgs/helper_package"
3337
# checkout_submodules: false
3438
# experiments: "native-assets"
@@ -97,11 +101,31 @@ on:
97101
default: "\"\""
98102
required: false
99103
type: string
104+
ignore_changelog:
105+
description: Which files to ignore for the license check.
106+
default: "\"\""
107+
required: false
108+
type: string
100109
ignore_coverage:
101110
description: Which files to ignore for the coverage check.
102111
default: "\"\""
103112
required: false
104113
type: string
114+
ignore_breaking:
115+
description: Which files to ignore for the license check.
116+
default: "\"\""
117+
required: false
118+
type: string
119+
ignore_leaking:
120+
description: Which files to ignore for the license check.
121+
default: "\"\""
122+
required: false
123+
type: string
124+
ignore_donotsubmit:
125+
description: Which files to ignore for the license check.
126+
default: "\"\""
127+
required: false
128+
type: string
105129
ignore_packages:
106130
description: Which packages to ignore.
107131
default: "\"\""
@@ -129,6 +153,7 @@ jobs:
129153
warn_on: ${{ inputs.warn_on }}
130154
local_debug: ${{ inputs.local_debug }}
131155
flutter_packages: ${{ inputs.flutter_packages }}
156+
ignore_changelog: ${{ inputs.ignore_changelog }}
132157
ignore_packages: ${{ inputs.ignore_packages }}
133158
checkout_submodules: ${{ inputs.checkout_submodules }}
134159

@@ -173,6 +198,7 @@ jobs:
173198
warn_on: ${{ inputs.warn_on }}
174199
local_debug: ${{ inputs.local_debug }}
175200
flutter_packages: ${{ inputs.flutter_packages }}
201+
ignore_breaking: ${{ inputs.ignore_breaking }}
176202
ignore_packages: ${{ inputs.ignore_packages }}
177203
checkout_submodules: ${{ inputs.checkout_submodules }}
178204

@@ -186,6 +212,7 @@ jobs:
186212
warn_on: ${{ inputs.warn_on }}
187213
local_debug: ${{ inputs.local_debug }}
188214
flutter_packages: ${{ inputs.flutter_packages }}
215+
ignore_donotsubmit: ${{ inputs.ignore_donotsubmit }}
189216
ignore_packages: ${{ inputs.ignore_packages }}
190217
checkout_submodules: ${{ inputs.checkout_submodules }}
191218

@@ -199,6 +226,7 @@ jobs:
199226
warn_on: ${{ inputs.warn_on }}
200227
local_debug: ${{ inputs.local_debug }}
201228
flutter_packages: ${{ inputs.flutter_packages }}
229+
ignore_leaking: ${{ inputs.ignore_leaking }}
202230
ignore_packages: ${{ inputs.ignore_packages }}
203231
checkout_submodules: ${{ inputs.checkout_submodules }}
204232

.github/workflows/health_base.yaml

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,31 @@ on:
6262
default: "\"\""
6363
required: false
6464
type: string
65+
ignore_changelog:
66+
description: Which files to ignore for the license check.
67+
default: "\"\""
68+
required: false
69+
type: string
6570
ignore_coverage:
6671
description: Which files to ignore for the coverage check.
6772
default: "\"\""
6873
required: false
6974
type: string
75+
ignore_breaking:
76+
description: Which files to ignore for the license check.
77+
default: "\"\""
78+
required: false
79+
type: string
80+
ignore_leaking:
81+
description: Which files to ignore for the license check.
82+
default: "\"\""
83+
required: false
84+
type: string
85+
ignore_donotsubmit:
86+
description: Which files to ignore for the license check.
87+
default: "\"\""
88+
required: false
89+
type: string
7090
ignore_packages:
7191
description: Which packages to ignore.
7292
default: "\"\""
@@ -149,9 +169,13 @@ jobs:
149169
--fail_on ${{ inputs.fail_on }} \
150170
--warn_on ${{ inputs.warn_on }} \
151171
--flutter_packages ${{ inputs.flutter_packages }} \
172+
--ignore_packages ${{ inputs.ignore_packages }} \
152173
--ignore_license ${{ inputs.ignore_license }} \
174+
--ignore_changelog ${{ inputs.ignore_changelog }} \
153175
--ignore_coverage ${{ inputs.ignore_coverage }} \
154-
--ignore_packages ${{ inputs.ignore_packages }} \
176+
--ignore_breaking ${{ inputs.ignore_breaking }} \
177+
--ignore_leaking ${{ inputs.ignore_leaking }} \
178+
--ignore_donotsubmit ${{ inputs.ignore_donotsubmit }} \
155179
--experiments ${{ inputs.experiments }}
156180
157181
- 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

pkgs/firehose/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
## 0.10.2-wip
22

33
- Don't check licenses of generated files in PR health workflow.
4+
- Add generalized ignore-per-checks to health workflow.
45

56
## 0.10.1
67

pkgs/firehose/README.md

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -229,17 +229,16 @@ jobs:
229229

230230
| Name | Type | Description | Example |
231231
| ------------- | ------------- | ------------- | ------------- |
232-
| checks | List of strings | What to check for in the PR health check | `"version,changelog,license,coverage,breaking,do-not-submit,leaking"` |
233-
| fail_on | List of strings | Which checks should lead to failure | `"version,changelog,do-not-submit"` |
234-
| warn_on | List of strings | Which checks should not fail, but only warn | `"license,coverage,breaking,leaking"` |
235-
| upload_coverage | boolean | Whether to upload the coverage to [coveralls](https://coveralls.io/) | `true` |
236-
| coverage_web | boolean | Whether to run `dart test -p chrome` for coverage | `false` |
237-
| use-flutter | boolean | Whether to setup Flutter in this workflow | `false` |
238-
| ignore_license | List of globs | | `"**.g.dart"` |
239-
| ignore_coverage | List of globs | Which files to ignore for the license check | `"**.mock.dart,**.g.dart"` |
240-
| ignore_packages | List of globs | Which packages to ignore | `"pkgs/helper_package"` |
241-
| checkout_submodules | boolean | Whether to checkout submodules of git repositories | `false` |
242-
| experiments | List of strings | Which experiments should be enabled for Dart | `"native-assets"` |
232+
| `checks` | List of strings | What to check for in the PR health check | `"version,changelog,license,coverage,breaking,do-not-submit,leaking"` |
233+
| `fail_on` | List of strings | Which checks should lead to failure | `"version,changelog,do-not-submit"` |
234+
| `warn_on` | List of strings | Which checks should not fail, but only warn | `"license,coverage,breaking,leaking"` |
235+
| `upload_coverage` | boolean | Whether to upload the coverage to [coveralls](https://coveralls.io/) | `true` |
236+
| `coverage_web` | boolean | Whether to run `dart test -p chrome` for coverage | `false` |
237+
| `flutter_packages` | List of strings | List of packages depending on Flutter | `"pkgs/intl_flutter"` |
238+
| `ignore_*` | List of globs | Files to ignore, where `*` can be `license`, `changelog`, `coverage`, `breaking`, `leaking`, or `donotsubmit` | `"**.g.dart"` |
239+
| `ignore_packages` | List of globs | Which packages to ignore completely | `"pkgs/helper_package"` |
240+
| `checkout_submodules` | boolean | Whether to checkout submodules of git repositories | `false` |
241+
| `experiments` | List of strings | Which experiments should be enabled for Dart | `"native-assets"` |
243242

244243
### Workflow docs
245244

pkgs/firehose/bin/health.dart

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import 'package:firehose/src/github.dart';
99
import 'package:firehose/src/health/health.dart';
1010

1111
void main(List<String> arguments) async {
12-
var checkTypes = Check.values.map((c) => c.name);
12+
var checkTypes = Check.values.map((c) => c.displayName);
1313
var argParser = ArgParser()
1414
..addOption(
1515
'check',
@@ -21,16 +21,6 @@ void main(List<String> arguments) async {
2121
defaultsTo: [],
2222
help: 'Which packages to ignore.',
2323
)
24-
..addMultiOption(
25-
'ignore_license',
26-
defaultsTo: [],
27-
help: 'Which files to ignore for the license check.',
28-
)
29-
..addMultiOption(
30-
'ignore_coverage',
31-
defaultsTo: [],
32-
help: 'Which files to ignore for the coverage check.',
33-
)
3424
..addMultiOption(
3525
'warn_on',
3626
allowed: checkTypes,
@@ -54,15 +44,22 @@ void main(List<String> arguments) async {
5444
defaultsTo: [],
5545
help: 'The Flutter packages in this repo',
5646
);
47+
for (var check in Check.values) {
48+
argParser.addMultiOption(
49+
'ignore_${check.name}',
50+
defaultsTo: [],
51+
help: 'Which files to ignore for the ${check.displayName} check.',
52+
);
53+
}
5754
final parsedArgs = argParser.parse(arguments);
5855
final checkStr = parsedArgs.option('check');
59-
final check = Check.values.firstWhere((c) => c.name == checkStr);
56+
final check = Check.values.firstWhere((c) => c.displayName == checkStr);
6057
final warnOn = parsedArgs.multiOption('warn_on');
6158
final failOn = parsedArgs.multiOption('fail_on');
6259
final flutterPackages = _listNonEmpty(parsedArgs, 'flutter_packages');
6360
final ignorePackages = _listNonEmpty(parsedArgs, 'ignore_packages');
64-
final ignoreLicense = _listNonEmpty(parsedArgs, 'ignore_license');
65-
final ignoreCoverage = _listNonEmpty(parsedArgs, 'ignore_coverage');
61+
final ignoredFor = Map.fromEntries(Check.values
62+
.map((c) => MapEntry(c, _listNonEmpty(parsedArgs, 'ignore_${c.name}'))));
6663
final experiments = _listNonEmpty(parsedArgs, 'experiments');
6764
final coverageWeb = parsedArgs.flag('coverage_web');
6865
if (warnOn.toSet().intersection(failOn.toSet()).isNotEmpty) {
@@ -76,8 +73,7 @@ void main(List<String> arguments) async {
7673
failOn,
7774
coverageWeb,
7875
ignorePackages,
79-
ignoreLicense,
80-
ignoreCoverage,
76+
ignoredFor,
8177
experiments,
8278
GithubApi(),
8379
flutterPackages,

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,12 @@ import '../repo.dart';
1212

1313
Future<Map<Package, List<GitFile>>> packagesWithoutChangelog(
1414
GithubApi github,
15-
List<Glob> ignoredPackages,
15+
List<Glob> ignored,
1616
Directory directory,
1717
) async {
1818
final repo = Repository(directory);
19-
final packages = repo.locatePackages(ignore: ignoredPackages);
20-
21-
final files = await github.listFilesForPR(directory, ignoredPackages);
19+
final packages = repo.locatePackages(ignore: ignored);
20+
final files = await github.listFilesForPR(directory, ignored);
2221

2322
var packagesWithoutChangedChangelog = collectPackagesWithoutChangelogChanges(
2423
packages,

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

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,38 +16,35 @@ import 'lcov.dart';
1616

1717
class Coverage {
1818
final bool coverageWeb;
19-
final List<Glob> ignoredFiles;
20-
final List<Glob> ignoredPackages;
19+
final List<Glob> ignored;
2120
final Directory directory;
2221
final List<String> experiments;
2322
final String dartExecutable;
2423

2524
Coverage(
2625
this.coverageWeb,
27-
this.ignoredFiles,
28-
this.ignoredPackages,
26+
this.ignored,
2927
this.directory,
3028
this.experiments,
3129
this.dartExecutable,
3230
);
3331

3432
CoverageResult compareCoveragesFor(List<GitFile> files, Directory base) {
3533
var repository = Repository(directory);
36-
var packages = repository.locatePackages(ignore: ignoredPackages);
34+
var packages = repository.locatePackages(ignore: ignored);
3735
print('Found packages $packages at $directory');
3836

3937
var filesOfInterest = files
4038
.where((file) => path.extension(file.filename) == '.dart')
4139
.where((file) => file.status != FileStatus.removed)
4240
.where((file) => isInSomePackage(packages, file.filename))
4341
.where((file) => isNotATest(packages, file.filename))
44-
.where(
45-
(file) => ignoredFiles.none((glob) => glob.matches(file.filename)))
42+
.where((file) => ignored.none((glob) => glob.matches(file.filename)))
4643
.toList();
4744
print('The files of interest are $filesOfInterest');
4845

4946
var baseRepository = Repository(base);
50-
var basePackages = baseRepository.locatePackages(ignore: ignoredPackages);
47+
var basePackages = baseRepository.locatePackages(ignore: ignored);
5148
print('Found packages $basePackages at $base');
5249

5350
var changedPackages = packages

0 commit comments

Comments
 (0)