Code formatting by PrinceWalnut #161
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }} |