Add linting workflow

This commit is contained in:
Matteo Bertucci
2021-01-14 09:44:52 +01:00
parent 3fd070021e
commit 39d4344fbf
3 changed files with 80 additions and 0 deletions

20
.flake8 Normal file
View File

@ -0,0 +1,20 @@
[flake8]
max-line-length=110
docstring-convention=all
import-order-style=pycharm
exclude=constants.py,__pycache__,.cache,.git,.md,.svg,.png,tests,venv,.venv
ignore=
B311,W503,E226,S311,T000
# Missing Docstrings
D100,D104,D105,D107,
# Docstring Whitespace
D203,D212,D214,D215,
# Docstring Quotes
D301,D302,
# Docstring Content
D400,D401,D402,D404,D405,D406,D407,D408,D409,D410,D411,D412,D413,D414,D416,D417
# Type Annotations
ANN002,ANN003,ANN101,ANN102,ANN204,ANN206
# Whitespace Before
E203

51
.github/workflows/linting.yml vendored Normal file
View File

@ -0,0 +1,51 @@
name: Linting
on: [push, pull_request]
jobs:
lint:
runs-on: ubuntu-latest
env:
PIP_CACHE_DIR: /tmp/pip-cache-dir
steps:
- name: Checks out repository
uses: actions/checkout@v2
- name: Set up Python 3.9
id: python
uses: actions/setup-python@v2
with:
python-version: 3.9
# This step caches our Python dependencies. To make sure we
# only restore a cache when the dependencies, the python version and
# the runner operating system we create a cache key
# that is a composite of those states.
# Only when the context is exactly the same, we will restore the cache.
- name: Restore pip cache
uses: actions/cache@v2
with:
path: ${{ env.PIP_CACHE_DIR }}
key: "python-0-${{ runner.os }}-\
${{ steps.python.outputs.python-version }}-\
${{ hashFiles('./requirements.txt', './requirements-dev.txt') }}"
- name: Install dependencies
run: |
pip install -r requirements.txt
pip install -r requirements-dev.txt
# Run flake8 and have it format the linting errors in the format of
# the GitHub Workflow command to register error annotations. This
# means that our flake8 output is automatically added as an error
# annotation to both the run result and in the "Files" tab of a
# pull request.
#
# Format used:
# ::error file={filename},line={line},col={col}::{message}
- name: Run flake8
run: "flake8 \
--format='::error file=%(path)s,line=%(row)d,col=%(col)d::[flake8] %(code)s: %(text)s'"

9
requirements-dev.txt Normal file
View File

@ -0,0 +1,9 @@
flake8~=3.8.4
flake8-annotations~=2.4.1
flake8-bugbear~=20.1.4
flake8-docstrings~=1.5.0
flake8-import-order~=0.18.1
flake8-string-format~=0.3.0
flake8-tidy-imports~=4.1.0
flake8-todo~=0.7
pep8-naming~=0.11.1