Skip to content

Commit

Permalink
Add caching for pre-commit on CI
Browse files Browse the repository at this point in the history
  • Loading branch information
cwygoda committed Apr 17, 2024
1 parent 55e0dac commit d91cae8
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
18 changes: 18 additions & 0 deletions .github/actions/pre-commit/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: run pre-commit checks
description: run all pre-commit managed checks
inputs:
pre-commit-home:
description: cache dir to use
required: true
default: ${{ github.workspace }}/.pre-commit-cache
runs:
using: "composite"
steps:
- id: python-interpreter-hash
run: echo "HASH=$(python -VV | sha256sum | cut -d' ' -f1)" >> $$GITHUB_OUTPUTS
- uses: actions/cache@v4
with:
path: ${{ env.PRE_COMMIT_HOME }}
key: pre-commit|${{ env.PYTHON_INTERPRETER_HASH }}|${{ hashFiles('.pre-commit-config.yaml') }}
- name: Run commit checks
run: poetry run pre-commit run -a
3 changes: 3 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ on:
jobs:
check:
runs-on: ubuntu-latest
env:
PRE_COMMIT_HOME: $CI_PROJECT_DIR/.pre-commit-cache
steps:
- uses: actions/checkout@v4
- run: pipx install poetry==1.7.1
Expand All @@ -16,6 +18,7 @@ jobs:
cache: poetry
- name: Install dependencies
run: poetry install --with=dev
- uses: ./.github/actions/pre-commit
- name: Run commit checks
run: poetry run pre-commit run -a
- name: Run tests
Expand Down

0 comments on commit d91cae8

Please sign in to comment.