-
Notifications
You must be signed in to change notification settings - Fork 2
435 lines (374 loc) · 13.3 KB
/
Copy pathci.yml
File metadata and controls
435 lines (374 loc) · 13.3 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
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
name: CI
on:
push:
branches:
- main
pull_request:
branches:
- "**"
jobs:
workflow-lint:
name: Workflow lint (actionlint)
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Lint GitHub workflow files
uses: rhysd/actionlint@v1.7.12
dependency-audit:
name: Dependency audit (uv audit)
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Set up uv
uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39
with:
python-version: "3.12"
enable-cache: true
- name: Audit dependencies for vulnerabilities
run: |
uv audit
docs-touch-gate:
name: Docs touch gate
runs-on: ubuntu-latest
if: ${{ github.event_name == 'pull_request' }}
permissions:
pull-requests: read
steps:
- name: Detect code/docs file changes
id: changes
uses: dorny/paths-filter@v4
with:
filters: |
code:
- 'src/**'
docs:
- 'docs/**'
- 'README.md'
- 'CHANGELOG.md'
- 'CONTRIBUTING.md'
- name: Enforce docs update for code changes
uses: actions/github-script@v9
env:
CODE_CHANGED: ${{ steps.changes.outputs.code }}
DOCS_CHANGED: ${{ steps.changes.outputs.docs }}
with:
script: |
// Labels must be fetched via the REST API. Re-runs and the event
// payload still reflect labels as-of the original `pull_request`
// event, so `no-docs` added after the first run would otherwise
// never be seen.
const pr = context.payload.pull_request;
if (!pr) {
core.setFailed("Expected pull_request payload.");
return;
}
const { data } = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: pr.number,
});
const labels = (data.labels ?? []).map((l) => l.name);
const hasSkipLabel = labels.includes("no-docs") || labels.includes("internal-only");
const codeChanged = process.env.CODE_CHANGED === "true";
const docsChanged = process.env.DOCS_CHANGED === "true";
if (!codeChanged) {
core.info("No src/ changes detected; docs-touch gate passes.");
return;
}
if (docsChanged) {
core.info("Code and docs changed together; docs-touch gate passes.");
return;
}
if (hasSkipLabel) {
core.info(
"No docs changes, but PR has no-docs/internal-only label; docs-touch gate passes."
);
return;
}
core.setFailed(
"This PR changes src/ without docs updates. " +
"Update docs/README/CHANGELOG/CONTRIBUTING, or apply the " +
"`no-docs`/`internal-only` label with reviewer approval."
);
newsfragment-naming:
name: News fragment naming (ID + KAC type)
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.12"
- name: Validate all newsfragments
run: |
python scripts/validate_newsfragments.py
- name: On PR, changed fragments must match this PR number
if: github.event_name == 'pull_request'
run: |
python scripts/validate_newsfragments.py \
--pr "${{ github.event.number }}" \
--diff "${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }}"
towncrier-fragment-gate:
name: Changelog fragment gate (Towncrier)
runs-on: ubuntu-latest
if: ${{ github.event_name == 'pull_request' }}
permissions:
pull-requests: read
steps:
- name: Detect source and fragment changes
id: changes
uses: dorny/paths-filter@v4
with:
filters: |
code:
- 'src/**'
- '.github/workflows/**'
- 'pyproject.toml'
fragment:
- 'newsfragments/*.added.md'
- 'newsfragments/*.changed.md'
- 'newsfragments/*.deprecated.md'
- 'newsfragments/*.removed.md'
- 'newsfragments/*.fixed.md'
- 'newsfragments/*.security.md'
changelog:
- 'CHANGELOG.md'
- name: Enforce changelog fragment for code changes
uses: actions/github-script@v9
env:
CODE_CHANGED: ${{ steps.changes.outputs.code }}
FRAGMENT_CHANGED: ${{ steps.changes.outputs.fragment }}
CHANGELOG_CHANGED: ${{ steps.changes.outputs.changelog }}
with:
script: |
const pr = context.payload.pull_request;
if (!pr) {
core.setFailed("Expected pull_request payload.");
return;
}
const { data } = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: pr.number,
});
const labels = (data.labels ?? []).map((l) => l.name);
const hasSkipLabel = labels.includes("skip-changelog") || labels.includes("internal-only");
const codeChanged = process.env.CODE_CHANGED === "true";
const fragmentChanged = process.env.FRAGMENT_CHANGED === "true";
const changelogChanged = process.env.CHANGELOG_CHANGED === "true";
if (!codeChanged) {
core.info("No relevant code/workflow changes; fragment gate passes.");
return;
}
if (fragmentChanged || changelogChanged) {
core.info("Fragment/changelog update detected; fragment gate passes.");
return;
}
if (hasSkipLabel) {
core.info(
"No changelog fragment, but PR has skip-changelog/internal-only label; gate passes."
);
return;
}
core.setFailed(
"This PR changes code/workflows without a changelog fragment. " +
"Add newsfragments/<PR>.(added|changed|deprecated|removed|fixed|security).md, update CHANGELOG.md, " +
"or apply `skip-changelog`/`internal-only` with reviewer approval."
);
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Set up uv
uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39
with:
python-version: "3.12"
enable-cache: true
- name: Sync dependencies
run: |
uv sync --locked --dev
- name: Lint
run: |
uv run ruff check .
- name: Format
run: |
uv run ruff format --check .
type-check:
name: Type Check
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Set up uv
uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39
with:
python-version: "3.12"
enable-cache: true
- name: Sync dependencies
run: |
uv sync --locked --dev
- name: Type check
run: |
uv run ty check .
test:
name: Tests (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
- os: windows-latest
- os: macos-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Set up uv
uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39
with:
python-version: "3.12"
enable-cache: true
- name: Sync dependencies
run: |
uv sync --locked --dev
# PySide6 links libEGL even for offscreen; ubuntu-latest images omit it by default.
- name: Install Qt EGL/XCB dependencies (Ubuntu only)
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
libegl1 \
libgl1 \
libxkbcommon0 \
libdbus-1-3
- name: Run pytest
env:
QT_QPA_PLATFORM: offscreen
run: |
uv run pytest --cov-fail-under=48
prose-lint:
name: Prose lint (codespell + doc8 + interrogate)
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Set up uv
uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39
with:
python-version: "3.12"
enable-cache: true
- name: Run pre-commit (prose hooks)
run: |
uv run pre-commit run --all-files codespell
uv run pre-commit run --all-files doc8
uv run pre-commit run --all-files interrogate
docs:
name: Docs (build + linkcheck)
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Set up uv
uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39
with:
python-version: "3.12"
enable-cache: true
# autosummary imports dbs_annotator modules that transitively touch
# PySide6; ubuntu-latest images omit the EGL/XCB libs that PySide6 needs
# even under QT_QPA_PLATFORM=offscreen.
- name: Install Qt EGL/XCB dependencies
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
libegl1 \
libgl1 \
libxkbcommon0 \
libdbus-1-3
- name: Sync docs dependency group
run: |
uv sync --locked --group docs --no-dev
- name: Verify generated TSV schema docs are up to date
run: |
uv run python scripts/generate_tsv_schema_docs.py --check
- name: Build HTML docs (warnings are errors)
env:
QT_QPA_PLATFORM: offscreen
MPLBACKEND: Agg
run: |
uv run sphinx-build -b html -W --keep-going docs docs/_build/html
- name: Link check (non-blocking)
continue-on-error: true
env:
QT_QPA_PLATFORM: offscreen
MPLBACKEND: Agg
run: |
uv run sphinx-build -b linkcheck docs docs/_build/linkcheck
- name: Upload rendered HTML artifact
uses: actions/upload-artifact@v7
with:
name: docs-html-${{ github.sha }}
path: docs/_build/html
if-no-files-found: error
- name: Upload linkcheck report
if: always()
uses: actions/upload-artifact@v7
with:
name: docs-linkcheck-${{ github.sha }}
path: docs/_build/linkcheck
if-no-files-found: warn
# Briefcase smoke test. Intentionally runs on Ubuntu (not Windows) and
# skips `briefcase package`, because:
# - ~80% of Briefcase regressions (bad [tool.briefcase] config, missing
# runtime deps, stale icon/stub paths, undeclared resources) are
# platform-agnostic and caught by `create` + `build`.
# - Packaging is the slowest step and rarely fails when build succeeds.
# - The tagged-release workflow (release.yml) fully exercises
# `create + build + package` for Windows MSI, macOS DMG, and Linux
# system packages, so platform-specific packaging regressions cannot
# reach a release without being caught there.
# The result is a PR-gated smoke test that runs in ~1-2 min instead of
# ~3-4 min on a Windows runner.
briefcase-smoke:
name: Briefcase smoke test (Linux)
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Set up uv
uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39
with:
python-version: "3.12"
enable-cache: true
# PySide6 links libEGL even for offscreen; ubuntu-latest images omit it by default.
- name: Install Qt EGL/XCB dependencies
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
libegl1 \
libgl1 \
libxkbcommon0 \
libdbus-1-3
- name: Sync dependencies (incl. build / Briefcase)
run: |
uv sync --locked --dev --group build
# Mirror release.yml so Briefcase installs from the same lock-derived
# constraints the real release build uses.
- name: Export lock-derived constraints for Briefcase
run: |
uv export --locked --format requirements.txt --no-dev --no-hashes --no-emit-project --no-emit-workspace --output-file constraints-briefcase.txt
- name: Briefcase create + build (linux system)
env:
QT_QPA_PLATFORM: offscreen
PIP_INDEX_URL: https://pypi.org/simple
PIP_EXTRA_INDEX_URL: ""
PIP_NO_CACHE_DIR: "1"
run: |
uv run briefcase create linux system --no-input
uv run briefcase build linux system --no-input