This repository has been archived by the owner on Apr 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
126 lines (103 loc) · 4.76 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
.PHONY: all
all: help
.PHONY: help
help:
@echo frequently used:
@echo "\t"make tests-all" "- run all test
@echo "\t"make tests-quick" "- run only quick tests
@echo Pass options to ./runtests.py or pytest by setting PYTEST_ARGS:
@echo "\t"make tests-all PYTEST_ARGS=-ktest_label_water_l" "- run only a specific test
@echo
@echo available targets:
@$(MAKE) --no-print-directory _list_targets_on_separate_lines | sed -e 's/^/\t/'
.PHONY: list
list:
@$(MAKE) --no-print-directory _list_targets_on_separate_lines | xargs
.PHONY: _list_targets_on_separate_lines
_list_targets_on_separate_lines:
# Adopted from http://stackoverflow.com/a/26339924/674064
@$(MAKE) -pRrq -f $(lastword $(MAKEFILE_LIST)) : 2>/dev/null | \
awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | \
sort | \
egrep -v -e '^[^[:alnum:]]' -e '^$@$$'
PIP_TOOLS_SOURCE_SPEC_FILES := requirements.in requirements-all.in
PIP_TOOLS_COMPILED_SPEC_FILES := $(PIP_TOOLS_SOURCE_SPEC_FILES:.in=.txt)
.PHONY: pip-upgrade
pip-upgrade: $(PIP_TOOLS_SOURCE_SPEC_FILES)
PIP_COMPILE_FLAGS=--upgrade $(MAKE) --always-make $(PIP_TOOLS_COMPILED_SPEC_FILES)
@echo
@echo Updated compiled pip-tools spec files $<, but NOT INSTALLED, yet.
@echo Consider running
@echo "\t"make pip-sync-all
@echo or
@echo "\tpip-sync <compiled spec file> [<compiled spec file> ...]"
@echo e.g.
@echo "\t"pip-sync $(PIP_TOOLS_COMPILED_SPEC_FILES)
@echo now.
.PHONY: pip-sync-all
pip-sync-all: requirements-all.txt
pip-sync $?
%.txt: %.in
pip-compile ${PIP_COMPILE_FLAGS} --output-file $@ $<
.PHONY: tests-quick
tests-quick: up-redis up-pg
docker build -t worker:test -f Dockerfile.worker .
docker run --link pg_tests:postgres --link redis-local:redis -e DJANGO_DB_PORT=5432 -e DJANGO_DB_HOST=postgres -e DJANGO_SETTINGS_MODULE= -v "$$(pwd):/code" --rm worker:test bash -c 'cp -r /code /tmp/code && cd /tmp/code/ && ./runtests.py $(PYTEST_ARGS)'
.PHONY: tests-all
tests-all: up-redis up-pg up-pg_translit
docker build -t worker:test -f Dockerfile.worker .
docker run --link pg_translit:translit --link pg_tests:postgres --link redis-local:redis -e DJANGO_DB_PORT=5432 -e DJANGO_DB_HOST=postgres -e PG_TRANSLIT_PORT=5432 -e PG_TRANSLIT_HOST=translit -e DJANGO_SETTINGS_MODULE= -v "$$(pwd):/code" --rm worker:test bash -c 'cp -r /code /tmp/code && cd /tmp/code/ && ./runtests.py $(PYTEST_ARGS) --runslow'
.PHONY: tox
tox: up-redis up-pg up-pg_translit
tox --skip-missing-interpreters
.PHONY: up-redis
up-redis:
docker pull redis > /dev/null
docker create -p "127.0.0.1:6379:6379" --name redis-local redis > /dev/null 2>&1 || true
docker start redis-local > /dev/null 2>&1 || true
./docker_entrypoint/wait-for-it/wait-for-it.sh 127.0.0.1:6379 -t 20
.PHONY: down-redis
down-redis:
docker stop redis-local > /dev/null 2>&1 && docker rm -vf redis-local > /dev/null 2>&1 || true
.PHONY: up-pg
up-pg:
docker pull geometalab/postgis-with-translit > /dev/null
docker create -p "127.0.0.1:54321:5432" -e POSTGRES_DB='postgres' --name pg_tests geometalab/postgis-with-translit > /dev/null 2>&1 || true
docker start pg_tests
./docker_entrypoint/wait-for-it/wait-for-it.sh 127.0.0.1:54321 -t 20
.PHONY: down-pg
down-pg:
docker stop pg_tests > /dev/null 2>&1 && docker rm -vf pg_tests > /dev/null 2>&1 || true
.PHONY: up-pg_translit
up-pg_translit:
docker pull geometalab/postgis-with-translit > /dev/null
docker create -p "127.0.0.1:65432:5432" -e POSTGRES_DB='osmaxx_db' --name pg_translit geometalab/postgis-with-translit > /dev/null 2>&1 || true
docker start pg_translit
./docker_entrypoint/wait-for-it/wait-for-it.sh 127.0.0.1:65432 -t 20
.PHONY: down-pg_translit
down-pg_translit:
docker stop pg_translit > /dev/null 2>&1 && docker rm -vf pg_translit > /dev/null 2>&1 || true
.PHONY: clean
clean: down-redis down-pg_translit down-pg
find . -name __pycache__ -exec rm -rf {} +
find . -name "*.pyc" -exec rm -rf {} +
LOCAL_RUN_ONCE_SERVICES := osmboundaries_importer osm-pbf-updater
LOCAL_DB_SERVICES := frontenddatabase mediatordatabase osmboundaries-database
LOCAL_APPLICATION_STACK := nginx frontend mediator worker worker-exclusive conversionserviceredis
LOCAL_DEPLOY_VERSION := latest
PUBLIC_LOCALHOST_IP := $(shell ip route get 1 | awk '{print $$NF;exit}')
COMPOSE := PUBLIC_LOCALHOST_IP=${PUBLIC_LOCALHOST_IP} DEPLOY_VERSION=${LOCAL_DEPLOY_VERSION} docker-compose
.PHONY: up_local_run_once
up_local_run_once: up_local_db
${COMPOSE} up -d ${LOCAL_RUN_ONCE_SERVICES}
.PHONY: up_local_db
up_local_db:
${COMPOSE} up -d ${LOCAL_DB_SERVICES}
.PHONY: up_local
up_local: up_local_db
${COMPOSE} up -d ${LOCAL_APPLICATION_STACK}
.PHONY: up_local_all
up_local_all: build_local up_local_db up_local_run_once up_local
.PHONY: build_local
build_local:
${COMPOSE} build --pull