This repository has been archived by the owner on Nov 3, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Makefile
208 lines (155 loc) · 6.6 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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
APPS = asset-manager content-store govuk-content-schemas government-frontend \
publishing-api router router-api search-api \
specialist-publisher static \
collections frontend publisher \
whitehall content-tagger \
contacts-admin finder-frontend email-alert-api
RUBY_VERSION = `cat .ruby-version`
DOCKER_RUN = docker run --rm -v `pwd`:/app ruby:$(RUBY_VERSION)
DOCKER_COMPOSE_CMD = docker-compose -f docker-compose.yml
TEST_PROCESSES := 1
ifndef JENKINS_URL
DOCKER_COMPOSE_CMD += -f docker-compose.development.yml
endif
ifndef TEST_ARGS
ifdef FLAKY_ONLY
FLAKEY_ONLY = true
endif
ifdef FLAKEY_ONLY
TAGS = --tag flaky --tag flakey
else
TAGS = --tag ~flaky --tag ~flakey --tag ~new
endif
TEST_ARGS = spec -o '$(TAGS) $(EXTRA_TAGS)'
endif
TEST_CMD = $(DOCKER_COMPOSE_CMD) run publishing-e2e-tests bundle exec parallel_rspec -n $(TEST_PROCESSES) $(TEST_ARGS)
all:
$(MAKE) clone
$(MAKE) stop
$(MAKE) clean_docker
$(MAKE) pull build
$(MAKE) start
$(MAKE) test
$(MAKE) stop
$(APPS):
bin/clone-app $@
clone: $(APPS)
kill:
$(DOCKER_COMPOSE_CMD) kill
$(DOCKER_COMPOSE_CMD) rm -f
build: kill
$(DOCKER_COMPOSE_CMD) build --pull diet-error-handler publishing-e2e-tests $(APPS_TO_BUILD)
setup_dependencies:
$(DOCKER_COMPOSE_CMD) up -d elasticsearch6 memcached mongo-2.6 mongo-3.6 mysql postgres rabbitmq redis
bundle exec rake docker:wait_for_dbs
$(MAKE) setup_dbs
bundle exec rake docker:wait_for_rabbitmq
$(MAKE) setup_queues
setup_apps:
bundle exec rake docker:wait_for_publishing_api
$(MAKE) publish_routes
$(MAKE) populate_end_to_end_test_data_from_whitehall
$(DOCKER_COMPOSE_CMD) run --rm publishing-e2e-tests bundle exec rake govuk:wait_for_router
$(MAKE) finder_frontend_seed
bundle exec rake docker:wait_for_apps
setup_dbs: router_setup content_store_setup asset_manager_setup \
publishing_api_setup whitehall_setup \
content_tagger_setup specialist_publisher_setup \
publisher_setup search_api_setup \
contacts_admin_setup email_alert_api_setup
router_setup:
$(DOCKER_COMPOSE_CMD) run --rm --no-deps router-api bundle exec rake db:reset
$(DOCKER_COMPOSE_CMD) run --rm --no-deps draft-router-api bundle exec rake db:reset
content_store_setup:
$(DOCKER_COMPOSE_CMD) run --rm --no-deps content-store bundle exec rake db:reset
$(DOCKER_COMPOSE_CMD) run --rm --no-deps draft-content-store bundle exec rake db:reset
asset_manager_setup:
$(DOCKER_COMPOSE_CMD) run --rm --no-deps asset-manager bundle exec rake db:reset
publishing_api_setup:
$(DOCKER_COMPOSE_CMD) run --rm --no-deps publishing-api bundle exec rake db:reset
whitehall_setup:
$(DOCKER_COMPOSE_CMD) run --rm --no-deps whitehall-admin bundle exec rake db:reset
content_tagger_setup:
$(DOCKER_COMPOSE_CMD) run --rm --no-deps content-tagger bundle exec rake db:reset
specialist_publisher_setup:
$(DOCKER_COMPOSE_CMD) run --rm --no-deps specialist-publisher env RUN_SEEDS_IN_PRODUCTION=true bundle exec rake db:seed
publisher_setup:
$(DOCKER_COMPOSE_CMD) run --rm --no-deps publisher bundle exec rake db:reset
search_api_setup:
$(DOCKER_COMPOSE_CMD) run --rm --no-deps search-api env SEARCH_INDEX=all bundle exec rake search:create_all_indices
email_alert_api_setup:
$(DOCKER_COMPOSE_CMD) run --rm --no-deps email-alert-api bundle exec rake db:reset
contacts_admin_setup:
$(DOCKER_COMPOSE_CMD) run --rm --no-deps contacts-admin bundle exec rake db:reset
finder_frontend_seed:
$(DOCKER_COMPOSE_CMD) run --rm --no-deps finder-frontend bundle exec rake registries:cache_warm
setup_queues:
$(DOCKER_COMPOSE_CMD) run --rm --no-deps publishing-api bundle exec rake setup_exchange
$(DOCKER_COMPOSE_CMD) run --rm --no-deps publishing-api-worker bundle exec rails runner 'Sidekiq::Queue.new.clear'
$(DOCKER_COMPOSE_CMD) run --rm --no-deps search-api-worker bundle exec rake message_queue:create_queues
publish_routes: publish_search_api publish_specialist publish_frontend publish_contacts_admin publish_whitehall
publish_search_api:
$(DOCKER_COMPOSE_CMD) exec -T search-api bundle exec rake publishing_api:publish_special_routes
$(DOCKER_COMPOSE_CMD) exec -T search-api bundle exec rake publishing_api:publish_supergroup_finders
publish_specialist:
$(DOCKER_COMPOSE_CMD) exec -T specialist-publisher bundle exec rake publishing_api:publish_finders
publish_frontend:
$(DOCKER_COMPOSE_CMD) exec -T frontend bundle exec rake publishing_api:publish_special_routes
$(DOCKER_COMPOSE_CMD) exec -T frontend bundle exec rake publishing_api:publish_calendars
publish_contacts_admin:
$(DOCKER_COMPOSE_CMD) exec -T contacts-admin bundle exec rake finders:publish
publish_whitehall:
$(DOCKER_COMPOSE_CMD) exec -T whitehall-admin bundle exec rake publishing_api:publish_special_routes
populate_end_to_end_test_data_from_whitehall:
$(DOCKER_COMPOSE_CMD) exec -T whitehall-admin bundle exec rake publishing_api:bulk_republish:document_type[Organisation]
$(DOCKER_COMPOSE_CMD) exec -T whitehall-admin bundle exec rake taxonomy:populate_end_to_end_test_data
clean_apps:
$(DOCKER_RUN) bash -c 'rm -rf /app/apps/*'
clean_docker:
bundle exec rake docker:remove_built_app_images
clean_tmp:
$(DOCKER_RUN) bash -c 'find /app/tmp -not -name .keep -type f -delete'
$(DOCKER_RUN) bash -c 'find /app/tmp -depth -empty -type d -delete'
clean: clean_tmp clean_apps clean_docker
up:
$(DOCKER_COMPOSE_CMD) up -d
pull:
$(DOCKER_COMPOSE_CMD) pull --parallel --ignore-pull-failures
start:
$(MAKE) setup_dependencies
$(MAKE) up
$(MAKE) setup_apps
test:
$(TEST_CMD)
test-specialist-publisher:
EXTRA_TAGS='--tag specialist_publisher' $(MAKE) test
test-publisher:
EXTRA_TAGS='--tag publisher' $(MAKE) test
test-collections:
EXTRA_TAGS='--tag collections' $(MAKE) test
test-finder-frontend:
EXTRA_TAGS='--tag finder_frontend' $(MAKE) test
test-frontend:
EXTRA_TAGS='--tag frontend' $(MAKE) test
test-government-frontend:
EXTRA_TAGS='--tag government_frontend' $(MAKE) test
test-content-tagger:
EXTRA_TAGS='--tag content_tagger' $(MAKE) test
test-contacts-admin:
EXTRA_TAGS='--tag contacts_admin' $(MAKE) test
test-whitehall:
EXTRA_TAGS='--tag whitehall' $(MAKE) test
stop: kill
.PHONY: all $(APPS) clone kill build start up test stop \
test-specialist-publisher \
test-publisher \
test-frontend test-content-tagger test-contacts-admin test-finder-frontend \
router_setup content_store_setup asset_manager_setup \
publishing_api_setup whitehall_setup \
content_tagger_setup \
specialist_publisher_setup publisher_setup \
search_api_setup publish_search_api publish_specialist publish_frontend \
publish_contacts_admin publish_whitehall setup_dbs setup_queues \
contacts_admin_setup contact_admin_seed pull \
clean_apps clean_docker clean_tmp clean setup_apps setup_dependencies \
finder_frontend_seed