-
Notifications
You must be signed in to change notification settings - Fork 0
169 lines (149 loc) · 6.71 KB
/
Copy pathtests.yml
File metadata and controls
169 lines (149 loc) · 6.71 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
name: tests
on:
push:
branches: [main, develop]
pull_request:
branches: [main]
workflow_dispatch:
# One in-flight test run per branch or PR. Without this, every push spawns a
# fresh 5-version matrix and the superseded runs keep going: four pushes in
# quick succession put ~20 test jobs in the pool at once, which starved the
# release-build wheels of runners and made a healthy run look hung at 7%.
#
# Deliberately NOT applied to release-build.yml: cancelling a half-finished
# release is worse than paying for it to complete.
concurrency:
group: tests-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
rust:
name: Rust tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable
components: clippy, rustfmt
# The proprietary Rust core is gitignored (only `src/lib.rs` is tracked),
# so a fresh checkout cannot build. Restore it from the chunked secrets.
# Regenerate with `python scripts/pack_rust_core.py pack` after any
# src/*.rs change, or CI silently tests a stale core.
- name: Restore proprietary Rust core
env:
RUST_SRC_B64_1: ${{ secrets.RUST_SRC_B64_1 }}
RUST_SRC_B64_2: ${{ secrets.RUST_SRC_B64_2 }}
RUST_SRC_B64_3: ${{ secrets.RUST_SRC_B64_3 }}
RUST_SRC_B64_4: ${{ secrets.RUST_SRC_B64_4 }}
RUST_SRC_B64_5: ${{ secrets.RUST_SRC_B64_5 }}
RUST_SRC_B64_6: ${{ secrets.RUST_SRC_B64_6 }}
RUST_SRC_B64_7: ${{ secrets.RUST_SRC_B64_7 }}
RUST_SRC_B64_8: ${{ secrets.RUST_SRC_B64_8 }}
RUST_SRC_B64_9: ${{ secrets.RUST_SRC_B64_9 }}
RUST_SRC_B64_10: ${{ secrets.RUST_SRC_B64_10 }}
RUST_SRC_B64_11: ${{ secrets.RUST_SRC_B64_11 }}
RUST_SRC_B64_12: ${{ secrets.RUST_SRC_B64_12 }}
run: python scripts/pack_rust_core.py unpack --from-env
# A9-06: the `full` feature pulls in `ocl`, which needs an OpenCL ICD
# loader at link time. Without this the `--features full` step failed on a
# bare runner for reasons unrelated to the code under test.
- name: Install OpenCL ICD loader + CPU runtime
run: |
sudo apt-get update
sudo apt-get install -y ocl-icd-opencl-dev pocl-opencl-icd
- name: cargo test (no default features)
run: cargo test --no-default-features
- name: cargo clippy
run: cargo clippy --no-default-features --all-targets -- -D warnings
- name: cargo test (full features)
run: cargo test --features full
- name: cargo clippy (full features)
run: cargo clippy --features full --all-targets -- -D warnings
python:
name: Python tests
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
# The proprietary Rust core is gitignored (only `src/lib.rs` is tracked),
# so a fresh checkout cannot build. Restore it from the chunked secrets.
# Regenerate with `python scripts/pack_rust_core.py pack` after any
# src/*.rs change, or CI silently tests a stale core.
- name: Restore proprietary Rust core
env:
RUST_SRC_B64_1: ${{ secrets.RUST_SRC_B64_1 }}
RUST_SRC_B64_2: ${{ secrets.RUST_SRC_B64_2 }}
RUST_SRC_B64_3: ${{ secrets.RUST_SRC_B64_3 }}
RUST_SRC_B64_4: ${{ secrets.RUST_SRC_B64_4 }}
RUST_SRC_B64_5: ${{ secrets.RUST_SRC_B64_5 }}
RUST_SRC_B64_6: ${{ secrets.RUST_SRC_B64_6 }}
RUST_SRC_B64_7: ${{ secrets.RUST_SRC_B64_7 }}
RUST_SRC_B64_8: ${{ secrets.RUST_SRC_B64_8 }}
RUST_SRC_B64_9: ${{ secrets.RUST_SRC_B64_9 }}
RUST_SRC_B64_10: ${{ secrets.RUST_SRC_B64_10 }}
RUST_SRC_B64_11: ${{ secrets.RUST_SRC_B64_11 }}
RUST_SRC_B64_12: ${{ secrets.RUST_SRC_B64_12 }}
run: python scripts/pack_rust_core.py unpack --from-env
- name: Install OpenCL ICD loader + CPU runtime
run: |
sudo apt-get update
sudo apt-get install -y ocl-icd-opencl-dev pocl-opencl-icd
# A9-08: `maturin develop` requires an active virtualenv and errors out
# without one. Create it and put it on PATH for every later step.
- name: Create virtualenv
run: |
python -m venv .venv
echo "$PWD/.venv/bin" >> "$GITHUB_PATH"
echo "VIRTUAL_ENV=$PWD/.venv" >> "$GITHUB_ENV"
- name: Install maturin
run: pip install "maturin>=1.0,<2.0"
- name: Build + install
run: |
maturin develop --release --no-default-features --features cuda
pip install -e ".[dev,stim]"
- name: ruff lint
run: ruff check python/
- name: ruff format check
run: ruff format --check python/
# A5-03: `maturin develop` installs the Python layer by COPY, so the repo
# source and the code pytest actually imports can silently diverge — a real
# fix in the tree can sit beside a stale installed copy and the suite will
# happily test the stale one. (Observed during the A5 work: the new tests
# reported all 31 pre-fix line numbers against already-fixed source.)
- name: Verify installed package matches repo source
run: |
python - <<'PY'
import filecmp, pathlib, sys
import qector_decoder_v3 as q
installed = pathlib.Path(q.__file__).parent
source = pathlib.Path("python/qector_decoder_v3")
names = sorted(p.name for p in source.glob("*.py"))
match, mismatch, errors = filecmp.cmpfiles(source, installed, names, shallow=False)
if mismatch or errors:
print(f"installed package diverges from repo source at: {installed}")
for n in mismatch:
print(f" DIFFERS: {n}")
for n in errors:
print(f" MISSING: {n}")
sys.exit(1)
print(f"OK: {len(match)} modules identical to repo source")
PY
# A9-01: `--timeout` needs pytest-timeout, now in the `dev` extra.
# `-x` removed: one flaky test should not hide the state of the other 1200.
- name: pytest
run: python -m pytest python/tests -q --timeout=300
- name: Import smoke test
run: |
python - <<'PY'
import qector_decoder_v3 as qd
print(f"version={qd.__version__}")
for name in ("NativeAutoDecoder", "set_license_key", "get_license_info"):
assert hasattr(qd, name), f"{name} missing"
print("All imports OK")
PY