-
Notifications
You must be signed in to change notification settings - Fork 63
121 lines (115 loc) · 4.01 KB
/
Copy pathcode-quality.yml
File metadata and controls
121 lines (115 loc) · 4.01 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
name: Code Quality
on:
push:
branches: [main, develop]
pull_request:
branches: [main]
workflow_dispatch:
permissions:
contents: read
checks: write
concurrency:
group: quality-${{ github.ref }}
cancel-in-progress: true
jobs:
# ---------------------------------------------------------------
# Backend coverage + quality
# ---------------------------------------------------------------
backend-quality:
name: Backend Coverage
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install dependencies
run: cd backend && npm install
- name: Generate Prisma client
run: cd backend && npx prisma generate || true
- name: Run tests with coverage
run: cd backend && npm run test:coverage || echo "⚠️ Coverage warnings (non-blocking)"
env:
NODE_ENV: test
- name: Check coverage threshold
run: |
cd backend
if [ -f coverage/coverage-summary.json ]; then
COVERAGE=$(node -pe "Math.round(JSON.parse(require('fs').readFileSync('coverage/coverage-summary.json', 'utf8')).total.lines.pct)")
echo "Backend line coverage: ${COVERAGE}%"
if [ "$COVERAGE" -lt 50 ]; then
echo "::error::Backend coverage ${COVERAGE}% is below 50% threshold"
exit 1
fi
echo "✅ Backend coverage ${COVERAGE}% meets threshold"
else
echo "::warning::No coverage summary found"
fi
- name: Upload coverage artifact
if: always()
uses: actions/upload-artifact@v4
with:
name: backend-quality-coverage
path: backend/coverage/
retention-days: 30
# ---------------------------------------------------------------
# Frontend coverage + quality
# ---------------------------------------------------------------
frontend-quality:
name: Frontend Coverage
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install dependencies
run: cd frontend && npm install
- name: Run tests with coverage
continue-on-error: true
run: cd frontend && npm run test:coverage || echo "⚠️ Coverage warnings (non-blocking)"
- name: Check coverage threshold
run: |
cd frontend
if [ -f coverage/coverage-summary.json ]; then
COVERAGE=$(node -pe "Math.round(JSON.parse(require('fs').readFileSync('coverage/coverage-summary.json', 'utf8')).total.lines.pct)")
echo "Frontend line coverage: ${COVERAGE}%"
if [ "$COVERAGE" -lt 15 ]; then
echo "::error::Frontend coverage ${COVERAGE}% is below 50% threshold"
exit 1
fi
echo "✅ Frontend coverage ${COVERAGE}% meets threshold"
else
echo "::warning::No coverage summary found"
fi
- name: Upload coverage artifact
if: always()
uses: actions/upload-artifact@v4
with:
name: frontend-quality-coverage
path: frontend/coverage/
retention-days: 30
# ---------------------------------------------------------------
# Code format check (non-blocking lint)
# ---------------------------------------------------------------
format-check:
name: Code Format Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Backend lint check
run: |
cd backend
npm install
npm run lint:check || echo "⚠️ Backend lint warnings (non-blocking)"
- name: Frontend lint check
run: |
cd frontend
npm install
npm run lint || echo "⚠️ Frontend lint warnings (non-blocking)"