diff --git a/.github/actions/pre-commit-setup/action.yml b/.github/actions/pre-commit-setup/action.yml index 8721e77a..735fd191 100644 --- a/.github/actions/pre-commit-setup/action.yml +++ b/.github/actions/pre-commit-setup/action.yml @@ -10,10 +10,35 @@ description: Prepare pre-commit environment runs: using: composite steps: + # Save on default-branch pushes; other runs only restore shared caches. + # Keep installed environments, but exclude package-manager download/build caches. + # Select entries separately so tar cannot include excluded buckets via a parent. - uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 + if: github.event_name == 'push' && github.ref == format('refs/heads/{0}', github.event.repository.default_branch) with: path: | - ~/.cache/prek + ~/.cache/prek/* + !~/.cache/prek/cache + ~/.cache/prek/cache/* + !~/.cache/prek/cache/uv + !~/.cache/prek/cache/npm + !~/.cache/prek/cache/go + !~/.cache/prek/cache/cargo + ~/.cache/kingfisher + key: ${{ runner.os }}-${{ runner.arch }}-prek-${{ hashFiles('.pre-commit-config.yaml') }} + restore-keys: | + ${{ runner.os }}-${{ runner.arch }}-prek- + - uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 + if: github.event_name != 'push' || github.ref != format('refs/heads/{0}', github.event.repository.default_branch) + with: + path: | + ~/.cache/prek/* + !~/.cache/prek/cache + ~/.cache/prek/cache/* + !~/.cache/prek/cache/uv + !~/.cache/prek/cache/npm + !~/.cache/prek/cache/go + !~/.cache/prek/cache/cargo ~/.cache/kingfisher key: ${{ runner.os }}-${{ runner.arch }}-prek-${{ hashFiles('.pre-commit-config.yaml') }} restore-keys: | @@ -25,3 +50,4 @@ runs: - uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1 with: version: 0.12.10 + save-cache: ${{ github.event_name == 'push' && github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }} diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index 5effe346..cac86061 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -40,7 +40,9 @@ jobs: if: steps.detect.outputs.method == 'pep735' run: | uv run --only-group pre-commit prek run --all-files --show-diff-on-failure + du -h --max-depth=1 ~/.cache/prek ~/.cache/prek/cache ~/.cache/kingfisher || true uv run --only-group pre-commit prek cache gc + du -h --max-depth=1 ~/.cache/prek ~/.cache/prek/cache ~/.cache/kingfisher || true env: RUFF_OUTPUT_FORMAT: github REUSE_OUTPUT_FORMAT: github @@ -49,7 +51,9 @@ jobs: if: steps.detect.outputs.method == 'uvx' run: | uvx prek run --all-files --show-diff-on-failure + du -h --max-depth=1 ~/.cache/prek ~/.cache/prek/cache ~/.cache/kingfisher || true uvx prek cache gc + du -h --max-depth=1 ~/.cache/prek ~/.cache/prek/cache ~/.cache/kingfisher || true env: RUFF_OUTPUT_FORMAT: github REUSE_OUTPUT_FORMAT: github diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9837c3f5..182a6f54 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -67,6 +67,8 @@ repos: rev: v2.1.0 hooks: - id: kingfisher-auto + env: + KINGFISHER_VERSION: v2.1.0 - repo: https://github.com/crate-ci/typos rev: v1.50.1 hooks: @@ -89,7 +91,7 @@ repos: - id: rumdl - id: rumdl-fmt - repo: https://github.com/kjanat/actionlint - rev: v1.14.0 + rev: v1.15.1 hooks: - id: actionlint ci: