mirror of
https://github.com/pre-commit/action.git
synced 2026-02-11 05:39:22 +00:00
shared cache feat
This commit is contained in:
parent
1b06ec171f
commit
8f49604b97
2 changed files with 10 additions and 2 deletions
|
|
@ -31,8 +31,8 @@ jobs:
|
|||
pre-commit:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-python@v3
|
||||
- uses: actions/checkout@v6
|
||||
- uses: actions/setup-python@v6
|
||||
- uses: pre-commit/action@v3.0.1
|
||||
```
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,10 @@ inputs:
|
|||
description: options to pass to pre-commit run
|
||||
required: false
|
||||
default: '--all-files'
|
||||
shared-cache:
|
||||
description: enable shared cache across branches
|
||||
required: false
|
||||
default: 'false'
|
||||
runs:
|
||||
using: composite
|
||||
steps:
|
||||
|
|
@ -15,6 +19,10 @@ runs:
|
|||
- uses: actions/cache@v4
|
||||
with:
|
||||
path: ~/.cache/pre-commit
|
||||
# Key matches pre-commit action format: pre-commit-3|pythonLocation|configHash
|
||||
# The restore-key will find caches from ANY branch with the same Python location and config hash
|
||||
# This allows sharing caches across branches when .pre-commit-config.yaml hasn't changed
|
||||
key: pre-commit-3|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }}
|
||||
restore-keys: ${{ inputs.shared-cache == 'true' && format('pre-commit-3|{0}|{1}', env.pythonLocation, hashFiles('.pre-commit-config.yaml')) || '' }}
|
||||
- run: pre-commit run --show-diff-on-failure --color=always ${{ inputs.extra_args }}
|
||||
shell: bash
|
||||
|
|
|
|||
Loading…
Reference in a new issue