Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding pre-commit with formatting, linting, and tests. #15

Merged
merged 1 commit into from
Mar 1, 2024
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
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
Loading