Repository navigation
192 lines (163 loc) · 5.65 KB
/
Copy pathci.yml
File metadata and controls
192 lines (163 loc) · 5.65 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
name: CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@main
- name: Install uv
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b
with:
version: "latest"
enable-cache: true
save-cache: false
- name: Run ruff linter
run: uv run ruff check .
- name: Run ruff formatter check
run: uv run ruff format --check .
type-check:
name: Type Check
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@main
- name: Install uv
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b
with:
version: "latest"
enable-cache: true
cache-dependency-glob: |
**/*requirements*.txt
**/*requirements*.in
**/*constraints*.txt
**/*constraints*.in
**/pyproject.toml
**/uv.lock
**/*.py.lock
- name: Install dependencies
run: uv sync --all-groups
- name: Run mypy
run: uv run mypy src/
security:
name: Security Scan
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@main
- name: Install uv
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b
with:
version: "latest"
enable-cache: true
save-cache: false
- name: Install dependencies
run: uv sync --all-groups
- name: Run bandit (code-level static security scan)
run: uv run bandit -r src/ -c pyproject.toml
# pip-audit: dependency-level vulnerability scan. Replaces `safety`,
# which requires interactive login and hangs in CI. Audits the fully
# resolved environment against the PyPI Advisory Database; fails the job
# if a known vulnerability with an available fix is present. Dependabot
# still surfaces advisories on GitHub; this enforces them in CI.
- name: Run pip-audit (dependency vulnerability scan)
run: uv run pip-audit
test:
name: Test (Python ${{ matrix.python-version }}, ${{ matrix.os }})
needs: [ type-check ]
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest, macos-latest ]
# 3.14t (free-threaded) excluded — not reliably available on hosted runners.
python-version: [ "3.10", "3.11", "3.12", "3.13", "3.14" ]
exclude:
# Python 3.14 not yet available on macOS runners
- os: macos-latest
python-version: "3.14"
steps:
- name: Checkout repository
uses: actions/checkout@main
- name: Install uv
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b
with:
version: "latest"
enable-cache: true
cache-dependency-glob: |
**/*requirements*.txt
**/*requirements*.in
**/*constraints*.txt
**/*constraints*.in
**/pyproject.toml
**/uv.lock
**/*.py.lock
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: uv sync --all-groups
- name: Run tests
run: uv run --group test pytest
env:
# Deterministic hashing so every xdist worker collects tests in the
# same order (avoids "Different tests collected between gwN and gwM"
# when a parametrize source iterates a set/dict).
PYTHONHASHSEED: "0"
- name: Stage coverage data
# Copy the data file to a NON-hidden name: upload-artifact@v4 globs
# don't reliably match dotfiles (.coverage*). `coverage combine || true`
# tolerates "no data to combine" when pytest-cov already merged.
run: |
uv run coverage combine || true
cp .coverage "covdata-${{ matrix.os }}-py${{ matrix.python-version }}"
- name: Upload coverage data
uses: actions/upload-artifact@v6
with:
name: coverage-${{ matrix.os }}-py${{ matrix.python-version }}
path: covdata-*
if-no-files-found: error
retention-days: 7
coverage:
name: Coverage Report
needs: [ test ]
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@main
- name: Install uv
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b
with:
version: "latest"
- name: Install dependencies
run: uv sync --all-groups
- name: Download coverage data
uses: actions/download-artifact@v6
with:
pattern: coverage-*
path: coverage-reports
merge-multiple: true
- name: Combine coverage
# Explicit file args (not a bare dir) so the non-hidden covdata-* files
# combine regardless of the `.coverage*` naming convention.
run: uv run coverage combine coverage-reports/*
- name: Generate coverage report
run: |
uv run coverage report --fail-under=80
uv run coverage html -d reports/coverage
uv run coverage xml -o reports/coverage.xml
- name: Upload combined coverage
uses: actions/upload-artifact@v4
with:
name: html-coverage-report
path: reports/coverage/
retention-days: 30