-
Notifications
You must be signed in to change notification settings - Fork 0
232 lines (190 loc) · 6.99 KB
/
Copy pathci.yml
File metadata and controls
232 lines (190 loc) · 6.99 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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
name: CI
"on":
push:
branches: [main]
pull_request:
branches: ['**']
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
# ============================================================================
# LAYER 1: Fast feedback (~1-2 min)
# ============================================================================
pre-commit:
name: Pre-commit hooks
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: read
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6
with:
python-version: "3.12"
- uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v5
with:
path: ~/.cache/pre-commit
key: pre-commit-${{ env.pythonLocation }}-${{ hashFiles('.pre-commit-config.yaml') }}
- run: pip install pre-commit
- run: pre-commit run --show-diff-on-failure --color=always --all-files
# ============================================================================
# LAYER 2: Testing
# CI = all Python versions on Linux only (minimal, cheap: 1x minutes).
# macOS (10x) / Windows (2x) spot-checks run at RELEASE time in cd.yml
# (pre-release-tests), not on every push.
# ============================================================================
test:
name: Test (Python ${{ matrix.python-version }} / ${{ matrix.os }})
needs: [pre-commit]
runs-on: ${{ matrix.os }}
timeout-minutes: 20
permissions:
contents: read
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
python-version: ['3.11', '3.12', '3.13']
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6
with:
python-version: ${{ matrix.python-version }}
- uses: astral-sh/setup-uv@d31148d669074a8d0a63714ba94f3201e7020bc3 # v8.3.0
with:
enable-cache: true
- name: Install dependencies
run: uv pip install -e ".[dev,gui]" --system
- name: Check dependency hygiene (deptry)
if: runner.os == 'Linux' && matrix.python-version == '3.12'
run: deptry src tests
- name: Run tests with coverage
shell: bash
run: |
pytest tests/ -v \
--cov=src/certamen \
--cov-report=xml \
--cov-report=term-missing \
--cov-branch \
--junitxml=test-results.xml
- name: Enforce coverage threshold
if: runner.os == 'Linux' && matrix.python-version == '3.12'
run: coverage report --fail-under=30
- name: Upload coverage report
if: runner.os == 'Linux' && matrix.python-version == '3.12'
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: coverage-report
path: |
coverage.xml
test-results.xml
retention-days: 1
# ============================================================================
# LAYER 3: Quality analysis (non-blocking, main only)
# ============================================================================
mutation-testing:
name: Mutation Testing
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
timeout-minutes: 30
continue-on-error: true
permissions:
contents: read
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6
with:
python-version: "3.12"
- uses: astral-sh/setup-uv@d31148d669074a8d0a63714ba94f3201e7020bc3 # v8.3.0
with:
enable-cache: true
- name: Install dependencies
run: |
uv pip install -e ".[dev]" --system
uv pip install pytest-timeout --system
- name: Run mutation testing
env:
PYTHONPATH: ${{ github.workspace }}/src
run: |
echo "=== Running Mutation Testing ==="
cd ${{ github.workspace }}
mutmut run || true
- name: Generate mutation report
run: |
echo "=== Mutation Testing Results ==="
mutmut results || true
echo ""
echo "=== Survived Mutants ==="
mutmut results --survived 2>/dev/null || true
complexity-checks:
name: Complexity & Maintainability
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: read
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6
with:
python-version: "3.12"
- run: pip install radon
- name: Check cyclomatic complexity
run: |
echo "=== Cyclomatic Complexity Report ==="
radon cc src/certamen/ --min B --show-complexity --total-average
- name: Check maintainability index
run: |
echo "=== Maintainability Index Report ==="
radon mi src/certamen/ --min B --show
- name: Fail on high complexity
run: |
radon cc src/certamen/ --min C --total-average || \
(echo "::warning::High complexity detected (grade C or worse)" && exit 0)
architecture-checks:
name: Architecture & Import Contracts
runs-on: ubuntu-latest
timeout-minutes: 10
continue-on-error: true
permissions:
contents: read
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6
with:
python-version: "3.12"
- uses: astral-sh/setup-uv@d31148d669074a8d0a63714ba94f3201e7020bc3 # v8.3.0
with:
enable-cache: true
- name: Install dependencies
run: |
uv pip install -e . --system
uv pip install import-linter --system
- name: Validate architecture
run: lint-imports || echo "::warning::Architecture violations detected"
frontend:
name: Frontend (Biome + types)
needs: [pre-commit]
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: read
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: "22"
cache: npm
cache-dependency-path: frontend/package-lock.json
- name: Install dependencies
run: npm ci
working-directory: frontend
- name: Biome check (lint + format)
run: npx biome ci .
working-directory: frontend
- name: Type check
run: npx tsc -b
working-directory: frontend
- name: Unit tests (Vitest)
run: npx vitest run
working-directory: frontend