From 9a134f4f53ddd4071215facfc20ea754f9cb337b Mon Sep 17 00:00:00 2001 From: Tom Whitwell Date: Fri, 14 Feb 2025 09:46:20 +0000 Subject: [PATCH] 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. --- action.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/action.yml b/action.yml index 18ded0d..9313159 100644 --- a/action.yml +++ b/action.yml @@ -16,5 +16,10 @@ runs: 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