Skip to content

Commit 82a3905

Browse files
refactor GitHub Actions workflow for coverage checks: rename job, streamline steps, and update test script configuration
1 parent 6f938dc commit 82a3905

1 file changed

Lines changed: 8 additions & 59 deletions

File tree

Lines changed: 8 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,11 @@
1-
name: 'Coverage Check'
1+
name: 'TS SDK - Unit Testing'
22

33
on:
44
pull_request:
55
branches:
66
- development
77
- staging
88
- main
9-
push:
10-
branches:
11-
- development
12-
- staging
13-
- main
149

1510
jobs:
1611
coverage:
@@ -19,59 +14,13 @@ jobs:
1914
contents: read
2015
pull-requests: write
2116
checks: write
22-
23-
steps:
24-
- name: Checkout code
25-
uses: actions/checkout@v4
26-
27-
- name: Setup Node.js
28-
uses: actions/setup-node@v4
29-
with:
30-
node-version: '18'
31-
cache: 'npm'
3217

33-
- name: Install dependencies
34-
run: npm ci
35-
36-
- name: Jest Coverage Report
37-
if: github.event_name == 'pull_request'
38-
uses: artiomtr/jest-coverage-report-action@v2
39-
with:
40-
github-token: ${{ secrets.GITHUB_TOKEN }}
41-
test-script: npm test -- --coverage --testMatch="**/test/unit/**/*.spec.ts"
42-
threshold: 95
43-
working-directory: ./
44-
package-manager: npm
45-
annotations: failed-tests
46-
coverage-file: ./coverage/coverage-summary.json
47-
base-coverage-file: ./coverage/coverage-summary.json
48-
skip-step: install
49-
50-
- name: Run unit tests with coverage (for push events)
51-
if: github.event_name == 'push'
52-
run: npm test -- --coverage --testMatch="**/test/unit/**/*.spec.ts" --coverageReporters=json-summary --coverageReporters=text
53-
54-
- name: Verify coverage threshold
55-
run: |
56-
COVERAGE=$(node -pe "
57-
const c = JSON.parse(require('fs').readFileSync('coverage/coverage-summary.json')).total;
58-
const threshold = 95;
59-
const metrics = ['statements', 'branches', 'functions', 'lines'];
60-
const failed = metrics.filter(m => c[m].pct < threshold);
61-
if (failed.length) {
62-
console.log('❌ Coverage below 95%: ' + failed.join(', '));
63-
process.exit(1);
64-
}
65-
console.log('✅ All coverage metrics meet the 95% threshold');
66-
")
18+
steps:
19+
- uses: actions/checkout@v4
6720

68-
- name: Upload coverage reports
69-
if: always()
70-
uses: actions/upload-artifact@v4
21+
- name: Run unit tests with coverage
22+
uses: ArtiomTr/jest-coverage-report-action@v2
23+
id: coverage
7124
with:
72-
name: coverage-report
73-
path: |
74-
coverage/
75-
reports/
76-
retention-days: 30
77-
25+
test-script: npm run test:unit
26+
threshold: 95

0 commit comments

Comments
 (0)