-
-
Notifications
You must be signed in to change notification settings - Fork 43
81 lines (68 loc) · 2.57 KB
/
node.js.yml
File metadata and controls
81 lines (68 loc) · 2.57 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
name: Node.js CI
on:
push:
branches: [ development ]
pull_request:
branches: [ development ]
jobs:
lint:
name: Lint Check
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Use Node.js 20.17.0
uses: actions/setup-node@v4
with:
node-version: 20.17.0
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run lint
run: npm run lint
test:
name: Tests with 10% Coverage Enforcement
runs-on: ubuntu-latest
needs: lint
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Use Node.js 20.17.0
uses: actions/setup-node@v4
with:
node-version: 20.17.0
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run tests with coverage enforcement
run: npm run test:ci
- name: Print detailed coverage report
if: always()
run: |
echo "📊 COVERAGE ENFORCEMENT REPORT 📊"
echo "=================================="
echo "Minimum Required: Lines: 34%, Statements: 34%, Functions: 27%, Branches: 12%"
echo "=================================="
if [ -f coverage/coverage-summary.json ]; then
node -e "
const coverage = require('./coverage/coverage-summary.json');
const { lines, statements, functions, branches } = coverage.total;
console.log('📈 CURRENT COVERAGE:');
console.log(\`📄 Lines: \${lines.pct}% \${lines.pct >= 34 ? '✅ PASS' : '❌ FAIL'}\`);
console.log(\`📝 Statements: \${statements.pct}% \${statements.pct >= 34 ? '✅ PASS' : '❌ FAIL'}\`);
console.log(\`🔧 Functions: \${functions.pct}% \${functions.pct >= 27 ? '✅ PASS' : '❌ FAIL'}\`);
console.log(\`🌿 Branches: \${branches.pct}% \${branches.pct >= 12 ? '✅ PASS' : '❌ FAIL'}\`);
const allPass = [lines, statements, functions, branches].every(metric => metric.pct >= 60);
console.log('================================');
console.log(\`🎯 OVERALL: \${allPass ? '✅ COVERAGE REQUIREMENTS MET' : '❌ COVERAGE REQUIREMENTS FAILED'}\`);
console.log('================================');
"
else
echo "❌ No coverage report generated"
fi
- name: Upload coverage report
if: always()
uses: actions/upload-artifact@v4
with:
name: backend-coverage-report
path: coverage/