-
Notifications
You must be signed in to change notification settings - Fork 1
70 lines (62 loc) · 1.8 KB
/
Copy pathpre_commit.yaml
File metadata and controls
70 lines (62 loc) · 1.8 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
name: Post-Commit Check to Ensure Pre-Commits Ran
# this ensures failure if local setup is misconfigured
# or GH web UI is used, we still are alerted to failures.
on:
workflow_call:
inputs:
UV_VERSION:
required: false
type: string
default: ''
JUST_VERSION:
required: false
type: string
default: ''
COMMAND:
required: false
type: string
default: 'pre-commit run -a'
PYTHON_VERSION:
description: 'The Python version to use'
required: false
default: '3.13'
type: string
jobs:
run-pre-commit:
runs-on: ubuntu-latest
# don't run on main/master b/c it will fail due to
# not committing to such branches.
if: |
(
github.ref != 'refs/heads/main' &&
github.ref != 'refs/heads/master'
)
steps:
- name: Check out code
uses: actions/checkout@v6
with:
persist-credentials: false
- name: Set up python
uses: actions/setup-python@v6
with:
python-version: ${{ inputs.PYTHON_VERSION }}
- name: python info
run: python --version
- name: Install uv
if: inputs.UV_VERSION != ''
run: |
curl -LsSf https://astral.sh/uv/${{ inputs.UV_VERSION }}/install.sh | sh
- uses: taiki-e/install-action@v2
if: inputs.JUST_VERSION != ''
with:
tool: just@${{ inputs.JUST_VERSION }}
- name: pre-commit install
run: |
python -m pip install pre-commit
pre-commit install
- uses: actions/cache@v4
with:
path: ~/.cache/pre-commit
key: pre-commit-3|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }}
- name: pre-commit run
run: ${{ inputs.COMMAND }}