5
0
Fork 0
mirror of https://github.com/pre-commit/action.git synced 2025-11-11 04:26:56 +00:00
pre-commit-action/action.yml
Tom Whitwell 9a134f4f53
add cache restore key and run gc in post step
This will allow us to restore all available cached hooks to reduce the
time spent "Initializing environment" on each run.

If any of the hooks are updated, the `pre-commit gc` command will remove
the now-unused hooks from ~/.cache/pre-commit, ensuring that we don't
store them in the cache indefinitely.
2025-02-14 12:47:00 +00:00

25 lines
708 B
YAML

name: pre-commit
description: run pre-commit
inputs:
extra_args:
description: options to pass to pre-commit run
required: false
default: '--all-files'
runs:
using: composite
steps:
- run: python -m pip install pre-commit
shell: bash
- run: python -m pip freeze --local
shell: bash
- uses: actions/cache@v4
with:
path: ~/.cache/pre-commit
key: pre-commit-3|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }}
restore-keys: |
pre-commit-3|${{ env.pythonLocation }}|
pre-commit-3|
- run: pre-commit run --show-diff-on-failure --color=always ${{ inputs.extra_args }}
shell: bash
- run: pre-commit gc
shell: bash