-
Notifications
You must be signed in to change notification settings - Fork 1
67 lines (57 loc) · 1.9 KB
/
ci.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
name: CI
####################################
# Start the job on all push and PR #
####################################
on:
pull_request:
branches: [master, main]
types: [synchronize, opened, reopened, ready_for_review]
# push:
# branches: [master, main]
jobs:
precommits:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Cache pip dependencies
uses: actions/cache@v3
with:
path: ~/.cache/pip
# key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
key: ${{ runner.os }}-pip-
restore-keys: |
${{ runner.os }}-pip-
- name: Install dependencies
run: |
python -m pip install pre-commit
pre-commit install
- name: Cache shfmt binary
uses: actions/cache@v3
with:
path: /usr/local/bin/shfmt
# key: ${{ runner.os }}-shfmt-${{ env.SHFMT_VERSION }}
key: ${{ runner.os }}-shfmt-
- name: Install shfmt
run: |
SHFMT_VERSION="v3.7.0"
SHFMT_BIN="shfmt_${SHFMT_VERSION}_linux_amd64"
wget -O shfmt "https://github.com/mvdan/sh/releases/download/${SHFMT_VERSION}/${SHFMT_BIN}"
chmod +x shfmt
sudo mv shfmt /usr/local/bin/
- name: Run pre-commits
run: |
CUR_SHA=$(git log --pretty=tformat:"%H" -n1 .)
echo $CUR_SHA
echo ${{ env.BASE_COMMIT_ID }}
git fetch
pre-commit run --from-ref origin/main --to-ref $CUR_SHA
# pre-commit run --from-ref ${{ env.BASE_COMMIT_ID }} --to-ref $CUR_SHA
# pre-commit run --all-files
# pre-commit run --from-ref origin/main --to-ref HEAD
# run: |
# BASE_COMMIT_ID=$(git rev-parse origin/main)