-
Notifications
You must be signed in to change notification settings - Fork 0
158 lines (133 loc) · 4.63 KB
/
test.yml
File metadata and controls
158 lines (133 loc) · 4.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
name: Test Pipeline
on:
push:
branches: [main]
pull_request:
branches: [main]
env:
CI: true
NODE_ENV: test
jobs:
test:
name: Run Tests
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22.x
cache: "npm"
- name: Install dependencies
run: npm ci
- name: Run tests
run: npm run test -- --run
- name: Run tests with coverage
run: npm run test -- --run --coverage
- name: Check coverage thresholds
run: |
echo "Checking coverage thresholds..."
npm run test -- --run --coverage --reporter=json > coverage-report.json 2>/dev/null || true
node -e "
try {
const fs = require('fs');
const coverage = JSON.parse(fs.readFileSync('coverage/coverage-summary.json', 'utf8'));
const total = coverage.total;
console.log('Coverage Summary:');
console.log('Lines:', total.lines.pct + '%');
console.log('Functions:', total.functions.pct + '%');
console.log('Branches:', total.branches.pct + '%');
console.log('Statements:', total.statements.pct + '%');
// Thresholds matching vitest.config.js
const thresholds = { lines: 45, functions: 60, branches: 75, statements: 45 };
let failed = false;
if (total.lines.pct < thresholds.lines) {
console.log('❌ Lines coverage (' + total.lines.pct + '%) below threshold (' + thresholds.lines + '%)');
failed = true;
}
if (total.functions.pct < thresholds.functions) {
console.log('❌ Functions coverage (' + total.functions.pct + '%) below threshold (' + thresholds.functions + '%)');
failed = true;
}
if (total.branches.pct < thresholds.branches) {
console.log('❌ Branches coverage (' + total.branches.pct + '%) below threshold (' + thresholds.branches + '%)');
failed = true;
}
if (total.statements.pct < thresholds.statements) {
console.log('❌ Statements coverage (' + total.statements.pct + '%) below threshold (' + thresholds.statements + '%)');
failed = true;
}
if (failed) {
process.exit(1);
} else {
console.log('✅ Coverage meets threshold requirements');
}
} catch (err) {
console.log('Coverage check skipped - no coverage data available');
}
"
- name: Upload coverage report
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: coverage/
retention-days: 30
- name: Comment coverage on PR
uses: romeovs/lcov-reporter-action@v0.3.1
if: github.event_name == 'pull_request'
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
lcov-file: ./coverage/lcov.info
delete-old-comments: true
continue-on-error: true
- name: Coverage summary
run: |
echo "## Coverage Summary" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
cat coverage/coverage-summary.json 2>/dev/null | jq '.' || echo "Coverage summary not available"
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
lint:
name: Code Quality
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22.x
cache: "npm"
- name: Install dependencies
run: npm ci
- name: Run linting
run: npm run lint
continue-on-error: true
- name: Check formatting
run: npm run format:check
continue-on-error: true
build:
name: Build Check
runs-on: ubuntu-latest
timeout-minutes: 5
needs: test
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22.x
cache: "npm"
- name: Install dependencies
run: npm ci
- name: Build
run: npm run build
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: build-output
path: dist/
retention-days: 7