screen-locker/.github/workflows/python-tests.yml
Krzysztof kuhy Rudnicki 0b0a18e81c
Some checks are pending
dependency freshness / dependencies on newest stable (push) Waiting to run
md-naming / markdown naming convention (push) Waiting to run
pre-commit / pre-commit (${{ matrix.group }}) (flutter, flutter-analyze, ) (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,flutter-analyze) (push) Waiting to run
Tests / test (push) Waiting to run
Tests / lock-popup-safety (push) Waiting to run
Tests / flutter test (shard ${{ matrix.shard }}) (0) (push) Waiting to run
Tests / flutter test (shard ${{ matrix.shard }}) (1) (push) Waiting to run
Tests / flutter test (shard ${{ matrix.shard }}) (2) (push) Waiting to run
Tests / flutter test (shard ${{ matrix.shard }}) (3) (push) Waiting to run
Tests / flutter test (shard ${{ matrix.shard }}) (4) (push) Waiting to run
Tests / flutter test (shard ${{ matrix.shard }}) (5) (push) Waiting to run
Tests / flutter test (shard ${{ matrix.shard }}) (6) (push) Waiting to run
Tests / flutter test (shard ${{ matrix.shard }}) (7) (push) Waiting to run
Tests / flutter test (shard ${{ matrix.shard }}) (8) (push) Waiting to run
Tests / flutter test (shard ${{ matrix.shard }}) (9) (push) Waiting to run
Tests / flutter-coverage (push) Blocked by required conditions
Tests / web-coverage (push) Waiting to run
release-apk / release (APK) (push) Waiting to run
repo-contract / repo contract (push) Waiting to run
deps: newest stable (freshness gate); migrate web/ npm -> pnpm
web: react/react-dom 19.3.1, vitest + coverage-v8 5.0.4, jsdom 30.1.3,
user-event 14.6.8, typescript-eslint 8.71.2. Lockfile is now
web/pnpm-lock.yaml (packageManager pnpm@12.14.0); hooks and CI use pnpm
with --frozen-lockfile. Node 24.22.0 in workflows; workout_app sqflite
2.4.4+2 / sqflite_common_ffi 2.4.4.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Xfj1sxKH9VBPqpcAni8Jry
2026-10-16 14:16:56 +02:00

147 lines
5.2 KiB
YAML

name: Tests
on:
push:
branches: [main]
pull_request:
branches: [main]
env:
# Bucket count for the Flutter suite; the matrix below lists 0..N-1.
# 10, not more: the account runs at most 20 jobs at once, and a push also
# starts ~10 others (pre-commit, freshness, the rest of this file). At 12
# three shards queued for up to 34 s and the workflow took 91 s.
FLUTTER_SHARDS: 10
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 in seconds;
# plain pip took ~26 s of a ~70 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
# -n auto spreads the suite over every runner core (pytest-xdist is in
# requirements.txt); pytest-cov merges the workers' coverage, and every
# worker loads conftest.py, so the state-file redirects hold in each.
# -q cancels pyproject's -v: 1368 test names were most of the log.
- name: Run tests with coverage
run: python -m pytest -n auto -p no:sugar -q
# The pytest suite replaces the whole `tk` module so it can never reach a
# display, which means the lock-screen widget behaviour it guards cannot be
# asserted there. This job runs the real-Tk half against a throwaway X
# server. See scripts/verify_lock_popup_safety.py.
lock-popup-safety:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.x"
- uses: astral-sh/setup-uv@v10.2.0
with:
enable-cache: true
cache-dependency-glob: requirements.txt
# No apt step: the runner image already ships xvfb-run, and
# setup-python's interpreter has its own tkinter (python3-tk is for the
# system python, which this job never runs). The apt-get update +
# install cost ~35 s. If either ever goes missing the check does not
# skip -- _xvfb_reexec returns 1 without xvfb-run, and the import fails
# without tkinter.
- name: Install dependencies
run: |
uv pip install --system -r requirements.txt
# The script imports screen_locker directly rather than through
# pytest, which would put the rootdir on sys.path for it.
uv pip install --system -e . --no-deps
- name: Sport selector survives gatelock's recovery tick
# Run as a module (like the screen-fits gate) so scripts/ resolves as a
# package and the check can import the helpers it was split into.
run: python3 -m scripts.verify_lock_popup_safety
# The two coverage bars below used to run only in the local pre-push hook,
# which became a 1-second stamp check on 2026-09-20 (pre-commit's manual
# stage holds them now). Nothing else in CI runs the Flutter or web suites,
# so these jobs are the only place the 100% bars are enforced on every push.
#
# The Flutter suite took ~150 s on one runner, nearly all of it compiling 77
# test files, so it runs as FLUTTER_SHARDS buckets of whole files in
# parallel and flutter-coverage applies the unchanged 100% bar and
# every-lib-file-present guard to their union.
flutter-shard:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
shard: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
name: flutter test (shard ${{ matrix.shard }})
steps:
- uses: actions/checkout@v4
# The slim cached SDK (utils/flutter-setup): subosito's full-SDK
# cache cost ~38 s to restore even on a hit.
- uses: kuhyx/utils/flutter-setup@flutter-setup-v1
with:
flutter-version: 3.47.7
working-directory: stronglift_replacement/workout_app
- name: flutter test --coverage, bucket ${{ matrix.shard }}
run: bash scripts/check_flutter_coverage.sh --shard "${{ matrix.shard }}/$FLUTTER_SHARDS"
- uses: actions/upload-artifact@v4
with:
name: flutter-lcov-${{ matrix.shard }}
path: stronglift_replacement/workout_app/coverage/lcov.info
if-no-files-found: error
retention-days: 1
flutter-coverage:
needs: flutter-shard
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
pattern: flutter-lcov-*
path: lcov-shards
- name: flutter test --coverage, 100% of lib/ (workout app)
run: bash scripts/check_flutter_coverage.sh --merged "$FLUTTER_SHARDS" lcov-shards/*/lcov.info
web-coverage:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
with:
package_json_file: web/package.json
- uses: actions/setup-node@v4
with:
node-version: 24.22.0
cache: pnpm
cache-dependency-path: web/pnpm-lock.yaml
- name: vitest --coverage, 100% (status web UI)
run: |
pnpm --dir web install --frozen-lockfile
pnpm --dir web run coverage