forked from mozilla/addons-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
230 lines (194 loc) Β· 7.49 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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
.PHONY: help docs test test_es test_no_es test_force_db tdd test_failed initialize_db populate_data update_code update_deps update_db update_assets full_init full_update reindex flake8 update_docker initialize_docker shell debug
NUM_ADDONS=10
NUM_THEMES=$(NUM_ADDONS)
APP=src/olympia/
# Get the name of the Makefile's directory for the docker container base name.
mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST)))
current_dir := $(notdir $(patsubst %/,%,$(dir $(mkfile_path))))
COMPOSE_PROJECT_NAME?=$(shell echo "${current_dir}" | tr -d '-' | tr -d '_')
DOCKER_NAME="${COMPOSE_PROJECT_NAME}_web_1"
UNAME_S := $(shell uname -s)
IN_DOCKER = $(wildcard /addons-server-centos7-container)
NPM_ARGS :=
ifneq ($(NPM_CONFIG_PREFIX),)
NPM_ARGS := --prefix $(NPM_CONFIG_PREFIX)
endif
help:
@echo "Please use 'make <target>' where <target> is one of the following commands."
@echo "Commands that are designed be run in the container:"
@echo " full_init to init the code, the dependencies and the database"
@echo " full_update to update the code, the dependencies and the database"
@echo " initialize_db to create a new database"
@echo " initialize_docker to initialize a docker image"
@echo " populate_data to populate a new database"
@echo " reindex to reindex everything in elasticsearch, for AMO"
@echo " update_deps to update the pythondependencies"
@echo " update_db to run the database migrations"
@echo "Commands that are designed to be run in the host:"
@echo " debug to connect to a running addons-server docker for debugging"
@echo " djshell to connect to a running addons-server django docker shell"
@echo " make to connect to a running addons-server docker and run make ARGS"
@echo " shell to connect to a running addons-server docker shell"
@echo " tdd to run the entire test suite, but stop on the first error"
@echo " test to run the entire test suite"
@echo " test_es to run the ES tests"
@echo " test_failed to rerun the failed tests from the previous run"
@echo " test_force_db to run the entire test suite with a new database"
@echo " test_no_es to run all but the ES tests"
@echo " update_docker to update a docker image"
@echo "Commands that are designed to be run in either the container or the host:"
@echo " docs to builds the documentation"
@echo " flake8 to run the flake8 linter"
@echo " update_code to update the git repository"
@echo "Check the Makefile to know exactly what each target is doing."
docs:
$(MAKE) -C docs html
test:
ifneq ($(IN_DOCKER),)
$(warning Command is designed to be run in the host)
endif
docker exec -t -i ${DOCKER_NAME} py.test $(APP) $(ARGS)
test_es:
ifneq ($(IN_DOCKER),)
$(warning Command is designed to be run in the host)
endif
docker exec -t -i ${DOCKER_NAME} py.test -m es_tests $(APP) $(ARGS)
test_no_es:
ifneq ($(IN_DOCKER),)
$(warning Command is designed to be run in the host)
endif
docker exec -t -i ${DOCKER_NAME} py.test -m "not es_tests" $(APP) $(ARGS)
test_force_db:
ifneq ($(IN_DOCKER),)
$(warning Command is designed to be run in the host)
endif
docker exec -t -i ${DOCKER_NAME} py.test --create-db $(APP) $(ARGS)
tdd:
ifneq ($(IN_DOCKER),)
$(warning Command is designed to be run in the host)
endif
docker exec -t -i ${DOCKER_NAME} py.test -x --pdb $(ARGS) $(APP)
test_failed:
ifneq ($(IN_DOCKER),)
$(warning Command is designed to be run in the host)
endif
docker exec -t -i ${DOCKER_NAME} py.test --lf $(ARGS) $(APP)
initialize_db:
ifeq ($(IN_DOCKER),)
$(warning Command is designed to be run in the container)
endif
python manage.py reset_db
python manage.py syncdb --noinput
python manage.py loaddata initial.json
python manage.py import_prod_versions
schematic --fake src/olympia/migrations/
python manage.py createsuperuser
python manage.py loaddata zadmin/users
populate_data:
ifeq ($(IN_DOCKER),)
$(warning Command is designed to be run in the container)
endif
# reindex --wipe will force the ES mapping to be re-installed. Useful to
# make sure the mapping is correct before adding a bunch of add-ons.
python manage.py reindex --wipe --force --noinput
python manage.py generate_addons --app firefox $(NUM_ADDONS)
python manage.py generate_addons --app thunderbird $(NUM_ADDONS)
python manage.py generate_addons --app android $(NUM_ADDONS)
python manage.py generate_addons --app seamonkey $(NUM_ADDONS)
python manage.py generate_themes $(NUM_THEMES)
# Now that addons have been generated, reindex.
python manage.py reindex --force --noinput
# Also update category counts (denormalized field)
python manage.py cron category_totals
update_code:
git checkout master && git pull
install_python_dependencies:
ifeq ($(IN_DOCKER),)
$(warning Command is designed to be run in the container)
endif
pip install -e .
pip install --no-deps --exists-action=w -r requirements/flake8.txt
pip install --no-deps --exists-action=w -r requirements/dev.txt
pip install --no-deps --exists-action=w -r requirements/docs.txt
pip install --no-deps --exists-action=w -r requirements/prod_without_hash.txt
install_node_dependencies:
ifeq ($(IN_DOCKER),)
$(warning Command is designed to be run in the container)
endif
npm install $(NPM_ARGS)
update_deps:
ifeq ($(IN_DOCKER),)
$(warning Command is designed to be run in the container)
endif
$(MAKE) install_python_dependencies install_node_dependencies
update_db:
ifeq ($(IN_DOCKER),)
$(warning Command is designed to be run in the container)
endif
schematic src/olympia/migrations
update_assets:
ifeq ($(IN_DOCKER),)
$(warning Command is designed to be run in the container)
endif
python manage.py compress_assets
python manage.py collectstatic --noinput
update_docker:
ifneq ($(IN_DOCKER),)
$(warning Command is designed to be run in the host)
endif
docker exec -t -i ${DOCKER_NAME} make update_docker_inner
update_docker_inner:
ifeq ($(IN_DOCKER),)
$(warning Command is designed to be run in the container)
endif
$(MAKE) update_deps update_db update_assets
full_init:
ifeq ($(IN_DOCKER),)
$(warning Command is designed to be run in the container)
endif
$(MAKE) update_deps initialize_db populate_data update_assets
full_update:
ifeq ($(IN_DOCKER),)
$(warning Command is designed to be run in the container)
endif
$(MAKE) update_code update_deps update_db update_assets
reindex:
ifeq ($(IN_DOCKER),)
$(warning Command is designed to be run in the container)
endif
python manage.py reindex $(ARGS)
# Guessing that people could have flake8 locally and it could work in
# both the container and in the host.
flake8:
flake8 src/
initialize_docker:
ifneq ($(IN_DOCKER),)
$(warning Command is designed to be run in the host)
endif
docker exec -t -i ${DOCKER_NAME} make initialize_docker_inner
initialize_docker_inner:
ifeq ($(IN_DOCKER),)
$(warning Command is designed to be run in the container)
endif
$(MAKE) initialize_db update_assets populate_data
debug:
ifneq ($(IN_DOCKER),)
$(warning Command is designed to be run in the host)
endif
docker exec -t -i ${DOCKER_NAME} supervisorctl fg olympia
shell:
ifneq ($(IN_DOCKER),)
$(warning Command is designed to be run in the host)
endif
docker exec -t -i ${DOCKER_NAME} bash
djshell:
ifneq ($(IN_DOCKER),)
$(warning Command is designed to be run in the host)
endif
docker exec -t -i ${DOCKER_NAME} ./manage.py shell
# Run a make command in the container
make:
ifeq ($(IN_DOCKER),)
$(warning Command is designed to be run in the host)
endif
docker exec -t -i ${DOCKER_NAME} make $(ARGS)