diet-guard/.github/workflows/python-tests.yml
Krzysztof kuhy Rudnicki c55172fc9d Split pre-commit into mypy/pylint/rest runners and install with uv
pre-commit took ~119 s as one job (24 s of pip, then every hook env and
every hook in series); Tests took ~56 s (26 s of pip, 7 s of apt-get for an
xvfb the image already ships, 17 s of -v pytest). Same hooks, same flags,
same 100% bar -- just parallel runners, cached uv wheels, xdist workers.

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

53 lines
1.8 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 installs requirements.txt (git deps
# included) in seconds; plain pip took ~26 s of a ~56 s run.
- uses: astral-sh/setup-uv@v10.2.0
with:
enable-cache: true
cache-dependency-glob: requirements.txt
cache-suffix: tests
- name: Install dependencies
run: uv pip install --system -r requirements.txt
# The gate's keyboard and layout tests drive real Tk: widget heights and
# the focus ring come from the font engine, and no mock can answer what
# they ask. Without a display they do not skip -- they fail, which is how
# this job stayed red while the tests themselves were fine.
# ubuntu-latest already ships xvfb, so the unconditional
# `apt-get update && install` spent ~7 s to report "already the newest
# version"; it now installs only on an image that lacks it.
- name: Install a virtual X display
run: |
command -v xvfb-run >/dev/null \
|| { sudo apt-get update && sudo apt-get install -y xvfb; }
# -n auto spreads the suite over every runner core (pytest-xdist is in
# requirements.txt); pytest-cov merges the workers' coverage and the
# 100% bar still comes from pyproject's fail_under. -q because -v
# printed all ~1050 test ids.
- name: Run tests with coverage
run: |
xvfb-run -a -s "-screen 0 1600x1200x24" python -m pytest \
-n auto \
-p no:sugar \
-q