forked from TrustTheVote-Project/Electorate-Vanadium-Core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
139 lines (104 loc) · 3.18 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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# Makefile.
#
# This is intended for convenience.
# All commands should be usable even without make.
# --- Variables
ROOT := $(abspath $(dir $(lastword $(MAKEFILE_LIST))))
PROJECT := vanadium
PIP_REQ_MAIN := requirements.txt
PIP_REQ_DEV := requirements-dev.txt
DOCKER_TAG := $(PROJECT)
DOCKER_APP := $(PROJECT)-app
DOCKER_HOST := localhost
DOCKER_PORT := 8080
SERVER_APP_PATH := $(ROOT)
SERVER_APP_NAME := $(PROJECT).app.main:application
SERVER_HOST := 127.0.0.1
SERVER_PORT := 8080
SERVER_MAIN_FLAGS = --host $(SERVER_HOST) --port $(SERVER_PORT) $(SERVER_APP_NAME)
SERVER_TEST_FLAGS = --reload $(SERVER_MAIN_FLAGS)
# --- Rules
help:
@echo "Make targets:"
@echo ""
@echo "Project builds:"
@echo ""
@echo " Notes:"
@echo " - These commands need an active virtualenv and use Poetry."
@echo " There are Pip equivalents but they are not make targets."
@echo ""
@echo " install - Install non-dev dependencies and main package"
@echo " develop - Install all dependencies and main package"
@echo " depends - Install all dependencies without the main package"
@echo ""
@echo " build - Build all distributable Python packages."
@echo " build-sdist - Build project as source tarball."
@echo " build-wheel - Build project as wheel."
@echo ""
@echo " clean - Remove all built Python packages."
@echo " clean-sdist - Remove built tarballs."
@echo " clean-wheel - Remove built wheels."
@echo ""
@echo "Pip requirements:"
@echo ""
@echo " pip-requirements - Export Pip requirements files with hashes."
@echo " pip-requirements-base - Export Pip requirements files without hashes."
@echo ""
@echo "Docker image:"
@echo ""
@echo " build-docker-image - Build Docker image from Dockerfile"
@echo " run-docker-image - Run Docker container"
@echo ""
@echo "PyTest: common commands"
@echo ""
@echo " test-all - Run all test cases"
@echo " test-one - Run until first failing case"
@echo " test-debug - Run debugger if any cases fail"
@echo ""
@echo "Uvicorn server"
@echo ""
@echo " serve - Run uvicorn server "
@echo ""
# Project builds
install:
poetry install --no-dev
develop:
poetry install
depends:
poetry install --no-root
build: build-sdist build-wheel
clean: clean-sdist clean-wheel
build-sdist:
poetry build -f sdist
clean-sdist:
rm -f dist/$(PROJECT)*.tar.gz
rmdir --ignore-fail-on-non-empty dist
build-wheel:
poetry build -f wheel
clean-wheel:
rm -f dist/$(PROJECT)*.whl
rmdir --ignore-fail-on-non-empty dist
# Pip requirements
pip-requirements:
poetry export -f requirements.txt > $(PIP_REQ_MAIN)
poetry export --dev -f requirements.txt > $(PIP_REQ_DEV)
pip-requirements-base:
poetry export --without-hashes -f requirements.txt > $(PIP_REQ_MAIN)
poetry export --without-hashes --dev -f requirements.txt > $(PIP_REQ_DEV)
# Docker
build-docker-image:
docker build -t "$(DOCKER_TAG)" .
run-docker-image: build-docker-image
docker run -it --rm --name "$(DOCKER_APP)" -p "$(DOCKER_PORT):$(DOCKER_PORT)" "$(DOCKER_TAG)"
# PyTest
test-all:
pytest
test-one:
pytest -x
test-debug:
pytest -x --pdb
# Uvicorn
serve:
uvicorn $(SERVER_MAIN_FLAGS)
serve-test:
uvicorn $(SERVER_TEST_FLAGS)