-
Notifications
You must be signed in to change notification settings - Fork 16
65 lines (58 loc) · 1.83 KB
/
check-precommit.yml
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
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.9"
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
jobs:
pre-commit:
runs-on: ubuntu-22.04
steps:
- name: Checkout 🛎️
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive
token: ${{ secrets.github-token || github.token }}
- name: Set up Python 🐍
uses: actions/setup-python@v5
with:
python-version: ${{ inputs.python-version }}
- name: Cache 💽 pre-commit
if: ${{ inputs.use-cache == true }}
uses: actions/cache@v4
with:
path: ~/.cache/pre-commit
key: pre-commit|py${{ inputs.python-version }}|${{ hashFiles('.pre-commit-config.yaml') }}
- name: Run pre-commit 🤖
id: precommit
run: |
pip install -q pre-commit
pre-commit run --all-files
- name: Fixing Pull Request ↩️
if: always() && inputs.push-fixes == true && steps.precommit.outcome == 'failure'
uses: actions-js/[email protected]
with:
github_token: ${{ secrets.github-token || github.token }}
message: "pre-commit: running and fixing..."
branch: ${{ github.ref_name }}