Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .github/workflows/pre-commit-action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: CI

on:
pull_request:
push:
branches:
- main

permissions:
contents: read

env:
SKIP: ${{ github.ref == 'refs/heads/main' && 'no-commit-to-branch' || '' }}

jobs:
linting:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
with:
python-version: "3.11"
- uses: pre-commit/action@v3.0.0
testing:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
with:
python-version: "3.11"
- name: pytest
run: |
make setup-pipenv
make install-dev
make test
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ share/python-wheels/
*.egg
MANIFEST

# Ruff
.ruff*

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
Expand Down Expand Up @@ -127,6 +130,7 @@ venv/
ENV/
env.bak/
venv.bak/
.vscode

# Spyder project settings
.spyderproject
Expand Down
9 changes: 9 additions & 0 deletions .markdownlint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
default: true

MD013:
# Number of characters
line_length: 120
# Number of characters for headings
heading_line_length: 80
# Number of characters for code blocks
code_block_line_length: 120
111 changes: 111 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
default_language_version:
python: python3.11
default_install_hook_types: [pre-commit, pre-push, pre-rebase]
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
hooks:
- id: check-yaml
- id: check-toml
- id: end-of-file-fixer
- id: trailing-whitespace
- id: check-ast
- id: check-builtin-literals
- id: check-docstring-first
- id: debug-statements
- id: fix-encoding-pragma
- id: double-quote-string-fixer
- id: check-added-large-files
- id: check-merge-conflict
- id: name-tests-test
# ensure tests match `test_.*\.py`
# NOTE: arg should be `--pytest-test-first` but only the following works now
args: ['--django']
- id: no-commit-to-branch
args: [--branch, master]
- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.10.0
hooks:
- id: python-use-type-annotations
- id: python-check-blanket-noqa
- id: python-check-blanket-type-ignore
- id: python-check-mock-methods
- id: python-no-eval
- id: python-no-log-warn
- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.38.0
hooks:
- id: markdownlint-fix
args: ['--config', '.markdownlint.yaml']
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.6
hooks:
- id: ruff
- id: ruff-format
args: ['--check']
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 23.11.0
hooks:
- id: black
args: ['--check']
- repo: https://github.com/hhatto/autopep8
rev: v2.0.4
hooks:
- id: autopep8
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.7.0
hooks:
- id: mypy
additional_dependencies: ['types-pytz', 'types-requests']
- repo: https://github.com/PyCQA/flake8
rev: 6.1.0
hooks:
- id: flake8
additional_dependencies: ['Flake8-pyproject==1.2.3']
- repo: https://github.com/PyCQA/bandit
rev: 1.7.5
hooks:
- id: bandit
args: ["-c", "pyproject.toml"]
- repo: https://github.com/pylint-dev/pylint
rev: v3.0.2
hooks:
- id: pylint
- repo: https://github.com/PyCQA/isort
rev: 5.12.0
hooks:
- id: isort
args: ['--check-only']
- repo: https://github.com/hadialqattan/pycln
rev: v2.4.0
hooks:
- id: pycln
- repo: https://github.com/mrtazz/checkmake.git
rev: 0.2.2
hooks:
- id: checkmake
- repo: https://github.com/tox-dev/pyproject-fmt
rev: "1.0.0"
hooks:
- id: pyproject-fmt
args: ['--check']
- repo: local
hooks:
- id: commit-msg
name: Check commit message
language: pygrep
entry: '^(chore|test|setup|feature|fix|build|docs|refactor)!?: [a-zA-Z0-9-_ ]+[a-zA-Z0-9-_ ]+.*'
args:
- --negate # fails if the entry is NOT matched
stages:
- commit-msg
- repo: local
hooks:
- id: pytest
name: pytest
entry: make test
language: system
pass_filenames: false
always_run: true
stages:
- pre-push
39 changes: 39 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
SHELL := /bin/bash

.PHONY: setup setup-pipenv install install-dev lint test run clean-setup clean-lint all clean

setup: install-dev
pipenv run pre-commit install
pipenv run pre-commit install --hook-type commit-msg

setup-pipenv:
python -m pip install --upgrade pip
pip install pipenv

install:
pipenv sync

install-dev:
pipenv sync --dev

lint:
pipenv run pre-commit run --all-files

test:
pipenv run pytest tests/* --cov

run:
pipenv run python run.py

clean-setup:
pipenv run pre-commit uninstall --hook-type commit-msg
pipenv run pre-commit uninstall
pipenv clean

clean-lint:
pipenv run pre-commit clean
pipenv run pre-commit gc

all: setup-pipenv setup lint

clean: clean-lint clean-setup
20 changes: 20 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[packages]
python-coverage-comment = {file = ".", editable = true}
httpx = "*"
jinja2 = "*"

[dev-packages]
ruff = "*"
mypy = "*"
pre-commit = "*"
pytest = "*"
pytest-env = "*"
pytest-cov = "*"

[requires]
python_version = "3.11"
Loading