diet-guard/.github/workflows/python-tests.yml
Krzysztof kuhy Rudnicki 49b3ea4d57
Some checks are pending
dependency freshness / dependencies on newest stable (push) Waiting to run
file-length / file length <= 250 lines (push) Waiting to run
md-naming / markdown naming convention (push) Waiting to run
pre-commit / pre-commit (${{ matrix.group }}) (mypy, mypy, ) (push) Waiting to run
pre-commit / pre-commit (${{ matrix.group }}) (pylint, pylint, ) (push) Waiting to run
pre-commit / pre-commit (${{ matrix.group }}) (rest, , mypy,pylint) (push) Waiting to run
Tests / test (push) Waiting to run
release-apk / release (APK) (push) Waiting to run
Give every xdist worker its own Xvfb (pytest-xvfb)
The first -n auto Tests run segfaulted in Tk's focus_force(): keyboard
focus is global to an X display, and four workers were sharing the one
xvfb-run display, stealing each other's focus. Stressed locally (layout +
keyboard tests x40, -n 8): 5 of 2760 failed on a shared display (focus-ring
assertions), 0 of 4600 with pytest-xvfb's per-process display -- and faster.
The geometry xvfb-run used moves into pyproject; the workflow keeps the
Xvfb install guard and drops xvfb-run.

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

55 lines
1.9 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. pytest-xvfb
# (requirements.txt, geometry in pyproject) starts one Xvfb per xdist
# worker: a shared display let workers steal each other's focus.
# 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 >/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: |
python -m pytest \
-n auto \
-p no:sugar \
-q