Skip to content

Commit 1e5cc9e

Browse files
authored
Merge pull request #336 from dafyddj/ci/gha-caching
ci(workflows): improve `pre-commit` caching
2 parents 61e0384 + 38d87fc commit 1e5cc9e

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

.github/workflows/main.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ jobs:
2929
runs-on: ubuntu-latest
3030
timeout-minutes: 5
3131
steps:
32+
- run: | # Needed because of bug #2031 in `actions/checkout`
33+
git config --global --add safe.directory "$GITHUB_WORKSPACE"
3234
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
3335
with:
3436
fetch-depth: 0
@@ -41,11 +43,18 @@ jobs:
4143
path: ~/.cache/pre-commit
4244
key: "${{ env.CI_CACHE_ID }}|\
4345
${{ hashFiles('.pre-commit-config.yaml') }}"
46+
restore-keys: |
47+
${{ env.CI_CACHE_ID }}|
48+
- name: Build cache
49+
shell: bash
50+
run: |
51+
pre-commit gc
52+
echo "Installing hook environments"
53+
time pre-commit install-hooks
4454
- name: Run `pre-commit`
4555
run: |
46-
git config --global --add safe.directory $(pwd)
4756
pre-commit run --all-files --color always --verbose
48-
pre-commit run --color always --hook-stage manual commitlint-ci
57+
pre-commit run --color always --hook-stage manual --verbose commitlint-ci
4958
test:
5059
name: Test / Kitchen
5160
needs:

0 commit comments

Comments
 (0)