From a9b3a83e8b48e76a252cc464910f5f79c2cd7a1f Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Tue, 5 May 2020 13:18:46 +0200 Subject: [PATCH 01/10] tox.ini: add a check-migrations.sh script to check migrations on each run (#42504) --- check-migrations.sh | 17 +++++++++++++++++ tox.ini | 1 + 2 files changed, 18 insertions(+) create mode 100755 check-migrations.sh diff --git check-migrations.sh check-migrations.sh new file mode 100755 index 00000000..cdf866dc --- /dev/null +++ check-migrations.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +set -e + +APPS=$(DJANGO_SETTINGS_MODULE=authentic2.settings python -c 'from django.conf import settings; print(" ".join(p for p in (p.split(".")[-1] for p in settings.INSTALLED_APPS if not p.startswith("django.")) if p not in ["admin", "auth", "contenttypes"]))') +TEMPFILE=`tempfile` +trap "rm -f ${TEMPFILE}" EXIT + +./authentic2-ctl makemigrations --dry-run --noinput ${APPS} >${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 tox.ini tox.ini index 70fcef5f..666085f4 100644 --- tox.ini +++ tox.ini @@ -84,6 +84,7 @@ deps = commands = py2: ./getlasso.sh py3: ./getlasso3.sh + authentic: ./check-migrations.sh rbac,authentic: py.test {env:FAST:} {env:REUSEDB:} {env:COVERAGE:} {env:JUNIT:} {tty:--sw:} {posargs:{env:TESTS} --random-group} [testenv:pylint] -- 2.26.0