2015-10-22 00:48:12 +03:00
|
|
|
.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
|
2014-10-13 17:42:34 +04:00
|
|
|
NUM_ADDONS=10
|
|
|
|
NUM_THEMES=$(NUM_ADDONS)
|
2013-11-20 15:00:42 +04:00
|
|
|
|
2016-07-05 17:49:16 +03:00
|
|
|
APP=src/olympia/
|
|
|
|
|
2016-02-11 20:16:01 +03:00
|
|
|
# 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 '_')
|
2015-10-27 03:27:51 +03:00
|
|
|
DOCKER_NAME="${COMPOSE_PROJECT_NAME}_web_1"
|
|
|
|
|
2014-10-28 17:37:38 +03:00
|
|
|
UNAME_S := $(shell uname -s)
|
|
|
|
|
2016-06-25 02:57:53 +03:00
|
|
|
IN_DOCKER = $(wildcard /addons-server-centos7-container)
|
2016-05-17 15:07:33 +03:00
|
|
|
|
2016-05-19 12:26:46 +03:00
|
|
|
NPM_ARGS :=
|
|
|
|
|
|
|
|
ifneq ($(NPM_CONFIG_PREFIX),)
|
|
|
|
NPM_ARGS := --prefix $(NPM_CONFIG_PREFIX)
|
|
|
|
endif
|
|
|
|
|
2013-11-20 15:00:42 +04:00
|
|
|
help:
|
2016-06-25 02:57:53 +03:00
|
|
|
@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"
|
2014-09-18 21:55:51 +04:00
|
|
|
@echo " initialize_db to create a new database"
|
2016-06-25 02:57:53 +03:00
|
|
|
@echo " initialize_docker to initialize a docker image"
|
2014-09-29 18:04:49 +04:00
|
|
|
@echo " populate_data to populate a new database"
|
2016-06-25 02:57:53 +03:00
|
|
|
@echo " reindex to reindex everything in elasticsearch, for AMO"
|
2015-09-29 11:38:50 +03:00
|
|
|
@echo " update_deps to update the pythondependencies"
|
2014-08-07 15:11:48 +04:00
|
|
|
@echo " update_db to run the database migrations"
|
2016-06-25 02:57:53 +03:00
|
|
|
@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"
|
2015-08-07 06:20:42 +03:00
|
|
|
@echo " update_docker to update a docker image"
|
2016-06-25 02:57:53 +03:00
|
|
|
@echo "Commands that are designed to be run in either the container or the host:"
|
|
|
|
@echo " docs to builds the documentation"
|
2014-10-21 20:01:56 +04:00
|
|
|
@echo " flake8 to run the flake8 linter"
|
2016-06-25 02:57:53 +03:00
|
|
|
@echo " update_code to update the git repository"
|
|
|
|
|
2016-05-17 15:07:33 +03:00
|
|
|
@echo "Check the Makefile to know exactly what each target is doing."
|
2013-11-20 15:00:42 +04:00
|
|
|
|
|
|
|
docs:
|
2015-08-26 20:35:10 +03:00
|
|
|
$(MAKE) -C docs html
|
2013-11-20 15:00:42 +04:00
|
|
|
|
|
|
|
test:
|
2016-06-25 02:57:53 +03:00
|
|
|
ifneq ($(IN_DOCKER),)
|
|
|
|
$(warning Command is designed to be run in the host)
|
|
|
|
endif
|
2016-07-05 17:49:16 +03:00
|
|
|
docker exec -t -i ${DOCKER_NAME} py.test $(APP) $(ARGS)
|
2014-11-19 19:36:40 +03:00
|
|
|
|
|
|
|
test_es:
|
2016-06-25 02:57:53 +03:00
|
|
|
ifneq ($(IN_DOCKER),)
|
|
|
|
$(warning Command is designed to be run in the host)
|
|
|
|
endif
|
2016-07-05 17:49:16 +03:00
|
|
|
docker exec -t -i ${DOCKER_NAME} py.test -m es_tests $(APP) $(ARGS)
|
2016-06-25 02:57:53 +03:00
|
|
|
|
2014-11-19 19:36:40 +03:00
|
|
|
test_no_es:
|
2016-06-25 02:57:53 +03:00
|
|
|
ifneq ($(IN_DOCKER),)
|
|
|
|
$(warning Command is designed to be run in the host)
|
|
|
|
endif
|
2016-07-05 17:49:16 +03:00
|
|
|
docker exec -t -i ${DOCKER_NAME} py.test -m "not es_tests" $(APP) $(ARGS)
|
2013-11-20 15:00:42 +04:00
|
|
|
|
|
|
|
test_force_db:
|
2016-06-25 02:57:53 +03:00
|
|
|
ifneq ($(IN_DOCKER),)
|
|
|
|
$(warning Command is designed to be run in the host)
|
|
|
|
endif
|
2016-07-05 17:49:16 +03:00
|
|
|
docker exec -t -i ${DOCKER_NAME} py.test --create-db $(APP) $(ARGS)
|
2013-11-20 15:00:42 +04:00
|
|
|
|
|
|
|
tdd:
|
2016-06-25 02:57:53 +03:00
|
|
|
ifneq ($(IN_DOCKER),)
|
|
|
|
$(warning Command is designed to be run in the host)
|
|
|
|
endif
|
2016-07-05 17:49:16 +03:00
|
|
|
docker exec -t -i ${DOCKER_NAME} py.test -x --pdb $(ARGS) $(APP)
|
2013-11-20 15:00:42 +04:00
|
|
|
|
|
|
|
test_failed:
|
2016-06-25 02:57:53 +03:00
|
|
|
ifneq ($(IN_DOCKER),)
|
|
|
|
$(warning Command is designed to be run in the host)
|
|
|
|
endif
|
2016-07-05 17:49:16 +03:00
|
|
|
docker exec -t -i ${DOCKER_NAME} py.test --lf $(ARGS) $(APP)
|
2013-11-20 15:00:42 +04:00
|
|
|
|
2014-09-18 21:55:51 +04:00
|
|
|
initialize_db:
|
2016-06-25 02:57:53 +03:00
|
|
|
ifeq ($(IN_DOCKER),)
|
|
|
|
$(warning Command is designed to be run in the container)
|
|
|
|
endif
|
2015-08-26 20:35:10 +03:00
|
|
|
python manage.py reset_db
|
|
|
|
python manage.py syncdb --noinput
|
|
|
|
python manage.py loaddata initial.json
|
|
|
|
python manage.py import_prod_versions
|
2016-01-04 12:24:35 +03:00
|
|
|
schematic --fake src/olympia/migrations/
|
2015-08-26 20:35:10 +03:00
|
|
|
python manage.py createsuperuser
|
|
|
|
python manage.py loaddata zadmin/users
|
2014-09-18 21:55:51 +04:00
|
|
|
|
2014-09-29 18:04:49 +04:00
|
|
|
populate_data:
|
2016-06-25 02:57:53 +03:00
|
|
|
ifeq ($(IN_DOCKER),)
|
|
|
|
$(warning Command is designed to be run in the container)
|
|
|
|
endif
|
2016-05-25 16:17:15 +03:00
|
|
|
# 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
|
2015-08-26 20:35:10 +03:00
|
|
|
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)
|
2016-05-25 16:17:15 +03:00
|
|
|
# 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
|
2014-09-29 18:04:49 +04:00
|
|
|
|
2014-04-22 13:17:21 +04:00
|
|
|
update_code:
|
2015-08-26 20:35:10 +03:00
|
|
|
git checkout master && git pull
|
2014-04-22 13:17:21 +04:00
|
|
|
|
2016-05-12 19:31:40 +03:00
|
|
|
install_python_dependencies:
|
2016-06-25 02:57:53 +03:00
|
|
|
ifeq ($(IN_DOCKER),)
|
|
|
|
$(warning Command is designed to be run in the container)
|
|
|
|
endif
|
2016-01-04 12:24:35 +03:00
|
|
|
pip install -e .
|
2016-07-19 16:46:09 +03:00
|
|
|
pip install --no-deps --exists-action=w -r requirements/flake8.txt
|
2016-06-15 16:12:43 +03:00
|
|
|
pip install --no-deps --exists-action=w -r requirements/dev.txt
|
2016-06-14 18:20:55 +03:00
|
|
|
pip install --no-deps --exists-action=w -r requirements/docs.txt
|
2016-05-12 19:31:40 +03:00
|
|
|
pip install --no-deps --exists-action=w -r requirements/prod_without_hash.txt
|
|
|
|
|
|
|
|
install_node_dependencies:
|
2016-06-25 02:57:53 +03:00
|
|
|
ifeq ($(IN_DOCKER),)
|
|
|
|
$(warning Command is designed to be run in the container)
|
|
|
|
endif
|
2016-05-19 12:26:46 +03:00
|
|
|
npm install $(NPM_ARGS)
|
2016-05-12 19:31:40 +03:00
|
|
|
|
2016-06-25 02:57:53 +03:00
|
|
|
update_deps:
|
|
|
|
ifeq ($(IN_DOCKER),)
|
|
|
|
$(warning Command is designed to be run in the container)
|
|
|
|
endif
|
|
|
|
$(MAKE) install_python_dependencies install_node_dependencies
|
2015-08-07 06:20:42 +03:00
|
|
|
|
2014-04-22 13:17:21 +04:00
|
|
|
update_db:
|
2016-06-25 02:57:53 +03:00
|
|
|
ifeq ($(IN_DOCKER),)
|
|
|
|
$(warning Command is designed to be run in the container)
|
|
|
|
endif
|
2016-01-04 12:24:35 +03:00
|
|
|
schematic src/olympia/migrations
|
2013-11-20 15:00:42 +04:00
|
|
|
|
2015-09-29 11:38:50 +03:00
|
|
|
update_assets:
|
2016-06-25 02:57:53 +03:00
|
|
|
ifeq ($(IN_DOCKER),)
|
|
|
|
$(warning Command is designed to be run in the container)
|
|
|
|
endif
|
2015-08-26 20:35:10 +03:00
|
|
|
python manage.py compress_assets
|
|
|
|
python manage.py collectstatic --noinput
|
2014-06-04 13:08:02 +04:00
|
|
|
|
2015-10-22 00:48:12 +03:00
|
|
|
update_docker:
|
2016-06-25 02:57:53 +03:00
|
|
|
ifneq ($(IN_DOCKER),)
|
|
|
|
$(warning Command is designed to be run in the host)
|
|
|
|
endif
|
2015-10-27 03:27:51 +03:00
|
|
|
docker exec -t -i ${DOCKER_NAME} make update_docker_inner
|
2015-08-07 06:20:42 +03:00
|
|
|
|
2016-06-25 02:57:53 +03:00
|
|
|
update_docker_inner:
|
|
|
|
ifeq ($(IN_DOCKER),)
|
|
|
|
$(warning Command is designed to be run in the container)
|
|
|
|
endif
|
|
|
|
$(MAKE) update_deps update_db update_assets
|
2015-08-07 06:20:42 +03:00
|
|
|
|
2016-06-25 02:57:53 +03:00
|
|
|
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
|
2014-04-22 13:17:21 +04:00
|
|
|
|
2016-06-25 02:57:53 +03:00
|
|
|
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
|
2013-11-20 15:00:42 +04:00
|
|
|
|
|
|
|
reindex:
|
2016-06-25 02:57:53 +03:00
|
|
|
ifeq ($(IN_DOCKER),)
|
|
|
|
$(warning Command is designed to be run in the container)
|
|
|
|
endif
|
2015-08-26 20:35:10 +03:00
|
|
|
python manage.py reindex $(ARGS)
|
2014-10-21 20:01:56 +04:00
|
|
|
|
2016-06-25 02:57:53 +03:00
|
|
|
# Guessing that people could have flake8 locally and it could work in
|
|
|
|
# both the container and in the host.
|
2014-10-21 20:01:56 +04:00
|
|
|
flake8:
|
2016-07-19 16:46:09 +03:00
|
|
|
flake8 src/
|
2015-10-22 00:48:12 +03:00
|
|
|
|
|
|
|
initialize_docker:
|
2016-06-25 02:57:53 +03:00
|
|
|
ifneq ($(IN_DOCKER),)
|
|
|
|
$(warning Command is designed to be run in the host)
|
|
|
|
endif
|
2015-10-27 03:27:51 +03:00
|
|
|
docker exec -t -i ${DOCKER_NAME} make initialize_docker_inner
|
2015-10-22 00:48:12 +03:00
|
|
|
|
2016-06-25 02:57:53 +03:00
|
|
|
initialize_docker_inner:
|
|
|
|
ifeq ($(IN_DOCKER),)
|
|
|
|
$(warning Command is designed to be run in the container)
|
|
|
|
endif
|
|
|
|
$(MAKE) initialize_db update_assets populate_data
|
2015-10-22 00:48:12 +03:00
|
|
|
|
|
|
|
debug:
|
2016-06-25 02:57:53 +03:00
|
|
|
ifneq ($(IN_DOCKER),)
|
|
|
|
$(warning Command is designed to be run in the host)
|
|
|
|
endif
|
2015-10-27 03:27:51 +03:00
|
|
|
docker exec -t -i ${DOCKER_NAME} supervisorctl fg olympia
|
2015-10-22 00:48:12 +03:00
|
|
|
|
|
|
|
shell:
|
2016-06-25 02:57:53 +03:00
|
|
|
ifneq ($(IN_DOCKER),)
|
|
|
|
$(warning Command is designed to be run in the host)
|
|
|
|
endif
|
2015-10-27 03:27:51 +03:00
|
|
|
docker exec -t -i ${DOCKER_NAME} bash
|
2015-10-22 00:48:12 +03:00
|
|
|
|
2015-10-23 21:24:46 +03:00
|
|
|
djshell:
|
2016-06-25 02:57:53 +03:00
|
|
|
ifneq ($(IN_DOCKER),)
|
|
|
|
$(warning Command is designed to be run in the host)
|
|
|
|
endif
|
2015-10-27 03:27:51 +03:00
|
|
|
docker exec -t -i ${DOCKER_NAME} ./manage.py shell
|
2015-10-23 21:24:46 +03:00
|
|
|
|
2016-06-25 02:57:53 +03:00
|
|
|
# Run a make command in the container
|
2015-10-22 00:48:12 +03:00
|
|
|
make:
|
2016-06-25 02:57:53 +03:00
|
|
|
ifeq ($(IN_DOCKER),)
|
|
|
|
$(warning Command is designed to be run in the host)
|
|
|
|
endif
|
2015-10-27 03:27:51 +03:00
|
|
|
docker exec -t -i ${DOCKER_NAME} make $(ARGS)
|