Skip to content

Commit f61a550

Browse files
authored
Enable experiments for health (#226)
* Enable `enable-experiment` option for health * Fix DNS bug * Add default * Add default to yaml * Add default to other wf * Add debug message * Remove empty from list * Add empty arg * Rev version * join by comma * Fix typos
1 parent c81f25c commit f61a550

File tree

8 files changed

+72
-19
lines changed

8 files changed

+72
-19
lines changed

.github/workflows/health.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,11 @@ on:
8888
default: false
8989
required: false
9090
type: boolean
91+
experiments:
92+
description: Which experiments should be enabled for Dart.
93+
default: "\"\""
94+
type: string
95+
required: false
9196

9297
jobs:
9398
version:
@@ -101,6 +106,7 @@ jobs:
101106
local_debug: ${{ inputs.local_debug }}
102107
use-flutter: ${{ inputs.use-flutter }}
103108
checkout_submodules: ${{ inputs.checkout_submodules }}
109+
104110
changelog:
105111
if: ${{ contains(inputs.checks, 'changelog') }}
106112
uses: ./.github/workflows/health_base.yaml
@@ -138,6 +144,7 @@ jobs:
138144
local_debug: ${{ inputs.local_debug }}
139145
use-flutter: ${{ inputs.use-flutter }}
140146
checkout_submodules: ${{ inputs.checkout_submodules }}
147+
experiments: ${{ inputs.experiments }}
141148

142149
breaking:
143150
if: ${{ contains(inputs.checks, 'breaking') }}

.github/workflows/health_base.yaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ on:
5555
default: false
5656
required: false
5757
type: boolean
58+
experiments:
59+
description: Which experiments should be enabled for Dart.
60+
default: "\"\""
61+
type: string
62+
required: false
5863

5964
jobs:
6065
health:
@@ -119,7 +124,8 @@ jobs:
119124
--check ${{ inputs.check }} \
120125
${{ fromJSON('{"true":"--coverage_web","false":""}')[inputs.coverage_web] }} \
121126
--fail_on ${{ inputs.fail_on }} \
122-
--warn_on ${{ inputs.warn_on }}
127+
--warn_on ${{ inputs.warn_on }} \
128+
--experiments ${{ inputs.experiments }}
123129
124130
- 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
125131
if: ${{ '$action_state' == 1 }}

pkgs/firehose/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.5.3
2+
3+
- Allow experiments to be enabled for Dart.
4+
15
## 0.5.2
26

37
- Also run health workflows on bot PRs.

pkgs/firehose/bin/health.dart

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ void main(List<String> arguments) async {
2424
allowed: checkTypes,
2525
help: 'Which checks should lead to workflow failure',
2626
)
27+
..addMultiOption(
28+
'experiments',
29+
help: 'Which experiments should be enabled for Dart',
30+
)
2731
..addFlag(
2832
'coverage_web',
2933
help: 'Whether to run web tests for coverage',
@@ -32,11 +36,20 @@ void main(List<String> arguments) async {
3236
var check = parsedArgs['check'] as String;
3337
var warnOn = parsedArgs['warn_on'] as List<String>;
3438
var failOn = parsedArgs['fail_on'] as List<String>;
39+
var experiments = (parsedArgs['experiments'] as List<String>)
40+
.where((name) => name.isNotEmpty)
41+
.toList();
3542
var coverageWeb = parsedArgs['coverage_web'] as bool;
3643
if (warnOn.toSet().intersection(failOn.toSet()).isNotEmpty) {
3744
throw ArgumentError('The checks for which warnings are displayed and the '
3845
'checks which lead to failure must be disjoint.');
3946
}
40-
await Health(Directory.current, check, warnOn, failOn, coverageWeb)
41-
.healthCheck();
47+
await Health(
48+
Directory.current,
49+
check,
50+
warnOn,
51+
failOn,
52+
coverageWeb,
53+
experiments,
54+
).healthCheck();
4255
}

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

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ import 'lcov.dart';
1414

1515
class Coverage {
1616
final bool coverageWeb;
17+
final List<String> experiments;
1718

18-
Coverage(this.coverageWeb);
19+
Coverage(this.coverageWeb, this.experiments);
1920

2021
Future<CoverageResult> compareCoverages(GithubApi github) async {
2122
var files = await github.listFilesForPR();
@@ -93,14 +94,26 @@ class Coverage {
9394
Get coverage for ${package.name} by running coverage in ${package.directory.path}''');
9495
Process.runSync(
9596
'dart',
96-
['pub', 'get'],
97+
[
98+
if (experiments.isNotEmpty)
99+
'--enable-experiment=${experiments.join(',')}',
100+
'pub',
101+
'get'
102+
],
97103
workingDirectory: package.directory.path,
98104
);
99105
if (coverageWeb) {
100106
print('Get test coverage for web');
101107
var resultChrome = Process.runSync(
102108
'dart',
103-
['test', '-p', 'chrome', '--coverage=coverage'],
109+
[
110+
if (experiments.isNotEmpty)
111+
'--enable-experiment=${experiments.join(',')}',
112+
'test',
113+
'-p',
114+
'chrome',
115+
'--coverage=coverage'
116+
],
104117
workingDirectory: package.directory.path,
105118
);
106119
print(resultChrome.stdout);
@@ -109,7 +122,12 @@ Get coverage for ${package.name} by running coverage in ${package.directory.path
109122
print('Get test coverage for vm');
110123
var resultVm = Process.runSync(
111124
'dart',
112-
['test', '--coverage=coverage'],
125+
[
126+
if (experiments.isNotEmpty)
127+
'--enable-experiment=${experiments.join(',')}',
128+
'test',
129+
'--coverage=coverage'
130+
],
113131
workingDirectory: package.directory.path,
114132
);
115133
print(resultVm.stdout);

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

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,15 @@ class Health {
5050
this.warnOn,
5151
this.failOn,
5252
this.coverageweb,
53+
this.experiments,
5354
);
5455
final github = GithubApi();
5556

5657
final String check;
5758
final List<String> warnOn;
5859
final List<String> failOn;
5960
final bool coverageweb;
61+
final List<String> experiments;
6062

6163
Future<void> healthCheck() async {
6264
// Do basic validation of our expected env var.
@@ -259,24 +261,26 @@ Changes to files need to be [accounted for](https://github.com/dart-lang/ecosyst
259261
}
260262

261263
Future<HealthCheckResult> doNotSubmitCheck() async {
264+
final dns = 'DO_NOT${'_'}SUBMIT';
265+
262266
final body = await github.pullrequestBody();
263267
final files = await github.listFilesForPR();
264-
print('Checking for DO_NOT${'_'}SUBMIT strings: $files');
268+
print('Checking for $dns strings: $files');
265269
final filesWithDNS = files
266270
.where((file) =>
267271
![FileStatus.removed, FileStatus.unchanged].contains(file.status))
268-
.where((file) => File(file.relativePath)
269-
.readAsStringSync()
270-
.contains('DO_NOT${'_'}SUBMIT'))
272+
.where((file) => File(file.relativePath).existsSync())
273+
.where(
274+
(file) => File(file.relativePath).readAsStringSync().contains(dns))
271275
.toList();
272-
print('Found files with DO_NOT_${'SUBMIT'}: $filesWithDNS');
276+
print('Found files with $dns: $filesWithDNS');
273277

274-
final bodyContainsDNS = body.contains('DO_NOT${'_'}SUBMIT');
275-
print('The body contains a DO_NOT${'_'}SUBMIT string: $bodyContainsDNS');
278+
final bodyContainsDNS = body.contains(dns);
279+
print('The body contains a $dns string: $bodyContainsDNS');
276280
final markdownResult = '''
277-
Body contains `DO_NOT${'_'}SUBMIT`: $bodyContainsDNS
281+
Body contains `$dns`: $bodyContainsDNS
278282
279-
| Files with `DO_NOT_${'SUBMIT'}` |
283+
| Files with `$dns` |
280284
| :--- |
281285
${filesWithDNS.map((e) => e.filename).map((e) => '|$e|').join('\n')}
282286
''';
@@ -290,7 +294,8 @@ ${filesWithDNS.map((e) => e.filename).map((e) => '|$e|').join('\n')}
290294
}
291295

292296
Future<HealthCheckResult> coverageCheck() async {
293-
var coverage = await Coverage(coverageweb).compareCoverages(github);
297+
var coverage =
298+
await Coverage(coverageweb, experiments).compareCoverages(github);
294299

295300
var markdownResult = '''
296301
| File | Coverage |

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.5.2
3+
version: 0.5.3
44
repository: https://github.com/dart-lang/ecosystem/tree/main/pkgs/firehose
55

66
environment:

pkgs/firehose/test/coverage_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ void main() {
4343
}
4444

4545
class FakeHealth extends Coverage {
46-
FakeHealth() : super(true);
46+
FakeHealth() : super(true, []);
4747

4848
@override
4949
Map<String, double> getCoverage(Package? package) {

0 commit comments

Comments
 (0)