From eb88df48e11c9cf803b2652dd90ffa85943c78d9 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Thu, 18 Oct 2018 16:19:39 -0400 Subject: [PATCH 1/3] No migrations left behind, in CI Fixes #1590 --- .circleci/config.yml | 2 +- bin/run.sh | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 834023395..d1f2a0225 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -13,7 +13,7 @@ jobs: working_directory: ~/normandy environment: - COMPOSE_FILE: ci/docker-compose.yml + COMPOSE_FILE: ci/docker-compose.yml steps: - checkout diff --git a/bin/run.sh b/bin/run.sh index ef04ebfee..94fa0631d 100755 --- a/bin/run.sh +++ b/bin/run.sh @@ -50,6 +50,9 @@ case $1 in first-start) echo "Starting the gunicorn server the first time" ./manage.py migrate + ./manage.py makemigrations --check --no-input --dry-run || ( + echo "You probably have migrations that need to be created" && exit 1 + ) ./manage.py update_actions start_gunicorn ;; From a0aec720825a1a9d6ceafaa0317a3639dce1d533 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Thu, 18 Oct 2018 16:31:53 -0400 Subject: [PATCH 2/3] its own step instead --- .circleci/config.yml | 4 ++++ bin/run.sh | 11 +++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index d1f2a0225..8cf378908 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -57,6 +57,10 @@ jobs: name: Python Tests command: docker-compose run web python-tests + - run: + name: Missing migrations + command: docker-compose run web migrations-check + - run: name: Contract tests command: | diff --git a/bin/run.sh b/bin/run.sh index 94fa0631d..52634e032 100755 --- a/bin/run.sh +++ b/bin/run.sh @@ -2,7 +2,7 @@ set -eo pipefail usage() { - echo "usage: ./bin/run.sh python-tests|js-tests|lint|start" + echo "usage: ./bin/run.sh python-tests|js-tests|lint|start|migrations-check" exit 1 } @@ -37,6 +37,12 @@ case $1 in fi set -e ;; + migrations-check) + echo "Checking that all migrations have been made" + ./manage.py makemigrations --check --no-input --dry-run || ( + echo "You probably have migrations that need to be created" && exit 1 + ) + ;; python-tests) echo "Running Python tests" junit_path=$ARTIFACTS_PATH/test_results/python_tests @@ -50,9 +56,6 @@ case $1 in first-start) echo "Starting the gunicorn server the first time" ./manage.py migrate - ./manage.py makemigrations --check --no-input --dry-run || ( - echo "You probably have migrations that need to be created" && exit 1 - ) ./manage.py update_actions start_gunicorn ;; From 328dd1f3277a255535ef781f2ac999c31a641c6a Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Thu, 18 Oct 2018 16:39:08 -0400 Subject: [PATCH 3/3] run migrate once for better error message --- bin/run.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/run.sh b/bin/run.sh index 52634e032..003631364 100755 --- a/bin/run.sh +++ b/bin/run.sh @@ -38,6 +38,7 @@ case $1 in set -e ;; migrations-check) + ./manage.py migrate echo "Checking that all migrations have been made" ./manage.py makemigrations --check --no-input --dry-run || ( echo "You probably have migrations that need to be created" && exit 1