-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.yml
More file actions
53 lines (53 loc) · 2.22 KB
/
action.yml
File metadata and controls
53 lines (53 loc) · 2.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
name: Cached Pre-Commit
description: Validates that your commit passes all its pre-commit rules, with caching from uv.
author: Andrew Aylett
inputs:
extra_args:
description: options to pass to pre-commit run
required: false
default: '--all-files'
pre_commit_version:
description: the version of pre-commit to use
required: false
default: '4.5.1'
pre_commit_uv_version:
description: the version of pre-commit-uv to use
required: false
default: '4.2.1'
uv_version:
description: the version of uv to use
required: false
default: '0.11.7'
runs:
using: composite
steps:
- uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: ~/.cache/pre-commit
key: andrewaylett/pre-commit-action/${{ hashFiles('.pre-commit-config.yaml') }}/${{ github.action_ref }}
restore-keys: |
andrewaylett/pre-commit-action/${{ hashFiles('.pre-commit-config.yaml') }}/
andrewaylett/pre-commit-action/
- uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
id: uv
with:
enable-cache: false
cache-local-path: ~/.cache/pre-commit/uv
version: ${{ inputs.uv_version }}
- run: |
# Set up and execute pre-commit
set -eu
echo ::group::Ensure pre-commit environment
${{ steps.uv.outputs.uv-path }} tool install 'pre-commit==${{ inputs.pre_commit_version }}' --with 'pre-commit-uv==${{ inputs.pre_commit_uv_version }}' --cache-dir '~/.cache/pre-commit/uv'
echo ::endgroup::
${{ steps.uv.outputs.uv-path }} tool run --from 'pre-commit==${{ inputs.pre_commit_version }}' --with 'pre-commit-uv==${{ inputs.pre_commit_uv_version }}' --cache-dir '~/.cache/pre-commit/uv' pre-commit run --show-diff-on-failure --color=always ${{ inputs.extra_args }}
echo ::group::Clean pre-commit cache
${{ steps.uv.outputs.uv-path }} tool run --from 'pre-commit==${{ inputs.pre_commit_version }}' --with 'pre-commit-uv==${{ inputs.pre_commit_uv_version }}' --cache-dir '~/.cache/pre-commit/uv' pre-commit gc
echo ::endgroup::
echo ::group::Clean uv cache
${{ steps.uv.outputs.uv-path }} cache prune --ci
echo ::endgroup::
shell: bash
branding:
icon: check-circle
color: blue