From c73cfd357345891b92b4c34f0d8f1cd3085a334e Mon Sep 17 00:00:00 2001 From: Krzysztof kuhy Rudnicki Date: Sun, 27 Sep 2026 08:49:17 +0200 Subject: [PATCH] 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 Claude-Session: https://claude.ai/code/session_01KFwA9nymhUdTrVF65kigTV --- .github/workflows/pre-commit.yml | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index 4f2b5dd2..8da364b2 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -121,15 +121,24 @@ 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 + if pre-commit run pylint --files .pre-commit-config.yaml; then + 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. #