wake-alarm/.github/workflows/python-tests.yml
2026-11-01 20:13:43 +01:00

79 lines
2.6 KiB
YAML

name: Tests
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.x"
# uv with a cached wheel store (and cached builds of the three
# git+ kuhyx/utils packages) installs requirements.txt in seconds;
# plain pip took 22 s of a 32 s job.
- uses: astral-sh/setup-uv@v10.2.0
with:
enable-cache: true
cache-dependency-glob: requirements.txt
- name: Install dependencies
run: uv pip install --system -r requirements.txt
# No -n auto: the whole suite runs in ~0.5 s, and under pytest-xdist it
# measured ~1.2 s locally (worker start-up outweighs the parallelism).
# Coverage and its 100% bar come from pyproject.toml's addopts.
- name: Run tests with coverage
run: python -m pytest -q -p no:sugar
# The Dart free-day rules are a port of ~/src/utils/freedays. This is the
# cross-language gate (scripts/free_days_interop/check.sh): it needs both
# Flutter and the Python package, which the pre-commit job does not have,
# so it runs here and the pre-commit job SKIPs that one hook.
free-days-interop:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check out the Python side of the pool
uses: actions/checkout@v4
with:
repository: kuhyx/utils
path: .utils
- uses: actions/setup-python@v5
with:
python-version: "3.x"
# This job is the workflow's critical path (the Flutter SDK restore and
# the Dart test are its floor); uv builds the venv in a couple of
# seconds where venv + pip took 12 s.
- uses: astral-sh/setup-uv@v10.2.0
with:
enable-cache: true
cache-dependency-glob: |
.utils/crdt-sync/pyproject.toml
.utils/freedays/pyproject.toml
- name: Install freedays into its own venv
run: |
uv venv --python "$pythonLocation/bin/python" .freedays-venv
uv pip install --quiet --python .freedays-venv/bin/python .utils/crdt-sync
uv pip install --quiet --python .freedays-venv/bin/python --no-deps .utils/freedays
- uses: kuhyx/utils/flutter-setup@flutter-setup-v1
with:
flutter-version: 3.47.9
working-directory: phone_app
- name: Dart writes, Python replays, both must agree
run: FREEDAYS_PYTHON="$PWD/.freedays-venv/bin/python" bash scripts/free_days_interop/check.sh