Add a system check on CI to catch missing migrations

This commit is contained in:
Hugo Rodger-Brown 2020-09-28 16:20:04 +01:00
parent 0e5316505b
commit bed5c802df
3 changed files with 34 additions and 0 deletions

View File

@ -27,6 +27,7 @@ matrix:
- { python: "3.8", env: TOXENV=base } - { python: "3.8", env: TOXENV=base }
- { python: "3.8", env: TOXENV=lint } - { python: "3.8", env: TOXENV=lint }
- { python: "3.8", env: TOXENV=docs } - { python: "3.8", env: TOXENV=docs }
- { python: "3.8", env: TOXENV=checks }
- python: "3.8" - python: "3.8"
env: TOXENV=dist env: TOXENV=dist

29
runchecks.py Executable file
View File

@ -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"])

View File

@ -46,6 +46,10 @@ deps =
-rrequirements/requirements-codestyle.txt -rrequirements/requirements-codestyle.txt
-rrequirements/requirements-testing.txt -rrequirements/requirements-testing.txt
[testenv:checks]
commands =
./runchecks.py
[testenv:docs] [testenv:docs]
skip_install = true skip_install = true
commands = mkdocs build commands = mkdocs build