-
Notifications
You must be signed in to change notification settings - Fork 0
184 lines (146 loc) · 4.98 KB
/
ci.yml
File metadata and controls
184 lines (146 loc) · 4.98 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
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
permissions:
contents: read
jobs:
test:
name: Test (Python ${{ matrix.python-version }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.12", "3.13"]
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v4
with:
enable-cache: true
- name: Set up Python ${{ matrix.python-version }}
run: uv python install ${{ matrix.python-version }}
- name: Install dependencies
run: uv sync --extra dev --extra pydantic
- name: Run tests with coverage
# Exclude tests/perf — those run in the dedicated memory-check job.
run: uv run pytest tests/ --ignore=tests/perf --cov=hawkapi --cov-report=xml -q
- name: Upload coverage
if: matrix.python-version == '3.13'
uses: codecov/codecov-action@v4
with:
file: coverage.xml
fail_ci_if_error: false
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v4
with:
enable-cache: true
- name: Set up Python
run: uv python install 3.13
- name: Install dependencies
run: uv sync --extra dev --extra pydantic
- name: Ruff check
run: uv run ruff check src/ tests/
- name: Ruff format check
run: uv run ruff format --check src/ tests/
typecheck:
name: Type check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v4
with:
enable-cache: true
- name: Set up Python
run: uv python install 3.13
- name: Install dependencies
run: uv sync --extra dev --extra pydantic --extra uvicorn --extra metrics --extra logging
- name: Pyright
run: uv run pyright src/
memory-check:
name: Memory Budget Check
# pytest-memray supports Linux and macOS only — never run on Windows.
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v4
with:
enable-cache: true
- name: Set up Python 3.13
run: uv python install 3.13
- name: Install dependencies
run: uv sync --extra dev
- name: Run memory budget tests
run: uv run pytest tests/perf/ -m memory --memray --memray-bin-path=/tmp -v
- name: Upload memray binary artefacts
if: always()
uses: actions/upload-artifact@v4
with:
name: memray-bin
path: /tmp/*.bin
if-no-files-found: ignore
retention-days: 7
perf-regression:
name: Performance Regression Gate
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
# Need history so the committed baseline JSON is available.
fetch-depth: 0
- name: Install uv
uses: astral-sh/setup-uv@v4
with:
enable-cache: true
- name: Set up Python 3.13
run: uv python install 3.13
- name: Install dependencies
run: uv sync --extra dev
- name: Run performance regression tests
# Compares each benchmark's mean against the committed baseline and
# fails the job if any hot path regresses by more than 5%.
run: |
uv run pytest tests/perf/ -m perf --benchmark-only \
--benchmark-compare=tests/perf/.benchmark_baseline.json \
--benchmark-compare-fail=mean:5% \
--benchmark-columns=min,mean,median,stddev,rounds
- name: Upload benchmark artefacts
if: always()
uses: actions/upload-artifact@v4
with:
name: perf-benchmarks
path: .benchmarks/
if-no-files-found: ignore
retention-days: 30
test-free-threaded:
name: Test (Python 3.13 free-threaded, experimental)
# Non-blocking: surfaces regressions without gating merges.
runs-on: ubuntu-latest
continue-on-error: true
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v4
with:
enable-cache: true
- name: Set up Python 3.13 free-threaded
# uv supports the free-threaded CPython build via the 't' suffix.
run: uv python install 3.13t
- name: Verify interpreter is actually free-threaded
# Fail fast if `uv python install 3.13t` silently resolved to a
# GIL-enabled 3.13 interpreter. Without this guard the rest of the
# job would still pass but for the wrong reason.
run: uv run --python 3.13t python -c "import sys; assert not sys._is_gil_enabled(), 'expected no-GIL interpreter'"
- name: Install dependencies
run: uv sync --python 3.13t --extra dev --extra pydantic
- name: Run unit tests
run: uv run --python 3.13t pytest tests/unit -x --tb=short -q