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 5f48a28 commit 66c1a15
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 4 deletions.
22 changes: 22 additions & 0 deletions .github/actions/pre-commit/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
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
shell: bash
run: echo "HASH=$(python -VV | sha256sum | cut -d' ' -f1)" >> $GITHUB_OUTPUT
- uses: actions/cache@v4
with:
path: ${{ inputs.pre-commit-home }}
key: pre-commit|${{ steps.python-interpreter-hash.outputs.HASH }}|${{ hashFiles('.pre-commit-config.yaml') }}
- name: Run commit checks
shell: bash
env:
PRE_COMMIT_HOME: ${{ inputs.pre-commit-home }}
run: poetry run pre-commit run -a
13 changes: 9 additions & 4 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,19 @@ on:
branches: ["main"]

jobs:
check:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: pipx install pre-commit
- name: Run commit checks
uses: ./.github/actions/pre-commit

test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ '3.10', '3.11', '3.12', 'pypy3.10' ]
python-version: ["3.10", "3.11", "3.12", "pypy3.10"]

steps:
- uses: actions/checkout@v4
Expand All @@ -21,7 +28,5 @@ jobs:
cache: poetry
- name: Install dependencies
run: poetry install --with=dev
- name: Run commit checks
run: poetry run pre-commit run -a
- name: Run tests
run: ./scripts/test

0 comments on commit 66c1a15

Please sign in to comment.