Skip to content

Instantly share code, notes, and snippets.

@lays147
Last active February 2, 2022 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lays147/216285640515191dc791ba69fbab8718 to your computer and use it in GitHub Desktop.
Save lays147/216285640515191dc791ba69fbab8718 to your computer and use it in GitHub Desktop.
Python Setup for Code Governance
repos:
- repo: https://github.com/commitizen-tools/commitizen
rev: v2.20.3
hooks:
- id: commitizen
stages: ["commit-msg"]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.1.0
hooks:
- id: check-toml
- id: check-yaml
- id: check-docstring-first
- id: detect-aws-credentials
- id: detect-private-key
- id: check-merge-conflict
- id: check-ast
- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.9.0
hooks:
- id: python-check-mock-methods
- id: python-use-type-annotations
- id: python-check-blanket-noqa
- id: python-no-eval
- repo: https://github.com/hadolint/hadolint
rev: v2.8.0
hooks:
- id: hadolint-docker
- repo: local
hooks:
- id: lint and format
name: Lint and format files
entry: make lint
language: system
types: [python]
- id: compliance and quality
name: Run for compliance and quality checks
entry: make run_compliance
language: system
types: [python]
- id: tests
name: Run tests
entry: make run_tests
language: system
types: [python]
name: Lint Commit Messages
on: [pull_request]
jobs:
commitlint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: wagoid/commitlint-github-action@v4
lint:
tox -e lint
run_tests:
poetry run pytest
run_compliance:
poetry run tox -e compliance
setup_pre_commit:
pre-commit install --hook-type pre-commit --hook-type pre-push --hook-type commit-msg
[tox]
envlist = py{36,38,39}
skipsdist = true
skip_missing_interpreters = true
[testenv]
description= Setup environment
[testenv:lint]
deps =
isort
black
autoflake
commands =
autoflake --recursive .
isort .
black .
[testenv:compliance]
description= Run compliance tests
deps =
flake8
flake8-bandit
flake8-bugbear
flake8-builtins
flake8-comprehensions
flake8-string-format
flake8-black
flake8-logging-format
flake8-isort
commands =
flake8
[flake8]
exclude =
.venv,
.git,
.tox,
dist,
doc,
*lib/python*,
*egg,
build,
max-complexity = 10
max-line-length = 88
statistics = True
count = True
format = pylint
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment