mirror of
https://github.com/pre-commit/action.git
synced 2026-02-11 21:59:24 +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:
|
pre-commit:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v6
|
||||||
- uses: actions/setup-python@v3
|
- uses: actions/setup-python@v6
|
||||||
- uses: pre-commit/action@v3.0.1
|
- uses: pre-commit/action@v3.0.1
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,10 @@ inputs:
|
||||||
description: options to pass to pre-commit run
|
description: options to pass to pre-commit run
|
||||||
required: false
|
required: false
|
||||||
default: '--all-files'
|
default: '--all-files'
|
||||||
|
shared-cache:
|
||||||
|
description: enable shared cache across branches
|
||||||
|
required: false
|
||||||
|
default: 'false'
|
||||||
runs:
|
runs:
|
||||||
using: composite
|
using: composite
|
||||||
steps:
|
steps:
|
||||||
|
|
@ -15,6 +19,10 @@ runs:
|
||||||
- uses: actions/cache@v4
|
- uses: actions/cache@v4
|
||||||
with:
|
with:
|
||||||
path: ~/.cache/pre-commit
|
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') }}
|
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 }}
|
- run: pre-commit run --show-diff-on-failure --color=always ${{ inputs.extra_args }}
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue