Skip to content

Commit 9fabe46

Browse files
authored
Add check for API leaks to the Health workflow (#251)
* Add checks for API leaks * Fixes * More fixes * Fix SDK version in testdata * Install dart_apitool on leaking in action * Update tests * Fix message * Add exports * Fix analyze issues * Reset tests after adding a period
1 parent 95fed18 commit 9fabe46

32 files changed

+284
-101
lines changed

.github/workflows/health.yaml

+21-8
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ name: Health
2121
# uses: dart-lang/ecosystem/.github/workflows/health.yaml@main
2222
# with:
2323
# sdk: beta
24-
# checks: "version,changelog,license,coverage,breaking,do-not-submit"
24+
# checks: "version,changelog,license,coverage,breaking,do-not-submit,leaking"
2525
# fail_on: "version,changelog,do-not-submit"
26-
# warn_on: "license,coverage,breaking"
26+
# warn_on: "license,coverage,breaking,leaking"
2727
# coverage_web: false
2828
# upload_coverage: false
2929
# use-flutter: true
@@ -54,18 +54,18 @@ on:
5454
# Restrict the checks to any subset of version, changelog, and license if
5555
# needed.
5656
checks:
57-
description: What to check for in the PR health check - any subset of "version,changelog,license,coverage,breaking,do-not-submit"
58-
default: "version,changelog,license,coverage,breaking,do-not-submit"
57+
description: What to check for in the PR health check - any subset of "version,changelog,license,coverage,breaking,do-not-submit,leaking"
58+
default: "version,changelog,license,coverage,breaking,do-not-submit,leaking"
5959
type: string
6060
required: false
6161
fail_on:
62-
description: Which checks should lead to failure - any subset of "version,changelog,license,coverage,breaking,do-not-submit"
62+
description: Which checks should lead to failure - any subset of "version,changelog,license,coverage,breaking,do-not-submit,leaking"
6363
default: "version,changelog,do-not-submit"
6464
type: string
6565
required: false
6666
warn_on:
67-
description: Which checks should not fail, but only warn - any subset of "version,changelog,license,coverage,breaking,do-not-submit"
68-
default: "license,coverage,breaking"
67+
description: Which checks should not fail, but only warn - any subset of "version,changelog,license,coverage,breaking,do-not-submit,leaking"
68+
default: "license,coverage,breaking,leaking"
6969
type: string
7070
required: false
7171
local_debug:
@@ -198,8 +198,21 @@ jobs:
198198
ignore_packages: ${{ inputs.ignore_packages }}
199199
checkout_submodules: ${{ inputs.checkout_submodules }}
200200

201+
leaking:
202+
if: ${{ contains(inputs.checks, 'leaking') }}
203+
uses: ./.github/workflows/health_base.yaml
204+
with:
205+
sdk: ${{ inputs.sdk }}
206+
check: leaking
207+
fail_on: ${{ inputs.fail_on }}
208+
warn_on: ${{ inputs.warn_on }}
209+
local_debug: ${{ inputs.local_debug }}
210+
use-flutter: ${{ inputs.use-flutter }}
211+
ignore_packages: ${{ inputs.ignore_packages }}
212+
checkout_submodules: ${{ inputs.checkout_submodules }}
213+
201214
comment:
202-
needs: [version, changelog, license, coverage, breaking, do-not-submit]
215+
needs: [version, changelog, license, coverage, breaking, do-not-submit, leaking]
203216
if: always()
204217
# These permissions are required for us to create comments on PRs.
205218
permissions:

.github/workflows/health_base.yaml

+5-5
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,17 @@ on:
1616
required: false
1717
type: string
1818
check:
19-
description: What to check for in the PR health check - any of "version,changelog,license,coverage,breaking,do-not-submit"
19+
description: What to check for in the PR health check - any of "version,changelog,license,coverage,breaking,do-not-submit,leaking"
2020
type: string
2121
required: true
2222
fail_on:
23-
description: Which checks should lead to failure - any subset of "version,changelog,license,coverage,breaking,do-not-submit"
23+
description: Which checks should lead to failure - any subset of "version,changelog,license,coverage,breaking,do-not-submit,leaking"
2424
default: "version,changelog,do-not-submit"
2525
type: string
2626
required: false
2727
warn_on:
28-
description: Which checks should not fail, but only warn - any subset of "version,changelog,license,coverage,breaking,do-not-submit"
29-
default: "license,coverage,breaking"
28+
description: Which checks should not fail, but only warn - any subset of "version,changelog,license,coverage,breaking,do-not-submit,leaking"
29+
default: "license,coverage,breaking,leaking"
3030
type: string
3131
required: false
3232
local_debug:
@@ -123,7 +123,7 @@ jobs:
123123

124124
- name: Install api_tool
125125
run: dart pub global activate dart_apitool
126-
if: ${{ inputs.check == 'breaking' }}
126+
if: ${{ inputs.check == 'breaking' || inputs.check == 'leaking' }}
127127

128128
- name: Check PR health
129129
id: healthstep

.github/workflows/health_internal.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ jobs:
1212
local_debug: true
1313
coverage_web: false
1414
upload_coverage: false
15-
checks: version,changelog,license,coverage,breaking,do-not-submit
15+
checks: version,changelog,license,coverage,breaking,do-not-submit,leaking
1616
fail_on: version,changelog,do-not-submit
17-
warn_on: license,coverage,breaking
17+
warn_on: license,coverage,breaking,leaking
1818
ignore_license: 'pkgs/firehose/test_data'
19-
ignore_coverage: 'pkgs/firehose/bin'
19+
ignore_coverage: 'pkgs/firehose/bin,pkgs/firehose/test_data'

.vscode/launch.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
},
1818
"args": [
1919
"--checks",
20-
"version,changelog,license,coverage,do-not-submit"
20+
"version,changelog,license,coverage,do-not-submit,leaking"
2121
]
2222
}
2323
]

