-
-
Notifications
You must be signed in to change notification settings - Fork 0
71 lines (61 loc) · 2.42 KB
/
codecov.yml
File metadata and controls
71 lines (61 loc) · 2.42 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
name: Code Coverage
on:
push:
branches: [main, 'release/*', 'feature/*']
pull_request:
branches: [main, 'release/*']
permissions:
contents: read
jobs:
coverage:
runs-on: ubuntu-latest
name: Run tests and upload coverage
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: '20'
- name: Install dependencies
run: |
echo "📦 Installing dependencies..."
npm install
echo "✅ Dependencies installed"
- name: Build TypeScript
run: |
echo "🔨 Building TypeScript..."
npm run build
echo "✅ Build complete"
- name: Run tests with coverage
run: |
echo "🧪 Running tests with coverage..."
npm test -- --coverage --coverageReporters=lcov --coverageReporters=json-summary --coverageReporters=text
echo "✅ Tests complete"
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage/lcov.info
flags: unittests
name: codecov-umbrella
fail_ci_if_error: false
verbose: true
- name: Coverage summary
run: |
echo ""
echo "=========================================="
echo "📊 Code Coverage Report"
echo "=========================================="
if [ -f coverage/coverage-summary.json ]; then
echo "✅ Coverage data generated successfully"
echo ""
# Parse and display coverage percentages (single file read)
node -e "const fs = require('fs'); try { const raw = fs.readFileSync('coverage/coverage-summary.json', 'utf8'); const data = JSON.parse(raw); const total = data.total; console.log('Lines: ' + total.lines.pct + '%'); console.log('Statements: ' + total.statements.pct + '%'); console.log('Functions: ' + total.functions.pct + '%'); console.log('Branches: ' + total.branches.pct + '%'); } catch (e) { console.error('⚠️ Error parsing coverage summary: ' + e); process.exit(1); }"
echo ""
echo "📤 Report uploaded to Codecov"
else
echo "⚠️ No coverage summary found"
fi
echo ""
echo "=========================================="