-
Notifications
You must be signed in to change notification settings - Fork 24
/
Makefile
156 lines (133 loc) · 6.17 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
146
147
148
149
150
151
152
153
154
155
156
E2E_DIRECTORY = e2e
E2E_DOCKER_COMPOSE = $(E2E_DIRECTORY)/docker-compose.yml
SCRIPTS_DIRECTORY = scripts
NODE_MODULES_BIN = node_modules/.bin
MEDTAGGER_CONFIGURATION = $(PWD)/e2e/.medtagger.yml
NG_SERVE_PID_FILE = ng_serve.pid
REST_PID_FILE = rest.pid
WEBSOCKET_PID_FILE = websocket.pid
WORKERS_PID_FILE = workers.pid
#
# Docker - Build & Push to Docker Hub
#
docker_build:
docker-compose build medtagger_backend_rest medtagger_frontend medtagger_backend_websocket medtagger_backend_worker medtagger_backend_database_migrations
docker_push_stable: docker_push_version
docker push medtagger/frontend_ui:latest
docker push medtagger/backend_rest:latest
docker push medtagger/backend_websocket:latest
docker push medtagger/backend_worker:latest
docker push medtagger/backend_database_migrations:latest
docker_push_nightly: docker_push_version
docker push medtagger/frontend_ui:nightly
docker push medtagger/backend_rest:nightly
docker push medtagger/backend_websocket:nightly
docker push medtagger/backend_worker:nightly
docker push medtagger/backend_database_migrations:nightly
docker_tag_as_stable:
docker tag medtagger/frontend_ui:latest medtagger/frontend_ui:$(MEDTAGGER_VERSION)
docker tag medtagger/backend_rest:latest medtagger/backend_rest:$(MEDTAGGER_VERSION)
docker tag medtagger/backend_websocket:latest medtagger/backend_websocket:$(MEDTAGGER_VERSION)
docker tag medtagger/backend_worker:latest medtagger/backend_worker:$(MEDTAGGER_VERSION)
docker tag medtagger/backend_database_migrations:latest medtagger/backend_database_migrations:$(MEDTAGGER_VERSION)
docker_tag_as_latest:
docker tag medtagger/frontend_ui:$(MEDTAGGER_VERSION) medtagger/frontend_ui:latest
docker tag medtagger/backend_rest:$(MEDTAGGER_VERSION) medtagger/backend_rest:latest
docker tag medtagger/backend_websocket:$(MEDTAGGER_VERSION) medtagger/backend_websocket:latest
docker tag medtagger/backend_worker:$(MEDTAGGER_VERSION) medtagger/backend_worker:latest
docker tag medtagger/backend_database_migrations:$(MEDTAGGER_VERSION) medtagger/backend_database_migrations:latest
docker_tag_as_nightly:
docker tag medtagger/frontend_ui:$(MEDTAGGER_VERSION) medtagger/frontend_ui:nightly
docker tag medtagger/backend_rest:$(MEDTAGGER_VERSION) medtagger/backend_rest:nightly
docker tag medtagger/backend_websocket:$(MEDTAGGER_VERSION) medtagger/backend_websocket:nightly
docker tag medtagger/backend_worker:$(MEDTAGGER_VERSION) medtagger/backend_worker:nightly
docker tag medtagger/backend_database_migrations:$(MEDTAGGER_VERSION) medtagger/backend_database_migrations:nightly
docker_push_version:
docker push medtagger/frontend_ui:$(MEDTAGGER_VERSION)
docker push medtagger/backend_rest:$(MEDTAGGER_VERSION)
docker push medtagger/backend_websocket:$(MEDTAGGER_VERSION)
docker push medtagger/backend_worker:$(MEDTAGGER_VERSION)
docker push medtagger/backend_database_migrations:$(MEDTAGGER_VERSION)
#
# E2E Tests
#
e2e:
make e2e__prepare_environment
@if ! make e2e__run; then\
make e2e__stop_medtagger;\
make e2e__clear_dependencies;\
echo "E2E Tests failed!";\
exit 1;\
fi
make e2e__delete_environment
echo "E2E Tests passed!"
e2e_build_docker_compose:
docker-compose -f $(E2E_DOCKER_COMPOSE) build
e2e_run_on_docker_compose: e2e__docker_run_medtagger
cd e2e && npm install
@if ! make e2e__run_docker; then\
docker-compose -f $(E2E_DOCKER_COMPOSE) logs e2e_medtagger_backend_database_migrations;\
docker-compose -f $(E2E_DOCKER_COMPOSE) down;\
echo "E2E Tests failed!";\
exit 1;\
fi
docker-compose -f $(E2E_DOCKER_COMPOSE) down
echo "E2E Tests passed!"
e2e__docker_run_medtagger:
docker-compose -f $(E2E_DOCKER_COMPOSE) up -d
e2e__prepare_environment:
docker-compose -f $(E2E_DOCKER_COMPOSE) up -d e2e_cassandra e2e_postgres e2e_rabbitmq
cd e2e && npm install
. $(E2E_DIRECTORY)/configuration.sh && cd backend && ./$(SCRIPTS_DIRECTORY)/dev__prepare_backend.sh $(MEDTAGGER_CONFIGURATION)
e2e__start_medtagger:
@if test -f "$(NG_SERVE_PID_FILE)" || test -f "$(REST_PID_FILE)" || test -f "$(WEBSOCKET_PID_FILE)" || test -f "$(WORKERS_PID_FILE)"; then\
echo "MedTagger is already running! Please stop it with \"make e2e__stop_medtagger\" first!";\
exit 1;\
fi
cd frontend && { ng serve -c local & echo $$! > ../$(NG_SERVE_PID_FILE); }
. $(E2E_DIRECTORY)/configuration.sh && cd backend && { make run_rest & echo $$! > ../$(REST_PID_FILE); }
. $(E2E_DIRECTORY)/configuration.sh && cd backend && { make run_websocket & echo $$! > ../$(WEBSOCKET_PID_FILE); }
. $(E2E_DIRECTORY)/configuration.sh && cd backend && { make run_workers & echo $$! > ../$(WORKERS_PID_FILE); }
e2e__stop_medtagger:
@if test -f "$(NG_SERVE_PID_FILE)"; then\
echo "Killing Ng Serve!";\
kill `cat $(NG_SERVE_PID_FILE)` || echo "Process already killed!";\
fi
@if test -f "$(REST_PID_FILE)"; then\
echo "Killing REST API!";\
kill `cat $(REST_PID_FILE)` || echo "Process already killed!";\
fi
@if test -f "$(WEBSOCKET_PID_FILE)"; then\
echo "Killing WebSocket API!";\
kill `cat $(WEBSOCKET_PID_FILE)` || echo "Process already killed!";\
fi
@if test -f "$(WORKERS_PID_FILE)"; then\
echo "Killing Worker!";\
kill `cat $(WORKERS_PID_FILE)` || echo "Process already killed!";\
fi
rm -f $(NG_SERVE_PID_FILE)
rm -f $(REST_PID_FILE)
rm -f $(WEBSOCKET_PID_FILE)
rm -f $(WORKERS_PID_FILE)
e2e__run:
make e2e__start_medtagger
sleep 30 # Let's wait a while for booting up of all services
@if ! make e2e__execute; then \
make e2e__stop_medtagger;\
echo "E2E Tests failed!";\
exit 1;\
fi
make e2e__stop_medtagger
echo "E2E Tests passed!"
e2e__run_docker:
sleep 30 # Let's wait a while for booting up of all services
cd $(E2E_DIRECTORY) && CYPRESS_HOST_URL=http://localhost/ CYPRESS_API_URL=http://localhost/api/v1/ $(NODE_MODULES_BIN)/cypress run --record
e2e__execute:
cd $(E2E_DIRECTORY) && $(NODE_MODULES_BIN)/cypress run
e2e__delete_environment:
. $(E2E_DIRECTORY)/configuration.sh && cd backend && alembic downgrade base
make e2e__clear_dependencies
e2e__clear_dependencies:
docker-compose -f $(E2E_DOCKER_COMPOSE) down
.PHONY: docker_build docker_tag_as_latest docker_tag_as_nightly docker_push docker_push_nightly docker_push_version \
e2e e2e_docker e2e__prepare_environment e2e__run e2e__delete_environment e2e__clear_dependencies