pkgs/firehose/CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.9.0
2+
3+
- Add `leaking` check to the health workflow.
4+
15
## 0.8.0
26

37
- Only check text files for do not submit strings.

pkgs/firehose/README.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ When run from a PR, this tool will check a configurable subset of the following
166166
* How the test coverage is affected by the PR.
167167
* The package versioning takes into account any breaking changes in the PR.
168168
* The PR contains `DO_NOT_SUBMIT` strings in the files or the description.
169+
* Any symbols are visible in the public API, but not exported.
169170

170171
This tool can work with either single package repos or with mono-repos (repos
171172
containing several packages).
@@ -192,9 +193,9 @@ jobs:
192193

193194
| Name | Type | Description | Example |
194195
| ------------- | ------------- | ------------- | ------------- |
195-
| checks | List of strings | What to check for in the PR health check | `"version,changelog,license,coverage,breaking,do-not-submit"` |
196+
| checks | List of strings | What to check for in the PR health check | `"version,changelog,license,coverage,breaking,do-not-submit,leaking"` |
196197
| fail_on | List of strings | Which checks should lead to failure | `"version,changelog,do-not-submit"` |
197-
| warn_on | List of strings | Which checks should not fail, but only warn | `"license,coverage,breaking"` |
198+
| warn_on | List of strings | Which checks should not fail, but only warn | `"license,coverage,breaking,leaking"` |
198199
| upload_coverage | boolean | Whether to upload the coverage to [coveralls](https://coveralls.io/) | `true` |
199200
| coverage_web | boolean | Whether to run `dart test -p chrome` for coverage | `false` |
200201
| use-flutter | boolean | Whether to setup Flutter in this workflow | `false` |

pkgs/firehose/bin/firehose.dart

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import 'dart:io';
66

77
import 'package:args/args.dart';
88
import 'package:firehose/firehose.dart';
9-
import 'package:firehose/src/github.dart';
109
import 'package:glob/glob.dart';
1110

1211
const helpFlag = 'help';

pkgs/firehose/bin/health.dart

+3-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +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);
1213
var argParser = ArgParser()
1314
..addOption(
1415
'check',
@@ -49,7 +50,8 @@ void main(List<String> arguments) async {
4950
help: 'Whether to run web tests for coverage',
5051
);
5152
final parsedArgs = argParser.parse(arguments);
52-
final check = parsedArgs['check'] as String;
53+
final checkStr = parsedArgs['check'] as String;
54+
final check = Check.values.firstWhere((c) => c.name == checkStr);
5355
final warnOn = parsedArgs['warn_on'] as List<String>;
5456
final failOn = parsedArgs['fail_on'] as List<String>;
5557
final ignorePackages = _listNonEmpty(parsedArgs, 'ignore_packages');

pkgs/firehose/lib/firehose.dart

+5
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ import 'src/pub.dart';
1414
import 'src/repo.dart';
1515
import 'src/utils.dart';
1616

17+
export 'src/changelog.dart' show Changelog;
18+
export 'src/github.dart' show FileStatus, GitFile, GithubApi;
19+
export 'src/repo.dart' show Package, Repository;
20+
export 'src/utils.dart' show Severity;
21+
1722
const String _botSuffix = '[bot]';
1823

1924
const String _githubActionsUser = 'github-actions[bot]';

0 commit comments

Comments
 (0)