Fix pre-commit GitHub Action cache (#4746)

Currently pre-commit caching seems not to work properly: There is
no cache stored according to GitHub Action tab, and the Prepare
Python dependencies job shows the following warning:
Warning: Path Validation Error: Path(s) specified in the action for caching do(es) not exist, hence no cache is being saved.

This seems to be similar to what have been observed and solved in
Home Assistant Core with https://github.com/home-assistant/core/pull/46696.
Use PRE_COMMIT_CACHE instead of PRE_COMMIT_HOME as well.
This commit is contained in:
Stefan Agner 2023-12-06 11:30:57 +01:00 committed by GitHub
parent d63f0d5e0b
commit 8c8122eee0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -9,7 +9,7 @@ on:
env:
DEFAULT_PYTHON: "3.11"
PRE_COMMIT_HOME: ~/.cache/pre-commit
PRE_COMMIT_CACHE: ~/.cache/pre-commit
concurrency:
group: "${{ github.workflow }}-${{ github.ref }}"
@ -49,7 +49,8 @@ jobs:
id: cache-precommit
uses: actions/cache@v3.3.2
with:
path: ${{ env.PRE_COMMIT_HOME }}
path: ${{ env.PRE_COMMIT_CACHE }}
lookup-only: true
key: |
${{ runner.os }}-pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}
restore-keys: |
@ -132,7 +133,7 @@ jobs:
id: cache-precommit
uses: actions/cache@v3.3.2
with:
path: ${{ env.PRE_COMMIT_HOME }}
path: ${{ env.PRE_COMMIT_CACHE }}
key: |
${{ runner.os }}-pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}
- name: Fail job if cache restore failed
@ -208,7 +209,7 @@ jobs:
id: cache-precommit
uses: actions/cache@v3.3.2
with:
path: ${{ env.PRE_COMMIT_HOME }}
path: ${{ env.PRE_COMMIT_CACHE }}
key: |
${{ runner.os }}-pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}
- name: Fail job if cache restore failed
@ -249,7 +250,7 @@ jobs:
id: cache-precommit
uses: actions/cache@v3.3.2
with:
path: ${{ env.PRE_COMMIT_HOME }}
path: ${{ env.PRE_COMMIT_CACHE }}
key: |
${{ runner.os }}-pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}
- name: Fail job if cache restore failed
@ -325,7 +326,7 @@ jobs:
id: cache-precommit
uses: actions/cache@v3.3.2
with:
path: ${{ env.PRE_COMMIT_HOME }}
path: ${{ env.PRE_COMMIT_CACHE }}
key: |
${{ runner.os }}-pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}
- name: Fail job if cache restore failed