Compare commits

..

No commits in common. "6fec606368d1af1e890502e366b44ef14b793edf" and "c50be1ee7f619f8e3a5afc0ecb7d938cd784fd71" have entirely different histories.

View File

@ -89,12 +89,9 @@ 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. 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.
# change rebuilds only the hooks whose rev moved.
- uses: actions/cache@v4
id: cache
if: matrix.group != 'shellcheck'
with:
path: ~/.cache/pre-commit
key: >-
@ -124,30 +121,15 @@ 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 (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'
# 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'
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.
#
@ -191,10 +173,9 @@ 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, pylint's: it finishes ~10 s ahead of the others, while
# rest (which also pays for zsh) was the slowest group with it.
# one group only; the other three would be paying for it twice over.
- name: Install prettier and shfmt (pinned)
if: matrix.group == 'pylint'
if: matrix.group == 'rest'
env:
PRETTIER_VERSION: 3.9.5
SHFMT_VERSION: v3.13.1
@ -229,5 +210,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: matrix.group != 'shellcheck' && steps.cache.outputs.cache-hit != 'true'
if: steps.cache.outputs.cache-hit != 'true'
run: pre-commit gc