mirror of
https://github.com/kuhyx/testsAndMisc.git
synced 2026-11-24 19:56:17 +01:00
Compare commits
3 Commits
c50be1ee7f
...
6fec606368
| Author | SHA1 | Date | |
|---|---|---|---|
| 6fec606368 | |||
| e55c350bff | |||
| c73cfd3573 |
33
.github/workflows/pre-commit.yml
vendored
33
.github/workflows/pre-commit.yml
vendored
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user