Code formatting by PrinceWalnut #239
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: [ubuntu-latest] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Install Miniconda | |
uses: conda-incubator/setup-miniconda@v2 | |
with: | |
miniconda-version: "latest" | |
channels: conda-forge, defaults | |
auto-activate-base: true | |
activate-environment: "" | |
- name: Source Miniconda | |
run: | | |
source $CONDA/etc/profile.d/conda.sh | |
conda activate | |
which python | |
python --version | |
echo $CONDA | |
conda install -n base conda-libmamba-solver | |
conda config --set solver libmamba | |
python -m pip install --upgrade pip | |
conda list | |
- 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 }} |