Compare commits

...

3 Commits

Author SHA1 Message Date
6fec606368 ci: keep the expected pylint env-build failure out of the annotations
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 checks / pre-commit (${{ matrix.group }}) (mypy, mypy) (push) Waiting to run
Pre-commit checks / pre-commit (${{ matrix.group }}) (pylint, pylint) (push) Waiting to run
Pre-commit checks / pre-commit (${{ matrix.group }}) (rest, ) (push) Waiting to run
Pre-commit checks / pre-commit (${{ matrix.group }}) (shellcheck, shellcheck) (push) Waiting to run
Shell tests / shell-tests (push) Waiting to run
Shell tests / lib-tests (push) Waiting to run
Shell tests / arch-tests (push) Waiting to run
A no-cache run (all pre-commit caches deleted, workflow_dispatch
36301788851) exercised the fallback for the first time: the first
build failed on sdl-config in 7 s, the headers installed in 21 s, the
retry built the env, and the job went green -- but the expected
traceback tripped setup-python's problem matcher and left an error
annotation on the green run. The first attempt now logs to a file; the
retry still prints in full.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KFwA9nymhUdTrVF65kigTV
2026-09-27 09:03:36 +02:00
e55c350bff ci: pre-commit shellcheck group skips the hook-env cache; pins move to pylint
Measured on c73cfd3: cold 59 s / warm 54 s / 47 s -- inside 60 s with
little margin. shellcheck is a language: system hook with no env, yet
its group restored (and on a miss saved) the ~120 MB hook-env cache.
The prettier/shfmt version-record step moves from rest (the slowest
group on the warm run, 49 s) to pylint (the fastest, 31-37 s).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KFwA9nymhUdTrVF65kigTV
2026-09-27 08:54:24 +02:00
c73cfd3573 ci: build the pylint env first, pygame headers only if that fails
The first run of the split workflow restored the pylint hook env from
the old monolithic cache, yet still spent 30 s on apt for pygame's SDL
headers, because the step was gated on an exact cache-key hit. That made
the pylint group 71 s. Now the env build is attempted first (pre-commit
installs the env, then has no files to lint) and the headers are
installed and the build retried only when it actually fails.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KFwA9nymhUdTrVF65kigTV
2026-09-27 08:49:17 +02:00

View File

@ -89,9 +89,12 @@ jobs:
# first, and the others would rebuild their hook envs on every run. The
# restore-keys fall back to any env set built by the SAME interpreter
# (this group's older config first, then any group's), so a config
# change rebuilds only the hooks whose rev moved.
# change rebuilds only the hooks whose rev moved. shellcheck is a
# `language: system` hook with no env to cache, so its group skips the
# ~120 MB restore (3-6 s) and the save.
- uses: actions/cache@v4
id: cache
if: matrix.group != 'shellcheck'
with:
path: ~/.cache/pre-commit
key: >-
@ -121,15 +124,30 @@ jobs:
# 2.6.1 is the newest release and its wheels stop at cp313, so on
# newest-stable Python pip falls back to a source build -- which dies on
# a missing `sdl-config` unless these are here. Only a pylint env BUILD
# needs them, so an exact cache hit skips the step.
- name: Install pygame build headers (pylint env build only)
if: matrix.group == 'pylint' && steps.cache.outputs.cache-hit != 'true'
# needs them (30 s of apt), and a restored cache usually already holds
# the env, so the build is tried first and the headers are installed
# only if it fails. Run against a non-Python file: pre-commit installs
# the hook env before filtering files, then has nothing to lint, so the
# only way this exits non-zero is the env build itself failing.
- name: Build the pylint hook env (pygame headers only if needed)
if: matrix.group == 'pylint'
run: |
set -euo pipefail
# The first attempt's output goes to a file: an expected sdl-config
# traceback would otherwise trip setup-python's problem matcher and
# put an error annotation on a green run. The retry below prints in
# full, so any other cause of failure still shows up there.
attempt_log="$RUNNER_TEMP/pylint-env-attempt.log"
if pre-commit run pylint --files .pre-commit-config.yaml >"$attempt_log" 2>&1; then
cat "$attempt_log"
exit 0
fi
echo "pylint env build failed -- installing pygame's build headers and retrying"
pkgs=(libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev libsdl2-ttf-dev
libfreetype6-dev libportmidi-dev)
sudo apt-get install -y "${pkgs[@]}" ||
{ sudo apt-get update && sudo apt-get install -y "${pkgs[@]}"; }
pre-commit run pylint --files .pre-commit-config.yaml
# Pin shellcheck instead of inheriting whatever ubuntu-latest ships.
#
@ -173,9 +191,10 @@ jobs:
# workflow that does run them inherits the pin instead of re-deriving
# it. Their real divergence risk is between developers: both REWRITE
# files, so two versions reformat the repo back and forth. Installed in
# one group only; the other three would be paying for it twice over.
# one group only, pylint's: it finishes ~10 s ahead of the others, while
# rest (which also pays for zsh) was the slowest group with it.
- name: Install prettier and shfmt (pinned)
if: matrix.group == 'rest'
if: matrix.group == 'pylint'
env:
PRETTIER_VERSION: 3.9.5
SHFMT_VERSION: v3.13.1
@ -210,5 +229,5 @@ jobs:
# group's key, so without this the envs of every hook rev ever used
# would ride along forever. gc drops the ones the config no longer names.
- name: Prune stale hook envs before the cache is saved
if: steps.cache.outputs.cache-hit != 'true'
if: matrix.group != 'shellcheck' && steps.cache.outputs.cache-hit != 'true'
run: pre-commit gc