-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
122 lines (95 loc) · 2.33 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
.DEFAULT: test
PLATFORM := ${shell uname -o}
ifeq (${VIRTUAL_ENV},)
INVENV = poetry run
else
INVENV =
endif
${info Platform: ${PLATFORM}}
.PHONY: help
help:
@echo "usage:"
@echo ""
@echo "install"
@echo " setup production environment"
@echo ""
@echo "dev | install-dev"
@echo " setup development environment"
@echo ""
@echo "all-tests"
@echo " run all tests"
@echo ""
@echo "serve | serve-w-reload"
@echo " start web server"
@echo ""
@echo "lint"
@echo " lint the code"
@echo ""
@echo "type-check"
@echo " check types"
@echo ""
@echo "fmt"
@echo " run formatter on all code"
@echo ""
@echo "tags"
@echo " generate tags file"
install:
poetry install --only=main
dev: install-dev
install-dev:
poetry install
init-db:
${INVENV} alembic upgrade head
build-parser: karp/search/domain/query_dsl/karp_query_parser.py karp/search/domain/query_dsl/karp_query_model.py
karp/search/domain/query_dsl/karp_query_parser.py: grammars/query.ebnf
${INVENV} tatsu $< > $@
karp/search/domain/query_dsl/karp_query_model.py: grammars/query.ebnf
${INVENV} tatsu --object-model $< > $@
.PHONY: serve
serve: install-dev
${INVENV} uvicorn --factory karp.api.main:create_app
.PHONY: serve-w-reload
serve-w-reload: install-dev
${INVENV} uvicorn --reload --factory karp.api.main:create_app
unit_test_dirs := tests/unit
e2e_test_dirs := tests/e2e
all_test_dirs := tests
tests := ${unit_test_dirs}
all_tests := ${all_test_dirs}
.PHONY: test
test: unit-tests
.PHONY: all-tests
all-tests: clean-pyc
${INVENV} pytest -vv tests
.PHONY: unit-tests
unit-tests:
${INVENV} pytest -vv tests/unit
.PHONY: e2e-tests
e2e-tests: clean-pyc
${INVENV} pytest -vv tests/e2e
.PHONY: integration-tests
integration-tests: clean-pyc
${INVENV} pytest -vv tests/integration
.PHONY: lint
lint:
${INVENV} ruff check ${flags} karp
.PHONY: lint-fix
lint-fix:
${INVENV} ruff check ${flags} karp --fix
.PHONY: fmt
fmt:
${INVENV} ruff format .
.PHONY: type-check
type-check:
${INVENV} mypy --config-file mypy.ini -p karp
.PHONY: tags
tags:
ctags --languages=python -R --python-kinds=-i karp
ctags --languages=python -R --python-kinds=-i -e karp
.PHONY: clean clean-pyc
clean: clean-pyc
clean-pyc:
find . -name '*.pyc' -exec rm -f {} +
find . -name '*.pyo' -exec rm -f {} +
find . -name '*~' -exec rm -f {} +
find . -name '__pycache__' -exec rm -fr {} +