Skip to content

Commit

Permalink
Adding pre-commit with formatting, linting, and tests. (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
epwr authored Mar 1, 2024
1 parent 1820ed0 commit 7533b04
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 2 deletions.
34 changes: 34 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: trailing-whitespace
- id: check-executables-have-shebangs
- id: check-yaml
- id: check-json
- id: pretty-format-json
- id: check-toml
- id: name-tests-test
args: [--unittest]
- id: no-commit-to-branch
args: [--branch, main]
- id: requirements-txt-fixer
- id: end-of-file-fixer
- id: check-added-large-files
- repo: local
hooks:
- id: make-format
name: Format Code
entry: make format
language: system
types: [python]
- id: make-lint
name: Lint Code
entry: make lint
language: system
types: [python]
- id: make-test
name: Test Code w/ Coverage
entry: make test
language: system
types: [python]
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@ VENV := venv
APP_DIR := app

# default target, when make executed without arguments
all: lint test format
all: format lint test

$(VENV)/bin/activate:
python3 -m venv $(VENV)
./$(VENV)/bin/pip install -r ./requirements/requirements.txt -r ./requirements/requirements-dev.txt

venv: $(VENV)/bin/activate

format: venv
./$(VENV)/bin/black app tests

lint: venv
./$(VENV)/bin/mypy app --strict
./$(VENV)/bin/flake8 app tests
Expand All @@ -24,7 +27,7 @@ test: venv
./$(VENV)/bin/coverage report --show-missing --fail-under=100

run: venv
touch .gitignore # used to force make to run command every time
touch .gitignore # used to force make to run command every time
$(shell yq -o='shell' '.env_variables' config/local.toml \
| tr '\n' ' ' \
| sed 's|$$|./$(VENV)/bin/python3 serve.py|')
Expand Down

0 comments on commit 7533b04

Please sign in to comment.