From 0058acbe97193a12b907263fc9cae413068f76f3 Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Fri, 15 May 2020 16:16:23 +0200 Subject: [PATCH] tox.ini: add check-migrations.sh --- check-migrations.sh | 26 ++++++++++++++++++++++++++ tox.ini | 1 + 2 files changed, 27 insertions(+) create mode 100755 check-migrations.sh diff --git a/check-migrations.sh b/check-migrations.sh new file mode 100755 index 0000000..6471aee --- /dev/null +++ b/check-migrations.sh @@ -0,0 +1,26 @@ +#!/bin/sh + +set -e + +trap "rm -f ${TEMPFILE} ${CHECK_MIGRATIONS_SETTINGS}" EXIT + +# https://stackoverflow.com/questions/49778988/makemigrations-in-dev-machine-without-database-instance +CHECK_MIGRATIONS_SETTINGS=`tempfile` +cat <${CHECK_MIGRATIONS_SETTINGS} +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.dummy', + } +} +EOF +TEMPFILE=`tempfile` + +DJANGO_SETTINGS_MODULE=authentic2.settings AUTHENTIC2_SETTINGS_FILE=${CHECK_MIGRATIONS_SETTINGS} django-admin makemigrations --dry-run --noinput authentic2_cut >${TEMPFILE} 2>&1 || true + +if ! grep 'No changes detected' -q ${TEMPFILE}; then + echo '!!! Missing migration detected !!!' + cat ${TEMPFILE} + exit 1 +else + exit 0 +fi diff --git a/tox.ini b/tox.ini index f844ac5..09484b0 100644 --- a/tox.ini +++ b/tox.ini @@ -59,6 +59,7 @@ deps = commands = py2: ./getlasso.sh py3: ./getlasso3.sh + ./check-migrations.sh py.test {env:COVERAGE:} {env:JUNIT:} {tty:--sw:} {posargs:tests/} [testenv:pylint]