From 8f49604b9745e32ba795ddea6c42180dd804dace Mon Sep 17 00:00:00 2001 From: Hammond95 Date: Tue, 20 Jan 2026 14:56:06 +0100 Subject: [PATCH] shared cache feat --- README.md | 4 ++-- action.yml | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2a30ad0..2c97052 100644 --- a/README.md +++ b/README.md @@ -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 ``` diff --git a/action.yml b/action.yml index 18ded0d..e56a9ce 100644 --- a/action.yml +++ b/action.yml @@ -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