-
Notifications
You must be signed in to change notification settings - Fork 3
50 lines (43 loc) · 1.19 KB
/
format.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
name: Format
run-name: Code formatting by ${{ github.actor }}
on:
pull_request:
branches:
- main
push:
branches:
- main
workflow_dispatch:
jobs:
format:
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: ['3.10']
os: [ubuntu-latest]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Format code with black
run: |
pip install black
black .
- name: Sort imports with isort
run: |
pip install isort
isort .
- name: Remove unused imports with autoflake
run: |
pip install autoflake
autoflake --in-place --remove-all-unused-imports --remove-unused-variables --recursive .
- name: Commit changes
uses: EndBug/add-and-commit@v4
with:
author_name: ${{ github.actor }}
author_email: ${{ github.actor }}@users.noreply.github.com
message: "Commit formatting and linting fixes"
add: "."
branch: ${{ github.ref }}