Project editing and testing configuration bumpf

This commit is contained in:
Jonathan Harker 2024-09-20 16:32:35 +12:00
parent 4011c1fa47
commit 2e4b981aa7
8 changed files with 139 additions and 0 deletions

25
.editorconfig Normal file
View file

@ -0,0 +1,25 @@
# Defines coding style rules for most editors and IDEs
# See: https://editorconfig.org
root = true
[*]
end_of_line = lf
charset = utf-8
insert_final_newline = true
indent_style = space
indent_size = 4
trim_trailing_whitespace = true
[*.{json,html,xml,yml,yaml}]
indent_size = 2
[*.csv]
end_of_line = crlf
trim_trailing_whitespace = false
[*.md]
trim_trailing_whitespace = false
[Makefile]
indent_style = tab

20
.gitignore vendored Normal file
View file

@ -0,0 +1,20 @@
# Logs, data, and other cruft
*~
.~lock*#
\#*
.\#*
*.log
*.pyc
__pycache__
/.idea
# Tests and metrics
/junit.xml
/.coverage
/coverage.xml
/.pytest_cache
/.tox/
# Virtual environments
/venv/
/.venv/

30
.pre-commit-config.yaml Normal file
View file

@ -0,0 +1,30 @@
fail_fast: false
repos:
# Are we accidentally committing secrets, keys, credentials, etc.?
- repo: https://github.com/gitleaks/gitleaks
rev: v8.18.4
hooks:
- id: gitleaks
# Check for simple quick low-hanging fruit
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
# Does it parse?
- id: check-ast
- id: check-json
- id: check-toml
- id: check-yaml
# Have we accidentally left merge markers in?
- id: check-merge-conflict
# Fix BOM, EOF whitespace
- id: fix-byte-order-marker
- id: end-of-file-fixer
# Auto-format some non-controversial PEP8 things
- repo: https://github.com/hhatto/autopep8
rev: v2.3.1
hooks:
- id: autopep8
# fix blank lines between classes and funcs, import lines, trailing whitespace
args: ["--in-place", "--select", "E301,E302,E303,E304,E305,E306,E401,W291,W292,W293,W391"]

17
pyproject.toml Normal file
View file

@ -0,0 +1,17 @@
[tool.isort]
line_length = 120
multi_line_output = 5
skip = []
known_first_party = []
[tool.flake8]
max_line_length = 120
exclude = [ ".git", ".pytest_cache", ".tox", ".venv", "__pycache__", "venv" ]
ignore = [ "E501" ]
[tool.autopep8]
max_line_length = 120
ignore = [ "E501" ]
in-place = true
recursive = true
aggressive = 3

5
pytest.ini Normal file
View file

@ -0,0 +1,5 @@
[pytest]
minversion = 8.0
norecursedirs = venv .venv .git *.egg .* build dist
python_files = tests.py test_*.py *_tests.py
pythonpath = .

13
requirements-dev.txt Normal file
View file

@ -0,0 +1,13 @@
-r requirements.txt
# Code lint
autopep8
flake8
# Security
pre-commit
# Unit tests and coverage
pytest
pytest-cov
tox

0
requirements.txt Normal file
View file

29
tox.ini Normal file
View file

@ -0,0 +1,29 @@
[tox]
envlist = py38,py310
skipsdist = True
skip_missing_interpreters = True
[testenv]
skip_install = True
setenv =
PYTHONPATH = {toxroot}
commands =
pytest --cov=. --junitxml=junit.xml --cov-report xml:coverage.xml --cov-report term {posargs}
deps =
-r requirements-dev.txt
[coverage:run]
[coverage:report]
skip_empty = True
sort = miss
[flake8]
max_line_length = 120
ignore = E501
exclude =
.git,
.pytest_cache,
.tox,
.venv,
venv