-
-
Notifications
You must be signed in to change notification settings - Fork 1
45 lines (43 loc) · 1.18 KB
/
format-code.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
name: Format code
on:
push:
branches:
- master
- main
jobs:
format:
name: Format with black and isort
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python 3.8
uses: actions/setup-python@v5.2.0
with:
python-version: 3.8
- name: Cache
uses: actions/cache@v4.0.2
with:
path: ~/.cache/pip
key: pip-format
- name: Install dependencies
run: |
python -m pip install --upgrade pip wheel
python -m pip install --upgrade black isort
- name: Pull again
run: git pull || true
- name: Run formatting
run: |
python -m isort -v --multi-line 3 --trailing-comma -l 88 --recursive .
python -m black -v .
- name: Commit files
run: |
if [ $(git diff HEAD | wc -l) -gt 30 ]
then
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config user.name "GitHub Actions"
git commit -m "Run formatting" -a || true
git push || true
fi