Python Linting¶
This action runs all our static analysis tools against the codebase as defined
in our .pre-commit-config.yaml
file.
Triggers¶
This action is triggered by any PR that is opened against the develop
or
master
branches but only if they touch one of the paths listed.
on:
pull_request:
branches:
- develop
- master
paths:
- 'arlunio/**'
- 'blog/**'
- 'tests/**'
- 'setup.py'
Jobs¶
Since static analysis tools only look at the source code without importing or running anything, it doesn’t matter too much which platform / python version they are run on as long as the tool itself supports it. For the sake of simplcity these checks are run on the latest version of python and on a linux agent.
Lint:
runs-on: ubuntu-latest
Steps¶
- uses: actions/checkout@v1
- name: Setup Python 3.8
uses: actions/setup-python@v1
with:
python-version: 3.8
- name: Setup Environment
run: |
python --version
python -m pip install --upgrade pip wheel
python -m pip install -e .[dev]
- name: Lint
run: |
pre-commit run --all-files
This action is fairly straight forword, we checkout the code, setup the python
envrionment and then run pre-commit
across all the entire project.
The only other step to note is that if any of the pre-commit
jobs applied fixes
(and thus fail the workflow) we run git diff in an attempt to help show and fix the
errors.
- name: Show Fixes
run:
git diff
if: ${{ failure() }}