2019-01-14 17:22:32 +03:00
|
|
|
# Determine the python version (2 or 3) so we can load the correct
|
|
|
|
# requirements and python binary. It can be passed through the env variable
|
|
|
|
# PYTHON_VERSION_MAJOR so that both version can coexist in the container and
|
|
|
|
# be chosen when running docker-compose.
|
|
|
|
export PYTHON_VERSION_MAJOR ?= $(shell python -c 'import sys; print(sys.version_info.major)')
|
|
|
|
export PIP_COMMAND=pip${PYTHON_VERSION_MAJOR}
|
|
|
|
export PYTHON_COMMAND=python${PYTHON_VERSION_MAJOR}
|
2018-09-05 12:23:49 +03:00
|
|
|
|
2018-08-28 21:48:35 +03:00
|
|
|
# FXA username and password for ui-tests
|
2019-03-12 02:20:06 +03:00
|
|
|
export FXA_EMAIL=${UITEST_FXA_EMAIL}
|
|
|
|
export FXA_PASSWORD=${UITEST_FXA_PASSWORD}
|
2018-08-28 21:48:35 +03:00
|
|
|
|
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 \
|
|
|
|
|
2017-06-15 11:41:40 +03:00
|
|
|
NODE_LIBS_JS := \
|
|
|
|
less/dist/less.js \
|
2017-06-21 11:07:44 +03:00
|
|
|
jqmodal/jqModal.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-06-19 11:10:05 +03:00
|
|
|
jquery-pjax/jquery.pjax.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 \
|
2017-06-15 11:41:40 +03:00
|
|
|
|
|
|
|
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
|
|
|
|
|
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: help_submake
|
2017-06-15 11:41:40 +03:00
|
|
|
help_submake:
|
|
|
|
@echo "Commands that are designed be run in the container:"
|
|
|
|
@echo " initialize to init the dependencies, the database, and assets"
|
|
|
|
@echo " update to update the dependencies, the database, and assets"
|
|
|
|
@echo " initialize_db to create a new database"
|
|
|
|
@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"
|
2019-02-13 18:21:05 +03:00
|
|
|
@echo " docs to build the documentation"
|
|
|
|
@echo " lint-codestyle to lint the code"
|
2017-06-15 11:41:40 +03:00
|
|
|
|
2019-02-13 18:21:05 +03:00
|
|
|
.PHONY: initialize_db
|
2017-06-15 11:41:40 +03:00
|
|
|
initialize_db:
|
|
|
|
rm -rf ./user-media/* ./tmp/*
|
2019-01-14 17:22:32 +03:00
|
|
|
$(PYTHON_COMMAND) manage.py reset_db
|
|
|
|
$(PYTHON_COMMAND) manage.py migrate --noinput --run-syncdb
|
|
|
|
$(PYTHON_COMMAND) manage.py loaddata initial.json
|
|
|
|
$(PYTHON_COMMAND) manage.py import_prod_versions
|
2019-01-30 15:30:31 +03:00
|
|
|
./schematic --fake src/olympia/migrations/
|
2019-01-14 17:22:32 +03:00
|
|
|
$(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
|
2017-06-15 11:41:40 +03:00
|
|
|
populate_data:
|
|
|
|
# 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
|
|
|
# Also update category counts (denormalized field)
|
2019-01-14 17:22:32 +03:00
|
|
|
$(PYTHON_COMMAND) manage.py cron category_totals
|
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/*
|
|
|
|
|
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:
|
2018-04-16 12:16:16 +03:00
|
|
|
# Can't use --progress-bar=off for system packages as long as our docker image
|
|
|
|
# doesn't have pip 10 by default.
|
2019-01-14 17:22:32 +03:00
|
|
|
$(PIP_COMMAND) install --no-deps --exists-action=w -r requirements/system.txt
|
2019-02-25 15:39:13 +03:00
|
|
|
$(PIP_COMMAND) install --progress-bar=off --no-deps --exists-action=w -r requirements/prod_py${PYTHON_VERSION_MAJOR}${DJANGO}.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
|
2019-02-07 09:56:39 +03:00
|
|
|
install_python_dev_dependencies: install_python_test_dependencies setup-codestyle
|
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/dev_without_hash.txt
|
|
|
|
$(PIP_COMMAND) install --progress-bar=off --no-deps --exists-action=w -r requirements/docs.txt
|
|
|
|
$(PIP_COMMAND) install -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
|
2018-07-19 13:13:19 +03:00
|
|
|
update_deps: cleanup_python_build_dir install_python_dev_dependencies install_node_dependencies
|
2017-06-15 11:41:40 +03:00
|
|
|
|
2019-02-13 18:21:05 +03:00
|
|
|
.PHONY: update_db
|
2017-06-15 11:41:40 +03:00
|
|
|
update_db:
|
2019-01-30 15:30:31 +03:00
|
|
|
./schematic src/olympia/migrations
|
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
|
2017-06-16 18:46:00 +03:00
|
|
|
update: update_deps update_db update_assets
|
2017-06-15 11:41:40 +03:00
|
|
|
|
2019-02-13 18:21:05 +03:00
|
|
|
.PHONY: reindex
|
2017-06-15 11:41:40 +03:00
|
|
|
reindex:
|
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-01-14 17:22:32 +03:00
|
|
|
$(PYTHON_COMMAND) manage.py reset_db --noinput
|
|
|
|
$(PYTHON_COMMAND) manage.py migrate --noinput --run-syncdb
|
2019-01-30 15:30:31 +03:00
|
|
|
./schematic --fake src/olympia/migrations/
|
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
|
|
|
|
|
|
|
|
# Also update category counts (denormalized field)
|
|
|
|
$(PYTHON_COMMAND) manage.py cron category_totals
|
2018-01-12 08:58:00 +03:00
|
|
|
|
2019-02-13 18:21:05 +03:00
|
|
|
.PHONY: run-ui-tests
|
2019-03-12 02:20:06 +03:00
|
|
|
run-ui-tests:
|
|
|
|
docker-compose -f docker-compose.yml -f tests/ui/docker-compose.selenium.yml exec selenium-firefox tox -e ui-tests
|
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"
|
|
|
|
|
2019-02-13 18:21:05 +03:00
|
|
|
.PHONY: setup-codestyle
|
2019-02-07 09:56:39 +03:00
|
|
|
setup-codestyle:
|
|
|
|
$(PIP_COMMAND) install --progress-bar=off --no-deps --exists-action=w -r requirements/codestyle_py${PYTHON_VERSION_MAJOR}.txt
|
|
|
|
|
2019-02-13 18:21:05 +03:00
|
|
|
.PHONY: lint-codestyle
|
2019-02-07 09:56:39 +03:00
|
|
|
lint-codestyle:
|
|
|
|
flake8 src/ services/ tests/
|
|
|
|
|
2019-02-13 18:21:05 +03:00
|
|
|
.PHONY: docs
|
|
|
|
docs:
|
|
|
|
$(MAKE) -C docs html SPHINXOPTS='-nW'
|
|
|
|
|
|
|
|
.PHONY: initialize
|
2017-06-16 18:46:00 +03:00
|
|
|
initialize: update_deps initialize_db update_assets populate_data
|