-
Notifications
You must be signed in to change notification settings - Fork 0
196 lines (155 loc) · 5.15 KB
/
Copy pathtest.yml
File metadata and controls
196 lines (155 loc) · 5.15 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
name: CI
on:
push:
pull_request:
jobs:
backend-quality:
name: Backend lint/typecheck
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Set up Python 3.11
uses: actions/setup-python@v6
with:
python-version: "3.11"
- name: Set up uv
uses: astral-sh/setup-uv@v7
with:
enable-cache: true
- name: Install dependencies
run: make python-sync
- name: Check Python lockfile
run: make python-lock-check
- name: Check release version consistency
run: make release-check
- name: Run backend lint
run: make lint
- name: Run release hygiene guard
run: make hygiene
- name: Check document authority
run: make doc-check
- name: Run backend typecheck
run: make typecheck
backend-tests:
name: Backend tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Set up Python 3.11
uses: actions/setup-python@v6
with:
python-version: "3.11"
- name: Set up uv
uses: astral-sh/setup-uv@v7
with:
enable-cache: true
- name: Install dependencies
run: make python-sync
- name: Bootstrap database schema
run: PYTHONPATH=. .venv/bin/python backend/data/database.py
- name: Run backend tests with coverage
run: make coverage
- name: Publish coverage summary
if: always()
run: |
if [ -f coverage.xml ]; then
pct=$(python3 -c "import xml.etree.ElementTree as ET; print(round(float(ET.parse('coverage.xml').getroot().get('line-rate')) * 100, 1))")
echo "### Backend coverage" >> $GITHUB_STEP_SUMMARY
echo "Line coverage: **${pct}%** (gate: fail_under in pyproject.toml)" >> $GITHUB_STEP_SUMMARY
fi
- name: Upload coverage artifact
uses: actions/upload-artifact@v7
with:
name: backend-coverage
path: coverage.xml
python-compat:
name: Python ${{ matrix.python-version }} compatibility
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.12", "3.13"]
steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
- uses: astral-sh/setup-uv@v7
with:
enable-cache: true
- name: Install locked test environment
run: uv sync --frozen --extra test --python ${{ matrix.python-version }}
- name: Run compatibility contract suite
run: >-
PYTHONPATH=. .venv/bin/python -m pytest -q
tests/test_schema_authority.py
tests/test_runtime_identity_and_job_ledger.py
tests/test_m61_p3_research.py
docker:
name: Docker build and health smoke
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Build backend and frontend images
run: |
docker build --target backend -t mingcang-backend:ci .
docker build --target frontend -t mingcang-frontend:ci .
- name: Verify backend container health
run: |
set -euo pipefail
docker run --detach --rm --name mingcang-backend-ci -p 18000:8000 mingcang-backend:ci
trap 'docker logs mingcang-backend-ci || true; docker stop mingcang-backend-ci || true' EXIT
for attempt in $(seq 1 30); do
if curl --fail --silent http://127.0.0.1:18000/health | grep -q '"status":"ok"'; then
exit 0
fi
sleep 2
done
exit 1
security:
name: Security and dependency audit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Set up Python 3.11
uses: actions/setup-python@v6
with:
python-version: "3.11"
- name: Set up uv
uses: astral-sh/setup-uv@v7
with:
enable-cache: true
- name: Install dependencies
run: make python-sync
- name: Run low-noise security snapshot
run: make security
- name: Run dependency audit
run: |
make dependency-audit
echo "### Dependency audit" >> $GITHUB_STEP_SUMMARY
echo "Audit completed at $(date -u '+%Y-%m-%dT%H:%M:%SZ'). No known vulnerabilities found." >> $GITHUB_STEP_SUMMARY
frontend:
name: Frontend test/build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Set up Node
uses: actions/setup-node@v6
with:
node-version: "20"
cache: "npm"
cache-dependency-path: frontend/package-lock.json
- name: Install dependencies
working-directory: frontend
run: npm ci
- name: Install browser runtime
working-directory: frontend
run: npx playwright install --with-deps chromium
- name: Run frontend tests
run: make frontend-test
- name: Run frontend ESLint gate
run: make frontend-lint
- name: Run frontend build
run: make build
- name: Run demo and live-mode browser smoke
run: make frontend-smoke