Skip to content

Commit 763c4e6

Browse files
committed
ci: enhance coverage reporting in GitHub Actions workflow and update Jest configuration
1 parent 9e12f1f commit 763c4e6

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

.github/workflows/test.yml

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,28 @@ jobs:
3232
- name: Setup
3333
uses: ./.github/actions/setup
3434

35-
- name: Run unit tests
35+
- name: Run unit tests with coverage
3636
run: yarn test:coverage --maxWorkers=2
3737

38+
- name: Check coverage thresholds
39+
run: |
40+
COVERAGE_THRESHOLD=80
41+
COVERAGE=$(cat coverage/coverage-summary.json | jq -r '.total.lines.pct')
42+
if (( $(echo "$COVERAGE < $COVERAGE_THRESHOLD" | bc -l) )); then
43+
echo "Coverage ($COVERAGE%) is below threshold ($COVERAGE_THRESHOLD%)"
44+
exit 1
45+
fi
46+
echo "Coverage ($COVERAGE%) is above threshold ($COVERAGE_THRESHOLD%)"
47+
48+
- name: Upload coverage to Codecov
49+
uses: codecov/codecov-action@v4
50+
with:
51+
token: ${{ secrets.CODECOV_TOKEN }}
52+
directory: ./coverage/
53+
flags: unittests
54+
name: codecov-umbrella
55+
fail_ci_if_error: true
56+
3857
build-library:
3958
runs-on: ubuntu-latest
4059
steps:

jest.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ module.exports = {
1010
'!plugin/src/**/__mocks__/**',
1111
],
1212
coverageDirectory: 'coverage',
13-
coverageReporters: ['text', 'lcov', 'html'],
13+
coverageReporters: ['text', 'lcov', 'html', 'json-summary'],
1414
coverageThreshold: {
1515
global: {
1616
branches: 80,

0 commit comments

Comments
 (0)