addons-server/Makefile-docker

247 строки
8.3 KiB
Plaintext
Исходник Обычный вид История

export PIP_COMMAND=pip3
export PYTHON_COMMAND=python3
APP=src/olympia/
NUM_ADDONS=10
NUM_THEMES=$(NUM_ADDONS)
NPM_ARGS :=
ifneq ($(NPM_CONFIG_PREFIX),)
NPM_ARGS := --prefix $(NPM_CONFIG_PREFIX)
endif
NODE_MODULES := $(NPM_CONFIG_PREFIX)node_modules/
2017-06-21 18:06:31 +03:00
STATIC_CSS := static/css/node_lib/
STATIC_JS := static/js/node_lib/
STATIC_JQUERY_UI := static/js/node_lib/ui/
2017-06-21 18:06:31 +03:00
NODE_LIBS_CSS := \
@claviska/jquery-minicolors/jquery.minicolors.css \
@claviska/jquery-minicolors/jquery.minicolors.png \
NODE_LIBS_JS := \
less/dist/less.js \
jqmodal/jqModal.js \
jquery/dist/jquery.js \
jquery.browser/dist/jquery.browser.js \
jquery.cookie/jquery.cookie.js \
2017-06-21 18:06:31 +03:00
@claviska/jquery-minicolors/jquery.minicolors.js \
2017-06-19 11:10:05 +03:00
jquery-pjax/jquery.pjax.js \
2017-11-24 17:41:59 +03:00
jszip/dist/jszip.js \
timeago/jquery.timeago.js \
underscore/underscore.js \
NODE_LIBS_JQUERY_UI := \
jquery-ui/ui/version.js \
jquery-ui/ui/data.js \
jquery-ui/ui/disable-selection.js \
jquery-ui/ui/ie.js \
jquery-ui/ui/keycode.js \
jquery-ui/ui/escape-selector.js \
jquery-ui/ui/labels.js \
jquery-ui/ui/jquery-1-7.js \
jquery-ui/ui/plugin.js \
jquery-ui/ui/safe-active-element.js \
jquery-ui/ui/safe-blur.js \
jquery-ui/ui/scroll-parent.js \
jquery-ui/ui/focusable.js \
jquery-ui/ui/tabbable.js \
jquery-ui/ui/unique-id.js \
jquery-ui/ui/position.js \
jquery-ui/ui/widget.js \
jquery-ui/ui/widgets/menu.js \
jquery-ui/ui/widgets/mouse.js \
jquery-ui/ui/widgets/autocomplete.js \
jquery-ui/ui/widgets/datepicker.js \
jquery-ui/ui/widgets/sortable.js
.PHONY: help_redirect
help_redirect:
@$(MAKE) help --no-print-directory
.PHONY: initialize_db
2019-08-29 16:34:26 +03:00
initialize_db: ## create a new database
rm -rf ./user-media/* ./tmp/*
$(PYTHON_COMMAND) manage.py create_db --force
$(PYTHON_COMMAND) manage.py migrate --noinput --run-syncdb
$(PYTHON_COMMAND) manage.py loaddata initial.json
$(PYTHON_COMMAND) manage.py import_prod_versions
./schematic --fake src/olympia/migrations/
$(PYTHON_COMMAND) manage.py createsuperuser
$(PYTHON_COMMAND) manage.py loaddata zadmin/users
.PHONY: populate_data
2019-08-29 16:34:26 +03:00
populate_data: ## populate a new database
# 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_COMMAND) manage.py reindex --wipe --force --noinput
$(PYTHON_COMMAND) manage.py generate_addons --app firefox $(NUM_ADDONS)
$(PYTHON_COMMAND) manage.py generate_addons --app android $(NUM_ADDONS)
$(PYTHON_COMMAND) manage.py generate_themes $(NUM_THEMES)
# These add-ons are specifically useful for the addons-frontend
# homepage. You may have to re-run this, in case the data there
# changes.
$(PYTHON_COMMAND) manage.py generate_default_addons_for_frontend
# Now that addons have been generated, reindex.
$(PYTHON_COMMAND) manage.py reindex --force --noinput
# Also update category counts (denormalized field)
$(PYTHON_COMMAND) manage.py cron category_totals
.PHONY: cleanup_python_build_dir
cleanup_python_build_dir:
# Work arounds "Multiple .dist-info directories" issue.
rm -rf /deps/build/*
.PHONY: install_python_test_dependencies
install_python_test_dependencies:
# Can't use --progress-bar=off for system packages as long as our docker image
# doesn't have pip 10 by default.
$(PIP_COMMAND) install --no-deps --exists-action=w -r requirements/system.txt
$(PIP_COMMAND) install --progress-bar=off --no-deps --exists-action=w -r requirements/prod.txt
$(PIP_COMMAND) install --progress-bar=off --no-deps --exists-action=w -r requirements/prod_without_hash.txt
$(PIP_COMMAND) install --progress-bar=off --no-deps --exists-action=w -r requirements/tests.txt
.PHONY: install_python_dev_dependencies
install_python_dev_dependencies: install_python_test_dependencies setup-codestyle
$(PIP_COMMAND) install --progress-bar=off --no-deps --exists-action=w -r requirements/dev.txt
$(PIP_COMMAND) install --progress-bar=off --no-deps --exists-action=w -r requirements/dev_without_hash.txt
$(PIP_COMMAND) install --progress-bar=off --no-deps --exists-action=w -r requirements/docs.txt
$(PIP_COMMAND) install -e .
.PHONY: install_node_dependencies
install_node_dependencies: install_node_js copy_node_js
.PHONY: install_node_js
install_node_js:
npm install $(NPM_ARGS)
.PHONY: copy_node_js
copy_node_js:
2017-06-21 18:06:31 +03:00
for dest in $(NODE_LIBS_CSS) ; do cp $(NODE_MODULES)$$dest $(STATIC_CSS) ; done
for dest in $(NODE_LIBS_JS) ; do cp $(NODE_MODULES)$$dest $(STATIC_JS) ; done
for dest in $(NODE_LIBS_JQUERY_UI) ; do cp $(NODE_MODULES)$$dest $(STATIC_JQUERY_UI) ; done
.PHONY: update_deps
2019-08-29 16:34:26 +03:00
update_deps: cleanup_python_build_dir install_python_dev_dependencies install_node_dependencies ## update the python and node dependencies
.PHONY: update_db
2019-08-29 16:34:26 +03:00
update_db: ## run the database migrations
./schematic src/olympia/migrations
.PHONY: update_assets
update_assets:
# If changing this here, make sure to adapt tests in amo/test_commands.py
$(PYTHON_COMMAND) manage.py compress_assets
$(PYTHON_COMMAND) manage.py collectstatic --noinput
$(PYTHON_COMMAND) manage.py generate_jsi18n_files
.PHONY: update
2019-08-29 16:34:26 +03:00
update: update_deps update_db update_assets ## update the dependencies, the database, and assets
.PHONY: reindex
2019-08-29 16:34:26 +03:00
reindex: ## reindex everything in elasticsearch, for AMO
$(PYTHON_COMMAND) manage.py reindex $(ARGS)
.PHONY: setup-ui-tests
setup-ui-tests:
rm -rf ./user-media/* ./tmp/*
# Reset the database and fake database migrations
$(PYTHON_COMMAND) manage.py create_db --force
$(PYTHON_COMMAND) manage.py migrate --noinput --run-syncdb
./schematic --fake src/olympia/migrations/
# Reindex
$(PYTHON_COMMAND) manage.py reindex --force --noinput --wipe
# Let's load some initial data and import mozilla-product versions
$(PYTHON_COMMAND) manage.py loaddata initial.json
$(PYTHON_COMMAND) manage.py loaddata zadmin/users
$(PYTHON_COMMAND) manage.py loaddata src/olympia/access/fixtures/initial.json
$(PYTHON_COMMAND) manage.py import_prod_versions
# Create a proper superuser that can be used to access the API
$(PYTHON_COMMAND) manage.py waffle_switch super-create-accounts on --create
$(PYTHON_COMMAND) manage.py waffle_switch activate-autograph-signing on --create
$(PYTHON_COMMAND) manage.py generate_addons --app firefox $(NUM_ADDONS)
$(PYTHON_COMMAND) manage.py generate_addons --app android $(NUM_ADDONS)
$(PYTHON_COMMAND) manage.py generate_themes $(NUM_THEMES)
$(PYTHON_COMMAND) manage.py generate_default_addons_for_frontend
# Also update category counts (denormalized field)
$(PYTHON_COMMAND) manage.py cron category_totals
run-auto-approve:
$(PYTHON_COMMAND) tests/ui/run_auto_approve.py
.PHONY: run-ui-tests
run-ui-tests:
docker-compose -f docker-compose.yml -f tests/ui/docker-compose.selenium.yml exec selenium-firefox tox -e ui-tests
.PHONY: perf-tests
perf-tests: setup-ui-tests
$(PIP_COMMAND) install --progress-bar=off --no-deps -r requirements/perftests.txt
locust --no-web -c 1 -f tests/performance/locustfile.py --host "http://olympia.test"
.PHONY: setup-codestyle
setup-codestyle:
$(PIP_COMMAND) install --progress-bar=off --no-deps --exists-action=w -r requirements/codestyle.txt
.PHONY: lint-codestyle
2019-08-29 16:34:26 +03:00
lint-codestyle: ## lint the code
flake8 src/ services/ tests/
.PHONY: docs
2019-08-29 16:34:26 +03:00
docs: ## build the documentation
$(MAKE) -C docs html SPHINXOPTS='-nW'
.PHONY: debug
2019-08-29 16:34:26 +03:00
debug: ## connect for debugging
supervisorctl fg olympia
.PHONY: djshell
2019-08-29 16:34:26 +03:00
djshell: ## connect to django shell
$(PYTHON_COMMAND) ./manage.py shell_plus
.PHONY: dbshell
2019-08-29 16:34:26 +03:00
dbshell: ## connect to a database shell
$(PYTHON_COMMAND) ./manage.py dbshell
.PHONY: initialize
2019-08-29 16:34:26 +03:00
initialize: update_deps initialize_db update_assets populate_data ## init the dependencies, the database, and assets
.PHONY: reload-uwsgi
2019-08-29 16:34:26 +03:00
reload-uwsgi: ## force django code reload
uwsgi --reload /code/docker/artifacts/addons-server-uwsgi-master.pid
.PHONY: test
2019-08-29 16:34:26 +03:00
test: ## run the entire test suite
pytest $(APP) $(ARGS)
.PHONY: test_es
2019-08-29 16:34:26 +03:00
test_es: ## run the ES tests
pytest -m es_tests $(APP) $(ARGS)
.PHONY: test_no_es
2019-08-29 16:34:26 +03:00
test_no_es: ## run all but the ES tests
pytest -m "not es_tests" $(APP) $(ARGS)
.PHONY: test_force_db
2019-08-29 16:34:26 +03:00
test_force_db: ## run the entire test suite with a new database
pytest --create-db $(APP) $(ARGS)
.PHONY: tdd
2019-08-29 16:34:26 +03:00
tdd: ## run the entire test suite, but stop on the first error
pytest -x --pdb $(ARGS) $(APP)
.PHONY: test_failed
2019-08-29 16:34:26 +03:00
test_failed: ## rerun the failed tests from the previous run
pytest --lf $(ARGS) $(APP)
2019-08-29 16:34:26 +03:00
.PHONY: help_submake
help_submake:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'