Repository navigation
165 lines (146 loc) · 6.61 KB
/
Copy pathtests.yml
File metadata and controls
165 lines (146 loc) · 6.61 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
name: Tests
on:
push:
branches: [main]
pull_request:
workflow_dispatch:
# Cancel superseded runs on the same ref (saves CI minutes on rapid pushes).
concurrency:
group: tests-${{ github.ref }}
cancel-in-progress: true
defaults:
run:
# The installable project lives in the sdr_dsp/ subdirectory (the one with
# pyproject.toml, the pytest config, and the `hardware` marker). The git
# root is one level up.
working-directory: sdr_dsp
# Pin the hash seed for the whole workflow: a ~1-in-6 flake was traced to a
# fixture seeded from the per-process-randomized builtin hash(). The fixture
# now seeds from hashlib; this keeps any future hash-order dependence
# deterministic in CI too. Post-mortem: docs/LOG.md 2026-09-23.
env:
PYTHONHASHSEED: "0"
jobs:
test:
name: pytest (${{ matrix.os }}, py${{ matrix.python-version }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
# windows-latest is the platform this library's hardware workflow
# targets (the HackRF capture path was debugged there); ubuntu and
# macos keep the pure-DSP core honest cross-platform. No board is
# needed -- every hardware test self-skips without one.
os: [windows-latest, ubuntu-latest, macos-latest]
python-version: ["3.11", "3.12", "3.13", "3.14"]
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
python-version: ${{ matrix.python-version }}
- name: Lockfile is in sync with pyproject
# A stale uv.lock means CI tests a different dependency set than a
# fresh `uv sync` would install. Fail early instead.
run: uv lock --check
- name: Sync environment (numpy + scipy + dev group, editable install)
run: uv sync
- name: Run test suite (hardware tests deselected)
# 95% floor. The tree is at ~99.6% line coverage; a floor far below
# that lets a whole untested module land unnoticed, which is exactly
# what the gate exists to catch. Raise it again if coverage climbs.
run: uv run pytest -m "not hardware" --cov=sdr_dsp --cov-report=xml --cov-report=term-missing --cov-fail-under=95
oldest-deps:
name: pytest (ubuntu, py3.11, oldest declared numpy/scipy)
# pyproject promises numpy>=1.26 and scipy>=1.11; the matrix above only
# ever tests whatever the lockfile resolved to (the newest). This leg
# installs the OLDEST versions the project claims to support, so the
# claim is tested rather than assumed.
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v5
with:
python-version: "3.11"
- name: Sync with lowest allowed direct dependencies
run: uv sync --resolution lowest-direct
- name: Show what resolved
run: uv run --no-sync python -c "import numpy, scipy; print('numpy', numpy.__version__, 'scipy', scipy.__version__)"
- name: Run test suite
# --no-sync: a plain `uv run` re-syncs to the lockfile (newest) first,
# which would silently undo the step above.
run: uv run --no-sync pytest -m "not hardware" -q
package:
name: build wheel + import from a clean env
# The package __init__ lazy-loads submodules (PEP 562) and ships a
# py.typed marker; both are easy to break in a way the editable install
# used by the tests never notices. Build the wheel, install it alone
# into an empty environment, and import the public surface from there.
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v5
with:
python-version: "3.12"
- name: Build sdist + wheel
run: uv build
- name: Import the wheel in an isolated environment
run: |
uv run --isolated --no-project --with dist/*.whl python - <<'PY'
import importlib.resources as r
import sdr_dsp, sdr_dsp.core, sdr_dsp.io, sdr_dsp.sinks, sdr_dsp.sources
import sdr_dsp.stream, sdr_dsp.link
from sdr_dsp import Pipeline, fm_demod, design_lowpass
from sdr_dsp.stream import StreamingFIR, StreamingResampler
assert (r.files("sdr_dsp") / "py.typed").is_file(), "py.typed missing from wheel"
print("wheel imports OK:", sdr_dsp.__name__)
PY
lint:
name: ruff + mypy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Tracked text files are LF in the index
# .gitattributes declares `text=auto eol=lf`; this holds the line.
# A CRLF file sneaking into the index breaks `#!` shebangs on Linux
# and produces whole-file whitespace diffs. `git ls-files --eol`
# reports the INDEX encoding (i/...), independent of the runner's OS.
working-directory: .
run: |
bad=$(git ls-files --eol | grep -E '^i/(crlf|mixed)' || true)
if [ -n "$bad" ]; then
echo "::error::tracked files with CRLF/mixed line endings in the index:"
echo "$bad"
exit 1
fi
echo "index is LF-clean ($(git ls-files --eol | grep -c '^i/lf') text files)"
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
python-version: "3.12"
- name: Sync environment
run: uv sync
- name: Ruff lint
# docs/dev_handbook/ is outside the package directory ruff runs from,
# so it is named explicitly or it is never checked.
run: uv run ruff check . ../docs/dev_handbook
- name: API handbook is regenerated
# docs/dev_handbook/sdr_dsp_API_HANDBOOK.md is generated from the
# source. The generator was only ever run by hand and the checked-in
# copy drifted ~1,100 lines behind the code before anyone noticed;
# this fails the job when it is stale. Fix: run the printed command
# and commit the result. Pinned to this one Python so annotation
# repr differences between versions can't make it flap.
run: >
uv run python ../docs/dev_handbook/generate_api_handbook.py
--check ../docs/dev_handbook/sdr_dsp_API_HANDBOOK.md
- name: Mypy
# Blocking. Not the strict gate hackrfpy runs: sdr_dsp DOES ship a
# py.typed marker but most signatures are not annotated yet, so this
# is mypy's default checks plus check_untyped_defs -- real type errors,
# incompatible assignments, wrong argument types. The tree is clean at
# that level; a regression fails the build. The path to strict is in
# docs/TODO.md.
run: uv run mypy