minor fixes #28
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 Fix | |
on: [push, pull_request] | |
jobs: | |
autostyle: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.x' | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install autoflake autopep8 | |
- name: Run autoflake to remove unused imports | |
run: | | |
autoflake --remove-all-unused-imports --remove-unused-variables --in-place --recursive . | |
- name: Run autopep8 to format the code | |
run: | | |
autopep8 --in-place --recursive --max-line-length 180 --ignore W503 . | |
- name: Commit changes | |
run: | | |
git config --global user.name 'github-actions[bot]' | |
git config --global user.email 'github-actions[bot]@users.noreply.github.com' | |
git add . | |
git diff-index --quiet HEAD || git commit -m 'Automatically fix code style issues' | |
git push | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
lint: | |
runs-on: ubuntu-latest | |
needs: autostyle | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Pull latest changes | |
run: git pull | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.x' | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install flake8 | |
- name: Run flake8 | |
run: | | |
flake8 . --max-line-length 180 |