-
Notifications
You must be signed in to change notification settings - Fork 0
293 lines (245 loc) · 7.2 KB
/
Copy pathci.yml
File metadata and controls
293 lines (245 loc) · 7.2 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
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
name: CI
on:
push:
branches: ["**"]
pull_request:
branches: ["**"]
workflow_dispatch:
permissions:
contents: read
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
jobs:
lint:
name: Lint (ruff, py311)
runs-on: ubuntu-latest
timeout-minutes: 15
env:
PYTHONPATH: src
UV_HTTP_TIMEOUT: 120
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
enable-cache: true
- name: Sync dependencies with uv
run: |
uv sync --frozen
- name: Show environment
run: |
uv --version
python --version
- name: Install ruff
run: |
uv pip install ruff
- name: Lint with ruff
run: |
uv run ruff check src
test:
name: Test (Python ${{ matrix.python-version }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11", "3.12"]
timeout-minutes: 25
env:
PYTHONPATH: src
UV_HTTP_TIMEOUT: 120
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
enable-cache: true
- name: Sync dependencies with uv
run: |
uv sync --frozen
- name: Show environment
run: |
uv --version
python --version
- name: Run tests with coverage
shell: bash
run: |
uv pip install pytest coverage
set +e
# Run pytest under coverage; only measure project sources under src/ and
# ignore proxy_test.py, which expects a local SOCKS proxy (Tor).
uv run coverage run --source=src -m pytest --ignore=proxy_test.py
rc=$?
set -e
if [ "$rc" -eq 5 ]; then
echo "No tests collected. Skipping pytest."
exit 0
fi
# Show coverage summary in CI logs and enforce minimum threshold
uv run coverage report -m --fail-under=30
# Export XML report for artifacts or external tools
uv run coverage xml -o coverage.xml
exit "$rc"
- name: Upload coverage report
if: always()
uses: actions/upload-artifact@v4
with:
name: coverage-${{ matrix.python-version }}
path: coverage.xml
typecheck:
name: Type check (mypy, py311)
runs-on: ubuntu-latest
needs: [lint]
timeout-minutes: 15
env:
PYTHONPATH: src
UV_HTTP_TIMEOUT: 120
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
enable-cache: true
- name: Sync dependencies with uv
run: |
uv sync --frozen
- name: Run mypy
run: |
uv pip install mypy
uv run mypy
build:
name: Build checks (py311)
runs-on: ubuntu-latest
needs: [lint, test, typecheck]
timeout-minutes: 20
env:
PYTHONPATH: src
UV_HTTP_TIMEOUT: 120
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
enable-cache: true
- name: Sync dependencies with uv
run: |
uv sync --frozen
- name: Show environment
run: |
uv --version
python --version
- name: Syntax check (compile all)
run: |
uv run python -m compileall -q src scripts
- name: Verify core packages importable
shell: bash
run: |
uv run python - <<'PY'
import sys, importlib
sys.path.append('src')
for pkg in ("helpers", "scrapers", "runpod", "ui", "db"):
importlib.import_module(pkg)
print("Core packages imported successfully")
# Verify database module works
from db import init_db, get_setting, set_setting
init_db()
set_setting("ci.test", "ok")
assert get_setting("ci.test") == "ok"
print("Database module verified")
PY
security:
name: Dependency audit (pip-audit)
runs-on: ubuntu-latest
needs: [lint, test]
timeout-minutes: 20
env:
UV_HTTP_TIMEOUT: 120
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
enable-cache: true
- name: Sync dependencies with uv
run: |
uv sync --frozen
- name: Run pip-audit
shell: bash
run: |
uv pip install pip-audit
# Audit the installed environment for known vulnerabilities.
# Ignore specific CVEs that are currently present only via transitive
# dependencies and tracked separately:
# - CVE-2025-6176 (brotli 1.1.0; fixed in 1.2.0)
# - CVE-2025-62727 (starlette 0.48.0; fixed in 0.49.1)
# - CVE-2025-66418 (urllib3 2.5.0; fixed in 2.6.0)
# - CVE-2025-66471 (urllib3 2.5.0; fixed in 2.6.0)
# - GHSA-f83h-ghpp-7wcc (pdfminer-six <=20251107; no fix yet, local privesc only)
# All other vulnerabilities will still cause this job to fail.
uv run pip-audit \
--ignore-vuln CVE-2025-6176 \
--ignore-vuln CVE-2025-62727 \
--ignore-vuln CVE-2025-66418 \
--ignore-vuln CVE-2025-66471 \
--ignore-vuln GHSA-f83h-ghpp-7wcc
docs:
name: Docs (format, links, spelling)
runs-on: ubuntu-latest
needs: [lint]
timeout-minutes: 15
env:
UV_HTTP_TIMEOUT: 120
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
enable-cache: true
- name: Sync dependencies with uv
run: |
uv sync --frozen
- name: Install docs tooling
run: |
uv pip install mdformat codespell
- name: Check Markdown formatting (mdformat)
run: |
uv run mdformat --check README.md docs
- name: Spell-check docs (codespell)
run: |
uv run codespell README.md docs
- name: Check documentation links (lychee)
uses: lycheeverse/lychee-action@v2
with:
args: --no-progress --exclude https://huggingface.co/settings/tokens --exclude https://www.reddit.com/r/LocalLLaMA/ README.md docs/**/*.md
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}