-
Notifications
You must be signed in to change notification settings - Fork 23
72 lines (63 loc) · 2.26 KB
/
Copy pathcheck-precommit.yml
File metadata and controls
72 lines (63 loc) · 2.26 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
71
72
name: Check formatting flow
on:
workflow_call:
secrets:
github-token:
description: "if provided an user GH's token, it will push update; requires `push` event"
required: false
inputs:
python-version:
description: "Python version to use"
default: "3.12"
required: false
type: string
use-cache:
description: "enable using GH caching for performance boost"
type: boolean
required: false
default: true
push-fixes:
description: "if provided an user GH's token, it will push update; requires `push` event"
type: boolean
required: false
default: false
defaults:
run:
shell: bash
env:
# Supply-chain guard: skip PyPI releases newer than this. See https://docs.astral.sh/uv/reference/settings/#exclude-newer
UV_EXCLUDE_NEWER: "2 days"
jobs:
pre-commit:
runs-on: ubuntu-22.04
steps:
- name: Checkout 🛎️
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
fetch-depth: 0
submodules: recursive
token: ${{ secrets.github-token || github.token }}
- name: Set up uv and Python 🐍
uses: astral-sh/setup-uv@37802adc94f370d6bfd71619e3f0bf239e1f3b78 # v7.6.0
with:
activate-environment: true
python-version: ${{ inputs.python-version }}
enable-cache: true
- name: Cache 💽 pre-commit
if: ${{ inputs.use-cache == true }}
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: ~/.cache/pre-commit
key: pre-commit|py${{ inputs.python-version }}|${{ hashFiles('.pre-commit-config.yaml') }}
- name: Run pre-commit 🤖
id: precommit
run: uvx pre-commit run --all-files
- name: Minimize uv cache
run: uv cache prune --ci
- name: Fixing Pull Request ↩️
if: always() && inputs.push-fixes == true && steps.precommit.outcome == 'failure'
uses: actions-js/push@5a7cbd780d82c0c937b5977586e641b2fd94acc5 # v1.5
with:
github_token: ${{ secrets.github-token || github.token }}
message: "pre-commit: running and fixing..."
branch: ${{ github.ref_name }}