-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
49 lines (38 loc) · 1.4 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
# define the name of the virtual environment directory
VENV := venv
APP_DIR := app
# default target, when make executed without arguments
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
./$(VENV)/bin/black --check app tests
# Use `yq` to parse config/testing.toml and set the env variables. Then run tests & coverage.
test: venv
$(shell yq -o='shell' '.env_variables' config/testing.toml \
| tr '\n' ' ' | \
sed 's|$$|./$(VENV)/bin/coverage run --omit=tests/* -m pytest|')
./$(VENV)/bin/coverage report --show-missing --fail-under=100
run: venv
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|')
clean:
rm -rf $(VENV)
find . -type f -name '*.pyc' -delete
setup-db:
$(shell yq -o='shell' '.env_variables.SQLITE_FILE' config/local.toml \
| tr '\n' ' ' \
| sed "s|value='\(.*\)'|sqlite3 '\1' < data/setup.sql|")
populate-db:
$(shell yq -o='shell' '.env_variables.SQLITE_FILE' config/local.toml \
| tr '\n' ' ' \
| sed "s|value='\(.*\)'|sqlite3 '\1' < data/initial_data.sql|")
.PHONY: all test venv run clean