From bed5c802df1f89f625dcd37dcd947fe834ed16fe Mon Sep 17 00:00:00 2001 From: Hugo Rodger-Brown Date: Mon, 28 Sep 2020 16:20:04 +0100 Subject: [PATCH] Add a system check on CI to catch missing migrations --- .travis.yml | 1 + runchecks.py | 29 +++++++++++++++++++++++++++++ tox.ini | 4 ++++ 3 files changed, 34 insertions(+) create mode 100755 runchecks.py diff --git a/.travis.yml b/.travis.yml index c204c5460..e5a4d82a7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,6 +27,7 @@ matrix: - { python: "3.8", env: TOXENV=base } - { python: "3.8", env: TOXENV=lint } - { python: "3.8", env: TOXENV=docs } + - { python: "3.8", env: TOXENV=checks } - python: "3.8" env: TOXENV=dist diff --git a/runchecks.py b/runchecks.py new file mode 100755 index 000000000..f5170250a --- /dev/null +++ b/runchecks.py @@ -0,0 +1,29 @@ +#!/usr/bin/env python3 +"""Basic script used to run django-admin checks in CI/tox.""" +from django.conf import settings +from django.core.management import execute_from_command_line + + +if __name__ == "__main__": + + # Minimal settings required to check for migrations + settings.configure( + SECRET_KEY = "not very secret in checks either", + DATABASES = { + "default": { + "ENGINE": "django.db.backends.sqlite3", + "NAME": ":memory:" + } + }, + INSTALLED_APPS = [ + 'django.contrib.auth', + 'django.contrib.contenttypes', + "rest_framework.authtoken" + ] + ) + + print("Running basic Django system checks") + execute_from_command_line(["manage.py", "check"]) + + print("Checking for missing Django migrations") + execute_from_command_line(["manage.py", "makemigrations", "--dry-run", "--verbosity=3", "--check"]) diff --git a/tox.ini b/tox.ini index d5e769764..93108980f 100644 --- a/tox.ini +++ b/tox.ini @@ -46,6 +46,10 @@ deps = -rrequirements/requirements-codestyle.txt -rrequirements/requirements-testing.txt +[testenv:checks] +commands = + ./runchecks.py + [testenv:docs] skip_install = true commands = mkdocs build