-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakefile
74 lines (67 loc) · 2.03 KB
/
makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
VENV ?= .venv
PYTHON_VERSION=3.8
PYTHON = $(if $(shell [ ! -d $(VENV) ] && echo found),python$(PYTHON_VERSION),. ${VENV}/bin/activate && python$(PYTHON_VERSION))
PYRIGHT = $(if $(shell [ ! -d $(VENV) ] && echo found),pyright,. ${VENV}/bin/activate && pyright)
PIP = $(PYTHON) -m pip
PYLINT = $(PYTHON) -m pylint
BLACK = $(PYTHON) -m black
MYPY = $(PYTHON) -m mypy
COVERAGE = $(PYTHON) -m coverage
UNIT_TEST_COV_THRESH = 50
SYS_TEST_COV_THRESH = 50
.PHONY: default
default: coverage
###################################
### Setup
###################################
.PHONY: venv install install-dev
venv:
$(PYTHON) -m venv .venv
install:
$(PIP) install -U setuptools wheel
$(PIP) install .
install-dev:
$(PIP) install -U setuptools wheel
$(PIP) install -e .[dev,rest_api]
###################################
### Run
###################################
.PHONE: run
run:
$(PYTHON) main.py
###################################
### Tests
###################################
.PHONY: tests tests-unit tests-system clean-coverage
tests: coverage
clean-coverage:
$(COVERAGE) erase
tests-unit: clean-coverage
$(COVERAGE) run --append --source=src --context=unit -m pytest tests/unit
tests-system: clean-coverage
$(COVERAGE) run --append --source=src --context=system -m pytest tests/system
coverage: tests-unit tests-system
$(COVERAGE) html --fail-under=$(UNIT_TEST_COV_THRESH) --context=unit -d htmlcov-unit
$(COVERAGE) html --fail-under=$(SYS_TEST_COV_THRESH) --context=system -d htmlcov-system
###################################
### Linting
###################################
.PHONY: lint typecheck format format-check format-write format-diff
lint: format-check typecheck
$(PYLINT) --rcfile=pylintrc organizer rest_api
$(PYLINT) --rcfile=pylintrc.tests tests
typecheck:
$(MYPY)
$(PYRIGHT) src tests
format: format-check
format-check:
$(BLACK) --check src tests
format-write:
$(BLACK) src tests
format-diff:
$(BLACK) --diff src tests
###################################
### Checks
###################################
.PHONY: pre-commit
pre-commit: lint tests