/
Makefile
146 lines (95 loc) · 3.73 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
140
141
142
143
144
145
# Makefile for Mercury data management framework
HOST=127.0.0.1
TEST_PATH=./tests
PHONY=clean
VIRTUALENV_NAME=mercury_test
VIRTUALENV_ROOT=~/.virtualenvs
IMAGE_VERSION = latest
PROJECT = mercury
COMPOSE = docker-compose -p ${PROJECT}
DOCKER = docker exec -it $(WEB) bash -c
HOST_UID = `id -u`
HOST_GID = `id -g`
# -------------- Basic targets --------------
clean:
find . -name '*.pyc' -exec rm --force {} +
find . -name '*.pyo' -exec rm --force {} +
find . -name '*~' -exec rm --force {} +
install-deps:
pip install -r requirements.txt
test_env:
mkdir -p $(VIRTUALENV_ROOT)
virtualenv --no-site-packages $(VIRTUALENV_ROOT)/$(VIRTUALENV_NAME)
cd $(VIRTUALENV_ROOT)/$(VIRTUALENV_NAME)/bin
python $(VIRTUALENV_ROOT)/$(VIRTUALENV_NAME)/bin/activate_this.py
$(VIRTUALENV_ROOT)/$(VIRTUALENV_NAME)/bin/pip install -r requirements.txt
test:
PYTHONPATH=./tests MERCURY_HOME=`pwd` pipenv run python -m unittest discover -t . ./tests -v
test_teamcity: test_env
PYTHONPATH=./tests $(VIRTUALENV_ROOT)/$(VIRTUALENV_NAME)/bin/python -m teamcity.unittestpy discover -t . ./tests -v
build-docs:
rm -f tempdata/*.py
ls scripts > tempdata/script_list.txt
cat tempdata/script_list.txt | xargs -I {} cp scripts/{} tempdata/{}.py
./extract_cmd_docs.py --dir scripts --list tempdata/script_list.txt > tempdata/doc_registry.json
cat tempdata/doc_registry.json \
| scripts/warp --j2 --template-file=templates/mercury_docs.py.j2 -s \
> mercury/mercury_docs.py
version:
python mark_version.py > version.py && cp version.py scripts/mercury-version && chmod u+x scripts/mercury-version
build-dist:
python setup.py sdist bdist_wheel
build-testdist:
python test_setup.py sdist bdist_wheel
clean-dist:
rm -rf dist/*
rm -rf build/*
pypi-upload:
twine upload -r dist/* --repository pypi
#-------------- Docker-aware build targets --------------
docker-build: FORCE
docker build -t binarymachines/mercury:${IMAGE_VERSION} -f conf/Dockerfile \
--build-arg "BINARY_BUILD_VERSION=${IMAGE_VERSION}" .
docker-build-clean: FORCE
docker build --no-cache -t binarymachines/mercury:${IMAGE_VERSION} -f conf/Dockerfile \
--build-arg "BINARY_BUILD_VERSION=${IMAGE_VERSION}" .
docker-pull: FORCE
docker pull binarymachines/mercury:${IMAGE_VERSION}
docker-pull-all: docker-pull FORCE
docker pull redis
docker pull couchbase
docker pull postgres
docker pull spotify/kafka
docker-push: FORCE
docker push binarymachines/mercury:${IMAGE_VERSION}
docker-tag-latest: FORCE
docker tag binarymachines/mercury:${IMAGE_VERSION} binarymachines:latest
docker-test: FORCE
./docker-test.sh
# ----- Dockerized local development -----
up: FORCE
${COMPOSE} up -d --no-build mercury
down: FORCE
${COMPOSE} down --remove-orphans -v
rm: FORCE
docker-compose rm -f
bounce: down rm up
sh: FORCE
${COMPOSE} run --rm mercury /bin/sh
lint: FORCE
${COMPOSE} run --rm mercury /bin/sh -c \
'flake8 --config=/opt/bamx/test/flake8.ini && \
echo -e "\n########## code style (flake8) PASSED ##########\n"'
typing: FORCE
${COMPOSE} run --rm mercury /bin/sh -c \
'mypy --config-file=/opt/bamx/test/mypy.ini /opt/bamx/src && \
echo -e "\n########## type check (mypy) PASSED ##########\n"'
pip-compile: FORCE
# NOTE: Fix file ownership at the end, instead of running the whole
# container as the host user/group. Due to an upstream limitation,
# `pip-compile` needs write access to `/root` for pip caching.
# https://github.com/jazzband/pip-tools/issues/395
${COMPOSE} run --rm mercury /bin/sh -c \
"pip-compile --rebuild --generate-hashes --output-file conf/deps/requirements.txt conf/deps/requirements-unpinned.txt && \
chown ${HOST_UID}:${HOST_GID} conf/deps/requirements.txt"
FORCE: # https://www.gnu.org/software/make/manual/html_node/Force-Targets.html#Force-Targets