Skip to content

Commit dfe746e

Browse files
committed
👷 add custom coverage check to ensure minimum coverage threshold is met
1 parent cf5a309 commit dfe746e

1 file changed

Lines changed: 21 additions & 4 deletions

File tree

.github/workflows/test.yml

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ concurrency:
2121
cancel-in-progress: true
2222

2323
env:
24+
MIN_COVERAGE: 90
2425
PUB_ENVIRONMENT: bot.github
2526

2627
jobs:
@@ -167,10 +168,26 @@ jobs:
167168
verbose: true
168169
- name: Check Code Coverage
169170
if: ${{ matrix.platform == 'vm' }}
170-
uses: VeryGoodOpenSource/very_good_coverage@v3.0.0
171-
with:
172-
path: coverage/lcov.info
173-
min_coverage: 90
171+
run: |
172+
set -euo pipefail
173+
awk -F: -v min="$MIN_COVERAGE" '
174+
/^LF:/ { total += $2 }
175+
/^LH:/ { hit += $2 }
176+
END {
177+
if (total == 0) {
178+
print "::error::No executable lines found in coverage/lcov.info"
179+
exit 1
180+
}
181+
182+
coverage = (hit / total) * 100
183+
printf("Line coverage: %.2f%% (%d/%d)\n", coverage, hit, total)
184+
185+
if (coverage < min) {
186+
printf("::error::Coverage %.2f%% is below %.2f%%\n", coverage, min)
187+
exit 1
188+
}
189+
}
190+
' coverage/lcov.info
174191
- name: Upload coverage to Codacy
175192
if: ${{ matrix.platform == 'vm' }}
176193
continue-on-error: true

0 commit comments

Comments
 (0)