-
Notifications
You must be signed in to change notification settings - Fork 0
57 lines (47 loc) · 1.6 KB
/
action-lint.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
name: Lint Code Base
on:
pull_request:
branches:
- main
push:
jobs:
lint:
name: Lint Code Base
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: "3.12"
- name: Install Dependencies
run: pip install pre-commit
- uses: actions/cache@v3
with:
path: ~/.cache/pre-commit
key: pre-commit|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }}
- name: Lint Code Base
run: |
if [ "${{ github.event_name }}" == "push" ]; then
GITHUB_FROM_SHA="${{ github.event.before }}"
GITHUB_TO_SHA="${{ github.event.after }}"
elif [ "${{ github.event_name }}" == "pull_request" ]; then
GITHUB_FROM_SHA="${{ github.event.pull_request.base.sha }}"
GITHUB_TO_SHA="${{ github.event.pull_request.head.sha }}"
else
GITHUB_FROM_SHA="4b825dc642cb6eb9a060e54bf8d69288fbee4904"
GITHUB_TO_SHA="HEAD"
fi
if [ "$GITHUB_FROM_SHA" == "0000000000000000000000000000000000000000" ]; then
GITHUB_FROM_SHA="4b825dc642cb6eb9a060e54bf8d69288fbee4904"
fi
echo "::notice::GITHUB_FROM_SHA: $GITHUB_FROM_SHA"
echo "::notice::GITHUB_TO_SHA: $GITHUB_TO_SHA"
pre-commit run \
--color always \
--show-diff-on-failure \
--from-ref $GITHUB_FROM_SHA \
--to-ref $GITHUB_TO_SHA