From 9cf1d44ee7baeaa47fecd031331fbcfa373555e1 Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Tue, 8 Oct 2019 09:33:39 -0400 Subject: [PATCH] Move Makefile versions to variables Signed-off-by: Roberto Rosario --- Makefile | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index e5de22ab31..489c40d584 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,15 @@ .PHONY: clean-pyc clean-build +DOCKER_MYSQL_IMAGE = mysql:8.0 +DOCKER_ORACLE_IMAGE = wnameless/oracle-xe-11g +DOCKER_POSTGRES_IMAGE = postgres:9.6-alpine +DOCKER_REDIS_IMAGE = redis:5.0-alpine + +PYTHON_MYSQL_VERSION = 1.4.4 +PYTHON_PSYCOPG2_VERSION = 2.8.3 +PYTHON_RABBITMQ_VERSION = 2.0.0 +PYTHON_REDIS_VERSION = 3.2.1 + help: @echo "Usage: make \n" @awk 'BEGIN {FS = ":.*##"} /^[a-zA-Z_-]+:.*?## / { printf " * %-40s -%s\n", $$1, $$2 }' $(MAKEFILE_LIST)|sort @@ -18,7 +28,7 @@ clean-pyc: ## Remove Python artifacts. find . -name '*.pyc' -exec rm -f {} + find . -name '*.pyo' -exec rm -f {} + find . -name '*~' -exec rm -f {} + - find . -name '__pycache__' -exec rm -R -f {} + + find . -name '__pycache__' -exec rm -R -f {} + # Testing @@ -33,10 +43,10 @@ test-all: clean-pyc test-launch-postgres: @docker rm -f test-postgres || true @docker volume rm test-postgres || true - docker run -d --name test-postgres -p 5432:5432 -v test-postgres:/var/lib/postgresql/data healthcheck/postgres + docker run -d --name test-postgres -p 5432:5432 -v test-postgres:/var/lib/postgresql/data $(DOCKER_POSTGRES_IMAGE) sudo apt-get install -q libpq-dev - pip install psycopg2 - while ! docker inspect --format='{{json .State.Health}}' test-postgres|grep 'Status":"healthy"'; do sleep 1; done + pip install psycopg2==$(PYTHON_PSYCOPG2_VERSION) + while ! nc -z 127.0.0.1 5432; do sleep 1; done test-with-postgres: ## MODULE= - Run tests for a single app, module or test class against a Postgres database container. test-with-postgres: test-launch-postgres @@ -53,10 +63,10 @@ test-with-postgres-all: test-launch-postgres test-launch-mysql: @docker rm -f test-mysql || true @docker volume rm test-mysql || true - docker run -d --name test-mysql -p 3306:3306 -e MYSQL_ALLOW_EMPTY_PASSWORD=True -e MYSQL_DATABASE=mayan -v test-mysql:/var/lib/mysql healthcheck/mysql + docker run -d --name test-mysql -p 3306:3306 -e MYSQL_ALLOW_EMPTY_PASSWORD=True -e MYSQL_DATABASE=mayan -v test-mysql:/var/lib/mysql $(DOCKER_MYSQL_IMAGE) sudo apt-get install -q libmysqlclient-dev mysql-client - pip install mysqlclient - while ! docker inspect --format='{{json .State.Health}}' test-mysql|grep 'Status":"healthy"'; do sleep 1; done + pip install mysqlclient==$(PYTHON_MYSQL_VERSION) + while ! nc -z 127.0.0.1 3306; do sleep 1; done mysql -h 127.0.0.1 -P 3306 -uroot -e "set global character_set_server=utf8mb4;" test-with-mysql: ## MODULE= - Run tests for a single app, module or test class against a MySQL database container. @@ -75,7 +85,7 @@ test-with-mysql-all: test-launch-mysql test-launch-oracle: @docker rm -f test-oracle || true @docker volume rm test-oracle || true - docker run -d --name test-oracle -p 49160:22 -p 49161:1521 -e ORACLE_ALLOW_REMOTE=true -v test-oracle:/u01/app/oracle wnameless/oracle-xe-11g + docker run -d --name test-oracle -p 49160:22 -p 49161:1521 -e ORACLE_ALLOW_REMOTE=true -v test-oracle:/u01/app/oracle $(DOCKER_ORACLE_IMAGE) # https://gist.github.com/kimus/10012910 pip install cx_Oracle while ! nc -z 127.0.0.1 49161; do sleep 1; done @@ -243,11 +253,12 @@ shell_plus: ## Run the shell_plus command. ./manage.py shell_plus --settings=mayan.settings.development test-with-docker-services-on: ## Launch and initialize production-like services using Docker (Postgres and Redis). - docker run -d --name redis -p 6379:6379 redis - docker run -d --name postgres -p 5432:5432 postgres + docker run -d --name redis -p 6379:6379 $(DOCKER_REDIS_IMAGE) + docker run -d --name postgres -p 5432:5432 $(DOCKER_POSTGRES_IMAGE) while ! nc -z 127.0.0.1 6379; do sleep 1; done while ! nc -z 127.0.0.1 5432; do sleep 1; done sleep 4 + pip install psycopg2==$(PYTHON_PSYCOPG2_VERSION) redis==$(PYTHON_REDIS_VERSION) ./manage.py initialsetup --settings=mayan.settings.staging.docker test-with-docker-services-off: ## Stop and delete the Docker production-like services. @@ -261,7 +272,7 @@ test-with-docker-worker: ## Launch a worker instance that uses the production-li DJANGO_SETTINGS_MODULE=mayan.settings.staging.docker ./manage.py celery worker -A mayan -B -l INFO -O fair docker-mysql-on: ## Launch and initialize a MySQL Docker container. - docker run -d --name mysql -p 3306:3306 -e MYSQL_ALLOW_EMPTY_PASSWORD=True -e MYSQL_DATABASE=mayan_edms mysql + docker run -d --name mysql -p 3306:3306 -e MYSQL_ALLOW_EMPTY_PASSWORD=True -e MYSQL_DATABASE=mayan_edms $(DOCKER_MYSQL_IMAGE) while ! nc -z 127.0.0.1 3306; do sleep 1; done docker-mysql-off: ## Stop and delete the MySQL Docker container. @@ -269,7 +280,7 @@ docker-mysql-off: ## Stop and delete the MySQL Docker container. docker rm mysql docker-postgres-on: ## Launch and initialize a PostgreSQL Docker container. - docker run -d --name postgres -p 5432:5432 postgres + docker run -d --name postgres -p 5432:5432 $(DOCKER_POSTGRES_IMAGE) while ! nc -z 127.0.0.1 5432; do sleep 1; done docker-postgres-off: ## Stop and delete the PostgreSQL Docker container.