Add linting and CI workflow

This commit is contained in:
thecode 2022-02-04 04:03:55 +02:00
parent 74ab406b91
commit de3119822a
8 changed files with 258 additions and 0 deletions

17
.github/dependabot.yml vendored Normal file
View File

@ -0,0 +1,17 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: daily
open-pull-requests-limit: 10
- package-ecosystem: "pip"
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
open-pull-requests-limit: 10

9
.github/release-drafter.yml vendored Normal file
View File

@ -0,0 +1,9 @@
change-template: "- #$NUMBER - $TITLE (@$AUTHOR)"
categories:
- title: "⚠ Breaking Changes"
labels:
- "breaking change"
template: |
## Whats Changed
$CHANGES

15
.github/workflows/release-drafter.yml vendored Normal file
View File

@ -0,0 +1,15 @@
name: Release Drafter
on:
push:
branches:
- main
jobs:
update_release_draft:
runs-on: ubuntu-latest
steps:
# Drafts your next Release notes as Pull Requests are merged into "main"
- uses: release-drafter/release-drafter@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

34
.github/workflows/test.yml vendored Normal file
View File

@ -0,0 +1,34 @@
# This workflow will install Python dependencies, run tests and lint
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
name: Test
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version:
- "3.9"
- "3.10"
steps:
- uses: actions/checkout@v2.3.4
with:
fetch-depth: 2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2.3.1
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements_lint.txt
- name: Lint
run: pre-commit run

101
.gitignore vendored Normal file
View File

@ -0,0 +1,101 @@
# Hide sublime text stuff
*.sublime-project
*.sublime-workspace
# Hide some OS X stuff
.DS_Store
.AppleDouble
.LSOverride
Icon
# Thumbnails
._*
# IntelliJ IDEA
.idea
*.iml
# pytest
.pytest_cache
.cache
# GITHUB Proposed Python stuff:
*.py[cod]
# C extensions
*.so
# Packages
*.egg
*.egg-info
dist
build
eggs
.eggs
parts
bin
var
sdist
develop-eggs
.installed.cfg
lib
lib64
pip-wheel-metadata
# Logs
*.log
pip-log.txt
# Unit test / coverage reports
.coverage
.tox
coverage.xml
nosetests.xml
htmlcov/
test-reports/
test-results.xml
test-output.xml
# Translations
*.mo
# Mr Developer
.mr.developer.cfg
.project
.pydevproject
.python-version
# emacs auto backups
*~
*#
*.orig
# venv stuff
pyvenv.cfg
pip-selfcheck.json
venv
.venv
Pipfile*
share/*
Scripts/
# vimmy stuff
*.swp
*.swo
tags
ctags.tmp
# vagrant stuff
virtualization/vagrant/setup_done
virtualization/vagrant/.vagrant
virtualization/vagrant/config
# Visual Studio Code
.vscode/*
!.vscode/cSpell.json
!.vscode/extensions.json
!.vscode/tasks.json
# Typing
.mypy_cache

48
.pre-commit-config.yaml Normal file
View File

@ -0,0 +1,48 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.1.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-docstring-first
- id: check-yaml
- id: debug-statements
- repo: https://gitlab.com/pycqa/flake8
rev: 4.0.1
hooks:
- id: flake8
args:
- --max-line-length=500
- --ignore=E203,E266,E501,W503
- --max-complexity=18
- --select=B,C,E,F,W,T4,B9
- repo: https://github.com/ambv/black
rev: 21.12b0
hooks:
- id: black
language_version: python3
- repo: https://github.com/asottile/pyupgrade
rev: v2.31.0
hooks:
- id: pyupgrade
args: ['--py39-plus']
- repo: https://github.com/pre-commit/mirrors-isort
rev: v5.10.1
hooks:
- id: isort
args:
- --multi-line=3
- --trailing-comma
- --force-grid-wrap=0
- --use-parentheses
- --line-width=88
- -p=homeassistant
- --force-sort-within-sections
- repo: https://github.com/PyCQA/pydocstyle
rev: 6.1.1
hooks:
- id: pydocstyle
- repo: https://github.com/pre-commit/mirrors-mypy
rev: 'v0.930'
hooks:
- id: mypy

27
pylintrc Normal file
View File

@ -0,0 +1,27 @@
[MASTER]
ignore=tests
# Use a conservative default here; 2 should speed up most setups and not hurt
# any too bad. Override on command line as appropriate.
jobs=2
persistent=no
[BASIC]
good-names=id,i,j,k,ex,Run,_,fp
max-attributes=15
[MESSAGES CONTROL]
# Reasons disabled:
# too-many-* - are not enforced for the sake of readability
# too-few-* - same as too-many-*
disable=
too-few-public-methods,
too-many-arguments,
too-many-public-methods,
too-many-instance-attributes,
too-many-branches
[REPORTS]
score=no
[FORMAT]
expected-line-ending-format=LF

7
requirements_lint.txt Normal file
View File

@ -0,0 +1,7 @@
black==21.12b0
flake8==4.0.1
isort==5.10.1
mypy==0.930
pre-commit==2.16.0
pydocstyle==6.1.1
pylint==2.12.2