2019-04-15 17:17:10 +03:00
|
|
|
export PYTHON_COMMAND=python3
|
2018-09-05 12:23:49 +03:00
|
|
|
|
2019-10-22 12:24:05 +03:00
|
|
|
# As we're using user-local installs inside the docker-container we need
|
|
|
|
# to be cautious about uprading pip and not confusing it with the
|
|
|
|
# globally installed version. This will take `$PYTHONUSERBASE` and `$PIP_USER`
|
|
|
|
# into account.
|
|
|
|
# See https://github.com/pypa/pip/issues/7205
|
|
|
|
export PIP_COMMAND=$(PYTHON_COMMAND) -m pip
|
2019-08-29 14:10:25 +03:00
|
|
|
APP=src/olympia/
|
|
|
|
|
2017-06-15 11:41:40 +03:00
|
|
|
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/
|
2017-06-15 11:41:40 +03:00
|
|
|
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 \
|
|
|
|
|
2021-10-19 14:22:22 +03:00
|
|
|
# NODE_LIBS_JS and NODE_LIBS_JQUERY_UI are referenced in settings.MINIFY_BUNDLES - keep both lists in sync
|
2017-06-15 11:41:40 +03:00
|
|
|
NODE_LIBS_JS := \
|
|
|
|
less/dist/less.js \
|
2017-06-15 14:04:08 +03:00
|
|
|
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-11-24 17:41:59 +03:00
|
|
|
jszip/dist/jszip.js \
|
2017-06-15 14:04:08 +03:00
|
|
|
timeago/jquery.timeago.js \
|
2017-06-16 15:27:44 +03:00
|
|
|
underscore/underscore.js \
|
2022-09-12 12:11:44 +03:00
|
|
|
netmask/lib/netmask.js \
|
2017-06-15 11:41:40 +03:00
|
|
|
|
|
|
|
NODE_LIBS_JQUERY_UI := \
|
|
|
|
jquery-ui/ui/data.js \
|
|
|
|
jquery-ui/ui/scroll-parent.js \
|
|
|
|
jquery-ui/ui/widget.js \
|
2021-10-19 14:22:22 +03:00
|
|
|
jquery-ui/ui/widgets/mouse.js \
|
2017-06-15 11:41:40 +03:00
|
|
|
jquery-ui/ui/widgets/sortable.js
|
|
|
|
|
2019-02-13 18:21:05 +03:00
|
|
|
.PHONY: help_redirect
|
2017-06-15 11:41:40 +03:00
|
|
|
help_redirect:
|
|
|
|
@$(MAKE) help --no-print-directory
|
|
|
|
|
2019-02-13 18:21:05 +03:00
|
|
|
.PHONY: initialize_db
|
2019-08-29 16:34:26 +03:00
|
|
|
initialize_db: ## create a new database
|
2017-06-15 11:41:40 +03:00
|
|
|
rm -rf ./user-media/* ./tmp/*
|
2019-03-18 13:57:49 +03:00
|
|
|
$(PYTHON_COMMAND) manage.py create_db --force
|
2019-09-12 18:25:46 +03:00
|
|
|
$(PYTHON_COMMAND) manage.py migrate --noinput
|
2019-01-14 17:22:32 +03:00
|
|
|
$(PYTHON_COMMAND) manage.py loaddata initial.json
|
|
|
|
$(PYTHON_COMMAND) manage.py import_prod_versions
|
|
|
|
$(PYTHON_COMMAND) manage.py createsuperuser
|
|
|
|
$(PYTHON_COMMAND) manage.py loaddata zadmin/users
|
2017-06-15 11:41:40 +03:00
|
|
|
|
2019-02-13 18:21:05 +03:00
|
|
|
.PHONY: populate_data
|
2019-08-29 16:34:26 +03:00
|
|
|
populate_data: ## populate a new database
|
2017-06-15 11:41:40 +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.
|
2019-01-14 17:22:32 +03:00
|
|
|
$(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)
|
2018-08-29 17:13:22 +03:00
|
|
|
# These add-ons are specifically useful for the addons-frontend
|
|
|
|
# homepage. You may have to re-run this, in case the data there
|
|
|
|
# changes.
|
2019-01-14 17:22:32 +03:00
|
|
|
$(PYTHON_COMMAND) manage.py generate_default_addons_for_frontend
|
2018-08-29 17:13:22 +03:00
|
|
|
|
2017-06-15 11:41:40 +03:00
|
|
|
# Now that addons have been generated, reindex.
|
2019-01-14 17:22:32 +03:00
|
|
|
$(PYTHON_COMMAND) manage.py reindex --force --noinput
|
2017-06-15 11:41:40 +03:00
|
|
|
|
2019-02-13 18:21:05 +03:00
|
|
|
.PHONY: cleanup_python_build_dir
|
2018-07-19 13:13:19 +03:00
|
|
|
cleanup_python_build_dir:
|
|
|
|
# Work arounds "Multiple .dist-info directories" issue.
|
|
|
|
rm -rf /deps/build/*
|
|
|
|
|
2023-03-23 17:46:56 +03:00
|
|
|
.PHONY: install_python_codestyle_dependencies
|
|
|
|
install_python_codestyle_dependencies:
|
|
|
|
$(PIP_COMMAND) install --progress-bar=off --no-deps --exists-action=w -r requirements/codestyle.txt
|
|
|
|
|
2019-02-13 18:21:05 +03:00
|
|
|
.PHONY: install_python_test_dependencies
|
2018-09-05 12:23:49 +03:00
|
|
|
install_python_test_dependencies:
|
2023-05-15 15:51:24 +03:00
|
|
|
$(PIP_COMMAND) install --progress-bar=off --no-deps --exists-action=w -r requirements/system.txt
|
|
|
|
$(PIP_COMMAND) install --progress-bar=off --no-deps --exists-action=w -r requirements/prod.txt
|
2019-01-14 17:22:32 +03:00
|
|
|
$(PIP_COMMAND) install --progress-bar=off --no-deps --exists-action=w -r requirements/tests.txt
|
2018-06-25 13:53:45 +03:00
|
|
|
|
2019-02-13 18:21:05 +03:00
|
|
|
.PHONY: install_python_dev_dependencies
|
2023-03-23 17:46:56 +03:00
|
|
|
install_python_dev_dependencies: install_python_test_dependencies install_python_codestyle_dependencies
|
2019-01-14 17:22:32 +03:00
|
|
|
$(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/docs.txt
|
2020-12-10 18:46:53 +03:00
|
|
|
# pep 517 mode (the default) breaks editable install in our project. https://github.com/mozilla/addons-server/issues/16144
|
|
|
|
$(PIP_COMMAND) install --no-use-pep517 -e .
|
2017-06-15 11:41:40 +03:00
|
|
|
|
2019-02-13 18:21:05 +03:00
|
|
|
.PHONY: install_node_dependencies
|
2017-06-16 18:46:00 +03:00
|
|
|
install_node_dependencies: install_node_js copy_node_js
|
|
|
|
|
2019-02-13 18:21:05 +03:00
|
|
|
.PHONY: install_node_js
|
2017-06-16 18:46:00 +03:00
|
|
|
install_node_js:
|
2017-06-15 11:41:40 +03:00
|
|
|
npm install $(NPM_ARGS)
|
|
|
|
|
2019-02-13 18:21:05 +03:00
|
|
|
.PHONY: copy_node_js
|
2017-06-15 11:41:40 +03:00
|
|
|
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
|
2017-06-15 11:41:40 +03:00
|
|
|
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
|
|
|
|
|
2019-02-13 18:21:05 +03:00
|
|
|
.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
|
2017-06-15 11:41:40 +03:00
|
|
|
|
2019-02-13 18:21:05 +03:00
|
|
|
.PHONY: update_db
|
2019-08-29 16:34:26 +03:00
|
|
|
update_db: ## run the database migrations
|
2019-09-12 18:25:46 +03:00
|
|
|
$(PYTHON_COMMAND) manage.py migrate --noinput
|
2017-06-15 11:41:40 +03:00
|
|
|
|
2019-02-13 18:21:05 +03:00
|
|
|
.PHONY: update_assets
|
2017-06-15 11:41:40 +03:00
|
|
|
update_assets:
|
2018-10-11 11:35:46 +03:00
|
|
|
# If changing this here, make sure to adapt tests in amo/test_commands.py
|
2019-01-14 17:22:32 +03:00
|
|
|
$(PYTHON_COMMAND) manage.py compress_assets
|
|
|
|
$(PYTHON_COMMAND) manage.py collectstatic --noinput
|
2019-01-21 12:09:18 +03:00
|
|
|
$(PYTHON_COMMAND) manage.py generate_jsi18n_files
|
2017-06-15 11:41:40 +03:00
|
|
|
|
2019-02-13 18:21:05 +03:00
|
|
|
.PHONY: update
|
2019-08-29 16:34:26 +03:00
|
|
|
update: update_deps update_db update_assets ## update the dependencies, the database, and assets
|
2017-06-15 11:41:40 +03:00
|
|
|
|
2019-02-13 18:21:05 +03:00
|
|
|
.PHONY: reindex
|
2019-08-29 16:34:26 +03:00
|
|
|
reindex: ## reindex everything in elasticsearch, for AMO
|
2019-01-14 17:22:32 +03:00
|
|
|
$(PYTHON_COMMAND) manage.py reindex $(ARGS)
|
2017-06-15 11:41:40 +03:00
|
|
|
|
2019-02-13 18:21:05 +03:00
|
|
|
.PHONY: setup-ui-tests
|
2018-04-25 12:32:40 +03:00
|
|
|
setup-ui-tests:
|
2017-10-05 14:14:08 +03:00
|
|
|
rm -rf ./user-media/* ./tmp/*
|
2018-01-12 08:58:00 +03:00
|
|
|
# Reset the database and fake database migrations
|
2019-03-18 13:57:49 +03:00
|
|
|
$(PYTHON_COMMAND) manage.py create_db --force
|
2019-09-12 18:25:46 +03:00
|
|
|
$(PYTHON_COMMAND) manage.py migrate --noinput
|
2018-01-12 08:58:00 +03:00
|
|
|
|
2019-03-12 02:20:06 +03:00
|
|
|
# Reindex
|
|
|
|
$(PYTHON_COMMAND) manage.py reindex --force --noinput --wipe
|
|
|
|
|
2018-01-12 08:58:00 +03:00
|
|
|
# Let's load some initial data and import mozilla-product versions
|
2019-01-14 17:22:32 +03:00
|
|
|
$(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
|
2018-01-12 08:58:00 +03:00
|
|
|
|
|
|
|
# Create a proper superuser that can be used to access the API
|
2019-01-14 17:22:32 +03:00
|
|
|
$(PYTHON_COMMAND) manage.py waffle_switch super-create-accounts on --create
|
|
|
|
$(PYTHON_COMMAND) manage.py waffle_switch activate-autograph-signing on --create
|
2019-03-12 02:20:06 +03:00
|
|
|
$(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
|
|
|
|
|
2019-12-17 20:28:38 +03:00
|
|
|
# Now that addons have been generated, reindex.
|
|
|
|
$(PYTHON_COMMAND) manage.py reindex --force --noinput
|
2017-10-05 14:14:08 +03:00
|
|
|
|
2019-02-13 18:21:05 +03:00
|
|
|
.PHONY: perf-tests
|
2018-04-25 12:32:40 +03:00
|
|
|
perf-tests: setup-ui-tests
|
2019-01-14 17:22:32 +03:00
|
|
|
$(PIP_COMMAND) install --progress-bar=off --no-deps -r requirements/perftests.txt
|
2018-04-25 12:32:40 +03:00
|
|
|
locust --no-web -c 1 -f tests/performance/locustfile.py --host "http://olympia.test"
|
|
|
|
|
2020-05-15 16:53:13 +03:00
|
|
|
.PHONY: lint
|
|
|
|
lint: ## lint the code
|
2022-12-12 14:45:11 +03:00
|
|
|
black --check src/ tests/
|
2023-05-10 12:14:51 +03:00
|
|
|
ruff check .
|
2023-02-09 15:09:13 +03:00
|
|
|
NODE_PATH=$(NODE_MODULES) npm exec $(NPM_ARGS) -- prettier --check '**'
|
2020-09-29 12:56:33 +03:00
|
|
|
curlylint src/
|
2019-02-07 09:56:39 +03:00
|
|
|
|
2020-05-15 16:53:13 +03:00
|
|
|
lint-codestyle: lint
|
|
|
|
|
2019-02-13 18:21:05 +03:00
|
|
|
.PHONY: docs
|
2019-08-29 16:34:26 +03:00
|
|
|
docs: ## build the documentation
|
2019-02-13 18:21:05 +03:00
|
|
|
$(MAKE) -C docs html SPHINXOPTS='-nW'
|
|
|
|
|
2019-08-29 14:10:25 +03:00
|
|
|
.PHONY: debug
|
2019-08-29 16:34:26 +03:00
|
|
|
debug: ## connect for debugging
|
2019-08-29 14:10:25 +03:00
|
|
|
supervisorctl fg olympia
|
|
|
|
|
|
|
|
.PHONY: djshell
|
2019-08-29 16:34:26 +03:00
|
|
|
djshell: ## connect to django shell
|
2019-08-29 14:10:25 +03:00
|
|
|
$(PYTHON_COMMAND) ./manage.py shell_plus
|
|
|
|
|
|
|
|
.PHONY: dbshell
|
2019-08-29 16:34:26 +03:00
|
|
|
dbshell: ## connect to a database shell
|
2019-08-29 14:10:25 +03:00
|
|
|
$(PYTHON_COMMAND) ./manage.py dbshell
|
|
|
|
|
2019-02-13 18:21:05 +03:00
|
|
|
.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
|
2019-08-29 14:10:25 +03:00
|
|
|
|
2020-05-15 16:53:13 +03:00
|
|
|
.PHONY: reload
|
|
|
|
reload: ## force django code reload
|
2023-03-23 17:46:56 +03:00
|
|
|
uwsgi --reload ${HOME}/docker/artifacts/addons-server-uwsgi-master.pid
|
2019-08-29 14:10:25 +03:00
|
|
|
|
2020-05-15 16:53:13 +03:00
|
|
|
reload-uwsgi: reload
|
|
|
|
|
2019-08-29 14:10:25 +03:00
|
|
|
.PHONY: test
|
2019-08-29 16:34:26 +03:00
|
|
|
test: ## run the entire test suite
|
2019-08-29 14:10:25 +03:00
|
|
|
pytest $(APP) $(ARGS)
|
|
|
|
|
|
|
|
.PHONY: test_es
|
2019-08-29 16:34:26 +03:00
|
|
|
test_es: ## run the ES tests
|
2019-08-29 14:10:25 +03:00
|
|
|
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
|
2019-08-29 14:10:25 +03:00
|
|
|
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
|
2019-08-29 14:10:25 +03:00
|
|
|
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
|
2019-08-29 14:10:25 +03:00
|
|
|
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
|
2019-08-29 14:10:25 +03:00
|
|
|
pytest --lf $(ARGS) $(APP)
|
2019-08-29 16:34:26 +03:00
|
|
|
|
2020-07-30 15:00:07 +03:00
|
|
|
.PHONY: run_js_tests
|
|
|
|
run_js_tests: ## Run the JavaScript test suite (requires compiled/compressed assets).
|
2023-02-09 15:09:13 +03:00
|
|
|
NODE_PATH=$(NODE_MODULES) npm exec $(NPM_ARGS) -- jest
|
2020-07-30 15:00:07 +03:00
|
|
|
|
|
|
|
.PHONY: watch_js_tests
|
|
|
|
watch_js_tests: ## Run+watch the JavaScript test suite (requires compiled/compressed assets).
|
2023-02-09 15:09:13 +03:00
|
|
|
NODE_PATH=$(NODE_MODULES) npm exec $(NPM_ARGS) -- jest --watch
|
2019-08-29 16:34:26 +03:00
|
|
|
|
2020-08-03 15:55:07 +03:00
|
|
|
.PHONY: format
|
|
|
|
format: ## Autoformat our codebase.
|
2023-02-09 15:09:13 +03:00
|
|
|
NODE_PATH=$(NODE_MODULES) npm exec $(NPM_ARGS) -- prettier --write '**'
|
2023-05-10 12:14:51 +03:00
|
|
|
ruff check --fix-only .
|
2023-02-09 15:09:13 +03:00
|
|
|
black src/ tests/
|
2020-08-03 15:55:07 +03:00
|
|
|
|
2019-08-29 16:34:26 +03:00
|
|
|
.PHONY: help_submake
|
|
|
|
help_submake:
|
2019-09-12 19:48:45 +03:00
|
|
|
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' Makefile-docker | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
|