Repository navigation
179 lines (171 loc) · 7.45 KB
/
Copy pathci.yml
File metadata and controls
179 lines (171 loc) · 7.45 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
name: CI
on:
push:
branches: [main]
# Docs-only pushes to main skip CI. Deliberately NOT mirrored onto
# pull_request below: `CI passed` is a required status check on main,
# and a required check that never reports leaves the PR permanently
# unmergeable. Running CI on a docs-only PR costs nothing now that the
# repository is public and Actions minutes are unmetered.
paths-ignore:
- "docs/**"
- "**.md"
- "LICENSE"
pull_request:
# Superseded runs on the same PR branch are cancelled -- a 3-push burst
# used to run three full matrices to answer a question only the last one
# was asking. Pushes to main are never cancelled: every commit on main
# should have its own recorded CI result.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
lint:
name: Lint (ruff)
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v7
- uses: actions/setup-python@v7
with:
python-version: "3.11"
- run: pip install ruff
- run: ruff check .
typecheck:
name: Types (mypy)
# Required from the start rather than advisory: the engine is clean
# today, and a non-required job that is already green protects nothing.
# Ruff's ANN rules require annotations everywhere; this is what checks
# they are correct. Engine only -- see [tool.mypy] in pyproject.toml.
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v7
- uses: actions/setup-python@v7
with:
python-version: "3.11"
- name: Install package + dev deps
run: pip install -e ".[dev]"
- run: mypy
workflows:
name: Lint workflows (actionlint)
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v7
- uses: actions/setup-python@v7
with:
python-version: "3.11"
# actionlint runs shellcheck over every run: block when it is on PATH.
- run: pip install actionlint-py shellcheck-py
- run: actionlint
test:
name: Tests (${{ matrix.os }} / Python ${{ matrix.python }})
strategy:
fail-fast: false
matrix:
# PRs run Linux only; the full three-OS matrix runs on pushes to
# main and in release.yml (which builds all three on `v*` tags and
# via workflow_dispatch). GitHub bills each job rounded up to a
# whole minute times a per-OS multiplier -- Linux 1x, Windows 2x,
# macOS 10x -- so the two ~1-minute macOS jobs were ~30 of the ~45
# billed minutes per run, two thirds of the bill for under two
# minutes of real work.
os: ${{ github.event_name == 'pull_request' && fromJSON('["ubuntu-22.04"]') || fromJSON('["ubuntu-22.04", "windows-2022", "macos-26"]') }}
python: ["3.11", "3.12"]
# Both interpreters are covered on Linux; the expensive runners
# only need to prove the platform works, not the version spread.
# These excludes are inert on PRs, where neither OS is in the list.
exclude:
- os: windows-2022
python: "3.12"
- os: macos-26
python: "3.12"
runs-on: ${{ matrix.os }}
env:
# PySide6 has no display to attach to on CI runners; the offscreen
# platform plugin lets QApplication() succeed headlessly.
QT_QPA_PLATFORM: offscreen
steps:
- uses: actions/checkout@v7
- uses: actions/setup-python@v7
with:
python-version: ${{ matrix.python }}
- name: Install Qt runtime libraries (Linux only)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y libegl1 libxkbcommon-x11-0 libgl1
- name: Install package + dev deps
run: pip install -e ".[dev]"
- name: Run unit tests (excluding r_parity and network)
# Coverage covers the whole shipped package (track2data + app + ui);
# the per-package floors are enforced in the next step. See
# docs/TECHNICAL_SPEC.md §11.
#
# `network` covers tests/test_references_resolve.py, which asks
# Crossref to confirm every DOI in the bibliography resolves to
# the work claimed. Thirty-five HTTP requests per matrix cell on
# every push would be slow and impolite to a free public API, and
# a Crossref outage would redden CI without anything here being
# broken. Run it deliberately when adding or editing a reference:
# pytest tests/test_references_resolve.py -m network
run: >
pytest tests/ -v -m "not r_parity and not network"
--cov --cov-report=term
- name: Enforce per-package coverage floors
# Two thresholds from the one coverage run above. Separate because a
# well-covered GUI must not be able to mask an engine regression --
# a bug in the engine changes exported numbers, a bug in the GUI is
# visible to the person hitting it. Engine ~96%, GUI ~90% today, so
# both floors have real headroom without being decorative.
run: |
coverage report --include='track2data/*' --fail-under=90
coverage report --include='app/*,ui/*' --fail-under=85
r_parity:
name: R-parity (synthetic fixtures)
runs-on: ubuntu-22.04
env:
# pytest-qt is pulled in transitively by the [dev] extra and imports
# QtGui at collection time regardless of which tests actually run, so
# this job needs the same headless Qt setup as `test` even though it
# never touches the GUI itself.
QT_QPA_PLATFORM: offscreen
steps:
- uses: actions/checkout@v7
- uses: actions/setup-python@v7
with:
python-version: "3.11"
- name: Install Qt runtime libraries
run: |
sudo apt-get update
sudo apt-get install -y libegl1 libxkbcommon-x11-0 libgl1
- name: Install package + dev deps
run: pip install -e ".[dev]"
- name: Run r_parity tests against synthetic tiny_v5 fixture
# r_parity_local tests use embargoed choice-pipeline data and are
# excluded here. Run them locally with: pytest -m r_parity_local
run: pytest tests/test_r_parity/ -v -m "r_parity and not r_parity_local"
required:
name: CI passed
# Single aggregate gate, and the only check required by branch
# protection on main. The matrix job names encode the OS and Python
# spread ("Tests (ubuntu-22.04 / Python 3.11)"), so requiring them
# directly would mean editing the branch-protection settings by hand
# every time the matrix changes -- and a required check whose name no
# longer exists blocks every PR until someone notices. One stable name
# keeps settings and workflow decoupled.
if: always()
needs: [lint, typecheck, workflows, test, r_parity]
runs-on: ubuntu-22.04
steps:
- name: Fail unless every upstream job succeeded
# `needs` results are only 'success' when the whole job (every
# matrix leg included) passed, so this catches a single failing
# matrix entry as well as a wholesale job failure.
if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')
run: |
echo "lint=${{ needs.lint.result }}"
echo "typecheck=${{ needs.typecheck.result }}"
echo "workflows=${{ needs.workflows.result }}"
echo "test=${{ needs.test.result }}"
echo "r_parity=${{ needs.r_parity.result }}"
echo "::error::One or more CI jobs did not succeed."
exit 1