Skip to content

Commit

Permalink
build: use uv to speed up pre-commit install
Browse files Browse the repository at this point in the history
  • Loading branch information
boidolr committed Oct 11, 2024
1 parent b40d9cf commit 33bf8ea
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,32 @@ on:
jobs:
pre-commit:
runs-on: ubuntu-latest
env:
python-version: 3.x
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4

- uses: boidolr/actions/setup-precommit@main
- name: Install uv
uses: astral-sh/setup-uv@c9aa747934b6867b18bf8f6624a8929c4f76147b # v3
with:
working-directory: tests
enable-cache: true
cache-suffix: "precommit"
cache-dependency-glob: tests/.pre-commit-config.yaml

- name: Cache pre-commit
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4
with:
path: ~/.cache/pre-commit
key: ${{ runner.os }}-pre-commit-${{ env.python-version }}-${{ hashFiles('**/.pre-commit-config.yaml') }}

- name: Check hook pass
run: pre-commit run --config "tests/.pre-commit-config.yaml" --all-files ast-grep-pass
run: uvx pre-commit run --config "tests/.pre-commit-config.yaml" --all-files ast-grep-pass

- name: Check hook failure
shell: bash
run: |
set +e
pre-commit run --config "tests/.pre-commit-config.yaml" --all-files ast-grep-fail
uvx pre-commit run --config "tests/.pre-commit-config.yaml" --all-files ast-grep-fail
if [[ "$?" == "0" ]]; then exit 1; fi
echo "::notice::Hook failed as expected"

0 comments on commit 33bf8ea

Please sign in to comment.