-
Notifications
You must be signed in to change notification settings - Fork 0
59 lines (51 loc) · 1.52 KB
/
black-format.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
name: Format Code
on:
push:
paths:
- '**.py'
- 'pyproject.toml'
- '.github/workflows/black-format.yml'
jobs:
format:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install formatters
run: |
python -m pip install --upgrade pip
pip install black isort
- name: Create pyproject.toml
run: |
cat << EOF > pyproject.toml
[tool.black]
line-length = 120
target-version = ['py310']
include = '\.pyi?$'
[tool.isort]
profile = "black"
line_length = 120
multi_line_output = 3
include_trailing_comma = true
force_grid_wrap = 0
use_parentheses = true
ensure_newline_before_comments = true
EOF
- name: Format code
run: |
isort .
black .
- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "style: format code with Black and isort"
commit_user_name: "github-actions[bot]"
commit_user_email: "github-actions[bot]@users.noreply.github.com"
commit_author: "github-actions[bot] <github-actions[bot]@users.noreply.github.com>"