Cleanup code and improve abstractions #13
Workflow file for this run
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: Lint and Format Code | |
on: | |
push: | |
branches: | |
- main | |
- dev | |
pull_request: | |
branches: | |
- main | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
ref: ${{ github.head_ref }} | |
- name: Set up Python | |
uses: actions/setup-python@v3 | |
with: | |
python-version: "3.10" | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install flake8 flake8-pyproject black isort | |
- name: Lint with flake8 | |
run: | | |
# uses the flake8 configuration in pyproject.toml | |
# stop the build if there are Python syntax errors or undefined names | |
flake8 . | |
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide | |
flake8 . --exit-zero | |
- name: Run black | |
run: black . | |
- name: Run isort | |
run: isort . | |
- name: Commit changes | |
run: | | |
git config --local user.email "[email protected]" | |
git config --local user.name "GitHub Action" | |
git add -A | |
if git diff --exit-code --staged; then | |
echo "No changes to commit" | |
else | |
git commit -m "[PROJ] Format code with Black" | |
git push https://${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }} | |
fi |