Skip to content

Commit b001826

Browse files
refactor: remove coverage action in favor of CLI (#425)
* refactor: remove very good coverage in favor of CLI * chore: use new CLI test flags * chore: use latest in main * chore: activate latest in main on flutter pkg * chore: add and order missing flags to dart/flutter pkg * chore: add missing flags and update docs * chore: install very_good_cli from pub * docs: add missing flags * docs: update coverage_excludes * chore: apply suggestions from code review Co-authored-by: Marcos Sevilla <31174242+marcossevilla@users.noreply.github.com> * fix(ci): format files
1 parent 6505830 commit b001826

6 files changed

Lines changed: 178 additions & 52 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
uses: ./.github/workflows/flutter_package.yml
1919
with:
2020
flutter_channel: stable
21-
flutter_version: 3.35.0
21+
flutter_version: "3.41.x"
2222
setup: flutter doctor --verbose
2323
working_directory: examples/flutter_package
2424

.github/workflows/dart_package.yml

Lines changed: 44 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ on:
77
required: false
88
type: string
99
default: "lib test"
10+
collect_coverage_from:
11+
required: false
12+
type: string
13+
default: "imports"
14+
description: "Whether to collect coverage from imported files only or all files. Allowed values: imports, all."
1015
concurrency:
1116
required: false
1217
type: number
@@ -15,6 +20,7 @@ on:
1520
required: false
1621
type: string
1722
default: ""
23+
description: "Space-separated list of globs to exclude files from the coverage report (e.g. '**/*.g.dart **/gen/*.dart')."
1824
dart_sdk:
1925
required: false
2026
type: string
@@ -30,6 +36,10 @@ on:
3036
required: false
3137
type: number
3238
default: 100
39+
no_example:
40+
required: false
41+
type: boolean
42+
default: false
3343
platform:
3444
required: false
3545
type: string
@@ -38,10 +48,19 @@ on:
3848
required: false
3949
type: boolean
4050
default: false
51+
description: "Whether to check for and respect coverage ignore comments (e.g. // coverage:ignore-line)."
4152
report_on:
4253
required: false
4354
type: string
4455
default: "lib"
56+
run_bloc_lint:
57+
required: false
58+
type: boolean
59+
default: true
60+
run_skipped:
61+
required: false
62+
type: boolean
63+
default: false
4564
runs_on:
4665
required: false
4766
type: string
@@ -50,22 +69,20 @@ on:
5069
required: false
5170
type: string
5271
default: ""
53-
working_directory:
54-
required: false
55-
type: string
56-
default: "."
57-
run_skipped:
72+
show_uncovered:
5873
required: false
5974
type: boolean
60-
default: false
61-
no_example:
75+
default: true
76+
description: "Whether to show uncovered lines when coverage is below 100%."
77+
test_optimization:
6278
required: false
63-
type: boolean
64-
default: false
65-
run_bloc_lint:
6679
type: boolean
6780
default: true
81+
description: "Whether to apply optimizations for test performance."
82+
working_directory:
6883
required: false
84+
type: string
85+
default: "."
6986
secrets:
7087
ssh_key:
7188
required: false
@@ -96,7 +113,9 @@ jobs:
96113
ssh-private-key: ${{secrets.ssh_key}}
97114

98115
- name: 📦 Install Dependencies
99-
run: dart pub get ${{(inputs.no_example && '--no-example') || ''}}
116+
run: |
117+
dart pub global activate very_good_cli
118+
dart pub get ${{(inputs.no_example && '--no-example') || ''}}
100119
101120
- name: ⚙️ Run Setup
102121
if: "${{inputs.setup != ''}}"
@@ -115,13 +134,17 @@ jobs:
115134
bloc lint .
116135
117136
- name: 🧪 Run Tests
118-
run: |
119-
dart pub global activate coverage 1.15.0
120-
dart test -j ${{inputs.concurrency}} --coverage=coverage --platform=${{inputs.platform}} ${{(inputs.run_skipped && '--run-skipped') || ''}} && dart pub global run coverage:format_coverage --lcov ${{(inputs.check_ignore && '--check-ignore') || ''}} --in=coverage --out=coverage/lcov.info --packages=.dart_tool/package_config.json --report-on=${{inputs.report_on}}
121-
122-
- name: 📊 Check Code Coverage
123-
uses: VeryGoodOpenSource/very_good_coverage@v3
124-
with:
125-
path: ${{inputs.working_directory}}/coverage/lcov.info
126-
exclude: ${{inputs.coverage_excludes}}
127-
min_coverage: ${{inputs.min_coverage}}
137+
run: >-
138+
very_good dart test
139+
-j ${{inputs.concurrency}}
140+
--coverage
141+
--platform ${{inputs.platform}}
142+
--min-coverage ${{inputs.min_coverage}}
143+
${{inputs.coverage_excludes != '' && format('--exclude-coverage "{0}"', inputs.coverage_excludes) || ''}}
144+
${{format('--report-on {0}', inputs.report_on)}}
145+
${{inputs.collect_coverage_from != 'imports' && format('--collect-coverage-from {0}', inputs.collect_coverage_from) || ''}}
146+
${{inputs.check_ignore && '--check-ignore' || '--no-check-ignore'}}
147+
${{inputs.show_uncovered && '--show-uncovered' || ''}}
148+
${{inputs.run_skipped && '--run-skipped' || ''}}
149+
${{(inputs.test_optimization && '--optimization') || '--no-optimization'}}
150+
--test-randomize-ordering-seed random

.github/workflows/flutter_package.yml

Lines changed: 47 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ on:
77
required: false
88
type: string
99
default: "lib test"
10+
collect_coverage_from:
11+
required: false
12+
type: string
13+
default: "imports"
14+
description: "Whether to collect coverage from imported files only or all files. Allowed values: imports, all."
1015
concurrency:
1116
required: false
1217
type: number
@@ -15,6 +20,7 @@ on:
1520
required: false
1621
type: string
1722
default: ""
23+
description: "Space-separated list of globs to exclude files from the coverage report (e.g. '**/*.g.dart **/gen/*.dart')."
1824
flutter_channel:
1925
required: false
2026
type: string
@@ -34,6 +40,27 @@ on:
3440
required: false
3541
type: number
3642
default: 100
43+
package_get_excludes:
44+
required: false
45+
type: string
46+
default: "!*"
47+
platform:
48+
required: false
49+
type: string
50+
default: ""
51+
description: "The platform to run tests on (e.g., 'chrome', 'android', 'ios')."
52+
report_on:
53+
required: false
54+
type: string
55+
default: "lib"
56+
run_bloc_lint:
57+
required: false
58+
type: boolean
59+
default: true
60+
run_skipped:
61+
required: false
62+
type: boolean
63+
default: false
3764
runs_on:
3865
required: false
3966
type: string
@@ -42,6 +69,11 @@ on:
4269
required: false
4370
type: string
4471
default: ""
72+
show_uncovered:
73+
required: false
74+
type: boolean
75+
default: true
76+
description: "Whether to show uncovered lines when coverage is below 100%."
4577
test_optimization:
4678
required: false
4779
type: boolean
@@ -54,14 +86,6 @@ on:
5486
required: false
5587
type: string
5688
default: "."
57-
package_get_excludes:
58-
required: false
59-
type: string
60-
default: "!*"
61-
run_bloc_lint:
62-
type: boolean
63-
default: true
64-
required: false
6589
secrets:
6690
ssh_key:
6791
required: false
@@ -96,7 +120,7 @@ jobs:
96120

97121
- name: 📦 Install Dependencies
98122
run: |
99-
flutter pub global activate very_good_cli
123+
dart pub global activate very_good_cli
100124
very_good packages get --recursive --ignore=${{inputs.package_get_excludes}}
101125
102126
- name: ⚙️ Run Setup
@@ -116,11 +140,17 @@ jobs:
116140
bloc lint .
117141
118142
- name: 🧪 Run Tests
119-
run: very_good test -j ${{inputs.concurrency}} ${{(inputs.test_recursion && '--recursive') || ''}} ${{(inputs.test_optimization && '--optimization') || '--no-optimization'}} --coverage --test-randomize-ordering-seed random
120-
121-
- name: 📊 Check Code Coverage
122-
uses: VeryGoodOpenSource/very_good_coverage@v3
123-
with:
124-
path: ${{inputs.working_directory}}/coverage/lcov.info
125-
exclude: ${{inputs.coverage_excludes}}
126-
min_coverage: ${{inputs.min_coverage}}
143+
run: >-
144+
very_good test
145+
-j ${{inputs.concurrency}}
146+
${{(inputs.test_recursion && '--recursive') || ''}}
147+
${{(inputs.test_optimization && '--optimization') || '--no-optimization'}}
148+
--coverage
149+
--min-coverage ${{inputs.min_coverage}}
150+
${{inputs.coverage_excludes != '' && format('--exclude-coverage "{0}"', inputs.coverage_excludes) || ''}}
151+
${{format('--report-on {0}', inputs.report_on)}}
152+
${{inputs.collect_coverage_from != 'imports' && format('--collect-coverage-from {0}', inputs.collect_coverage_from) || ''}}
153+
${{inputs.show_uncovered && '--show-uncovered' || ''}}
154+
${{inputs.run_skipped && '--run-skipped' || ''}}
155+
${{inputs.platform != '' && format('--platform {0}', inputs.platform) || ''}}
156+
--test-randomize-ordering-seed random

site/docs/overview.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ uses: VeryGoodOpenSource/very_good_workflows/.github/workflows/dart_pub_publish.
3737
# A reusable workflow for publishing Mason bricks
3838
uses: VeryGoodOpenSource/very_good_workflows/.github/workflows/mason_publish.yml@v1
3939

40+
# A reusable workflow to keep track of the rights and restrictions external dependencies might impose on Dart or Flutter projects
41+
uses: VeryGoodOpenSource/very_good_workflows/.github/workflows/license_check.yml@v1
42+
4043
```
4144
4245
[github_workflows_link]: https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions

site/docs/workflows/dart_package.md

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,14 @@ This workflow runs helpful checks on a Dart package according to the steps below
1010

1111
The Dart package workflow consists of the following steps:
1212

13-
1. Install dependencies
14-
2. Format
15-
3. Analyze
16-
4. Run tests
17-
5. Check code coverage
13+
1. Setup Dart
14+
2. Set SSH Key (if provided)
15+
3. Install dependencies
16+
4. Run Setup (if provided)
17+
5. Format
18+
6. Analyze
19+
7. Bloc Lint (if enabled)
20+
8. Run tests (includes coverage collection and enforcement)
1821

1922
## Inputs
2023

@@ -26,7 +29,7 @@ The Dart package workflow consists of the following steps:
2629

2730
### `coverage_excludes`
2831

29-
**Optional** List of paths to exclude from the coverage report, separated by an empty space. Supports `globs` to describe file patterns.
32+
**Optional** Space-separated list of globs to exclude files from the coverage report (e.g. '**/\*.g.dart **/gen/\*.dart').
3033

3134
**Default** `""`
3235

@@ -66,7 +69,7 @@ The Dart package workflow consists of the following steps:
6669

6770
### `check_ignore`
6871

69-
**Optional** Allows ignoring lines from [coverage](https://pub.dev/packages/coverage).
72+
**Optional** Whether to check for and respect coverage ignore comments (e.g. `// coverage:ignore-line`).
7073

7174
**Default** `false`
7275

@@ -107,6 +110,32 @@ The Dart package workflow consists of the following steps:
107110

108111
**Default** `false`
109112

113+
### `show_uncovered`
114+
115+
**Optional** Whether to show uncovered lines when coverage is below 100%. Implicitly enables coverage collection when used alone.
116+
117+
**Default** `true`
118+
119+
### `collect_coverage_from`
120+
121+
**Optional** Whether to collect coverage from imported files only or all files. Counting untested files against coverage (`all`) results in stricter enforcement.
122+
123+
**Allowed values** `imports`, `all`
124+
125+
**Default** `"imports"`
126+
127+
### `test_optimization`
128+
129+
**Optional** Whether to apply optimizations for test performance.
130+
131+
**Default** `true`
132+
133+
### `run_bloc_lint`
134+
135+
**Optional** Whether to run [bloc lint](https://pub.dev/packages/bloc_tools) on the package.
136+
137+
**Default** `true`
138+
110139
## Secrets
111140

112141
### `ssh_key`

site/docs/workflows/flutter_package.md

Lines changed: 47 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,14 @@ This workflow runs helpful checks on a Flutter package according to the steps be
1010

1111
The Flutter package workflow consists of the following steps:
1212

13-
1. Install dependencies
14-
2. Format
15-
3. Analyze
16-
4. Run tests
17-
5. Check code coverage
13+
1. Setup Flutter
14+
2. Set SSH Key (if provided)
15+
3. Install dependencies
16+
4. Run Setup (if provided)
17+
5. Format
18+
6. Analyze
19+
7. Bloc Lint (if enabled)
20+
8. Run tests (includes coverage collection and enforcement)
1821

1922
## Inputs
2023

@@ -38,7 +41,7 @@ The Flutter package workflow consists of the following steps:
3841

3942
### `coverage_excludes`
4043

41-
**Optional** A space-separated list of paths to exclude from the coverage report. Supports `globs` to describe file patterns.
44+
**Optional** Space-separated list of globs to exclude files from the coverage report (e.g. '**/\*.g.dart **/gen/\*.dart').
4245

4346
**Default** `""`
4447

@@ -102,6 +105,44 @@ The Flutter package workflow consists of the following steps:
102105

103106
**Default** `"!*"`
104107

108+
### `platform`
109+
110+
**Optional** The platform to run tests on (e.g., `chrome`, `android`, `ios`).
111+
112+
**Default** `""`
113+
114+
### `report_on`
115+
116+
**Optional** A comma-separated list of folders that should be checked in code coverage.
117+
118+
**Default** `"lib"`
119+
120+
### `run_bloc_lint`
121+
122+
**Optional** Whether to run [bloc lint](https://pub.dev/packages/bloc_tools) on the package.
123+
124+
**Default** `true`
125+
126+
### `run_skipped`
127+
128+
**Optional** Run skipped tests instead of skipping them.
129+
130+
**Default** `false`
131+
132+
### `show_uncovered`
133+
134+
**Optional** Whether to show uncovered lines when coverage is below 100%. Implicitly enables coverage collection when used alone.
135+
136+
**Default** `true`
137+
138+
### `collect_coverage_from`
139+
140+
**Optional** Whether to collect coverage from imported files only or all files. Counting untested files against coverage (`all`) results in stricter enforcement.
141+
142+
**Allowed values** `imports`, `all`
143+
144+
**Default** `"imports"`
145+
105146
## Secrets
106147

107148
### `ssh_key`

0 commit comments

Comments
 (0)