wake-alarm/.github/workflows/python-tests.yml
Krzysztof kuhy Rudnicki a4876d84ec Speed up CI: uv installs, split pre-commit into mypy/pylint/rest
- pre-commit: drop the 28 s requirements.txt install (only
  dependency-freshness among the system hooks needs third-party code:
  pyyaml, packaging), run pre-commit directly instead of
  pre-commit/action, and split mypy and pylint into their own matrix
  jobs with per-group hook-env caches. Same hook set, same
  SKIP=free-days-interop (the rest group).
- Tests: uv with a cached wheel store for requirements.txt (pip took
  22 s), -q and -p no:sugar. No -n auto: the suite runs in ~0.5 s and
  measured ~1.2 s under pytest-xdist.
- free-days-interop (the critical path): build the freedays venv with
  uv instead of venv + pip (12 s).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0188kZdx3bb56QM8JFUnbHuM
2026-09-26 17:45:00 +02:00

80 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: subosito/flutter-action@v2
with:
flutter-version: 3.47.5
channel: stable
cache: true
- name: Dart writes, Python replays, both must agree
run: FREEDAYS_PYTHON="$PWD/.freedays-venv/bin/python" bash scripts/free_days_interop/check.sh