addons-server/Makefile

231 строка
7.5 KiB
Makefile
Исходник Обычный вид История

.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)
2016-06-25 02:57:53 +03:00
IN_DOCKER = $(wildcard /addons-server-centos7-container)
NPM_ARGS :=
ifneq ($(NPM_CONFIG_PREFIX),)
NPM_ARGS := --prefix $(NPM_CONFIG_PREFIX)
endif
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"
@echo " initialize_db to create a new database"
2016-06-25 02:57:53 +03:00
@echo " initialize_docker to initialize a docker image"
@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"
@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"
@echo "Check the Makefile to know exactly what each target is doing."
docs:
2015-08-26 20:35:10 +03:00
$(MAKE) -C docs html
test:
2016-06-25 02:57:53 +03:00
ifneq ($(IN_DOCKER),)
$(warning Command is designed to be run in the host)
endif
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
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
docker exec -t -i ${DOCKER_NAME} py.test -m "not es_tests" $(APP) $(ARGS)
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
docker exec -t -i ${DOCKER_NAME} py.test --create-db $(APP) $(ARGS)
tdd:
2016-06-25 02:57:53 +03:00
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:
2016-06-25 02:57:53 +03:00
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:
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
schematic --fake src/olympia/migrations/
2015-08-26 20:35:10 +03:00
python manage.py createsuperuser
python manage.py loaddata zadmin/users
populate_data:
2016-06-25 02:57:53 +03:00
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
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)
# 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:
2015-08-26 20:35:10 +03:00
git checkout master && git pull
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
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:
2016-06-25 02:57:53 +03:00
ifeq ($(IN_DOCKER),)
$(warning Command is designed to be run in the container)
endif
npm install $(NPM_ARGS)
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
update_db:
2016-06-25 02:57:53 +03:00
ifeq ($(IN_DOCKER),)
$(warning Command is designed to be run in the container)
endif
schematic src/olympia/migrations
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
update_docker:
2016-06-25 02:57:53 +03:00
ifneq ($(IN_DOCKER),)
$(warning Command is designed to be run in the host)
endif
docker exec -t -i ${DOCKER_NAME} make update_docker_inner
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
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
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
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:
flake8 src/
initialize_docker:
2016-06-25 02:57:53 +03:00
ifneq ($(IN_DOCKER),)
$(warning Command is designed to be run in the host)
endif
docker exec -t -i ${DOCKER_NAME} make initialize_docker_inner
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
debug:
2016-06-25 02:57:53 +03:00
ifneq ($(IN_DOCKER),)
$(warning Command is designed to be run in the host)
endif
docker exec -t -i ${DOCKER_NAME} supervisorctl fg olympia
shell:
2016-06-25 02:57:53 +03:00
ifneq ($(IN_DOCKER),)
$(warning Command is designed to be run in the host)
endif
docker exec -t -i ${DOCKER_NAME} bash
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
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
make:
2016-06-25 02:57:53 +03:00
ifeq ($(IN_DOCKER),)
$(warning Command is designed to be run in the host)
endif
docker exec -t -i ${DOCKER_NAME} make $(ARGS)