mirror of
https://github.com/pre-commit/action.git
synced 2025-11-11 04:26:56 +00:00
## Motivation In my experience, the cache of pre-commits can be quite large. It takes a couple of minutes to fetch the cache in GitHub Actions. I assume it might be faster to install hooks than to fetch cache. So, it would be useful to add an input `enable_cache` if we cache pre-commit hooks or not.
25 lines
722 B
YAML
25 lines
722 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'
|
|
enable_cache:
|
|
description: Whether to cache pre-commit hooks
|
|
required: false
|
|
default: 'true'
|
|
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
|
|
if: inputs.enable_cache == 'true'
|
|
with:
|
|
path: ~/.cache/pre-commit
|
|
key: pre-commit-3|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }}
|
|
- run: pre-commit run --show-diff-on-failure --color=always ${{ inputs.extra_args }}
|
|
shell: bash
|