-
Notifications
You must be signed in to change notification settings - Fork 7
81 lines (62 loc) · 1.92 KB
/
pre-commit.yaml
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
73
74
75
76
77
78
79
80
81
# run pre-commit
name: lint
on:
pull_request:
jobs:
lint:
permissions:
contents: read
pull-requests: write
runs-on: "ubuntu-22.04"
defaults:
run:
shell: /usr/bin/bash -o pipefail -u -e {0}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: install pre-commit
run: pip install pre-commit
- uses: actions/cache@v4
with:
path: ~/.cache/pre-commit
key: pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}
- name: setup pre-commit
run: |
pre-commit install-hooks
- name: run pre-commit
run: |
pre-commit run --color=always --from-ref '${{ github.event.pull_request.base.sha }}' --to-ref '${{ github.event.pull_request.head.sha }}' 2>&1 | tee pre-commit-output
- name: pre-commit tip
if: failure()
run: |
echo 'run `pre-commit run --all-files` and commit the resulting changes'
- name: render report (click Summary to view)
if: failure()
run: |
cat <<EOF >> report
## pre-commit failed
Run \`pre-commit run --all-files\` to check for errors.
Usually, these will just be auto-formatting changes,
which you can commit and push.
You can install the pre-commit hooks with:
\`\`\`
pip install pre-commit
pre-commit install
\`\`\`
pre-commit output:
\`\`\`\`
$(cat pre-commit-output | sed 's/\x1b\[[0-9;?]*[mh]//g')
\`\`\`\`
<details>
<summary>diff produced by auto-formatters:</summary>
\`\`\`diff
$(git diff HEAD)
\`\`\`
</details>
EOF
cat report
cat report >> $GITHUB_STEP_SUMMARY