new file mode 100644
@@ -0,0 +1,10 @@
+.git
+.env
+.devcontainer
+.ruff_cache
+__pycache__
+*.pyc
+*.sqlite3
+*.patch
+venv
+.venv
@@ -7,3 +7,4 @@
pull-*/
venv
*.sqlite3
+.env
new file mode 100755
@@ -0,0 +1,32 @@
+#!/bin/sh
+# Run the tests in the app image against a throwaway MySQL. Used by CI.
+#
+# SPDX-License-Identifier: MIT
+
+set -e
+
+IMAGE=${IMAGE:-error-report-web-test}
+NET=error-report-web-test
+DB=error-report-web-test-db
+
+docker build -t "$IMAGE" .
+
+docker network create $NET >/dev/null
+trap 'docker rm -f $DB >/dev/null; docker network rm $NET >/dev/null' EXIT
+
+# Root so Django can create the test database; testingpw isn't a secret.
+docker run -d --name $DB --network $NET --network-alias db \
+ -e MYSQL_ROOT_PASSWORD=testingpw -e MYSQL_DATABASE=errorreport \
+ mysql:8.0.36 >/dev/null
+until docker exec $DB mysql -h127.0.0.1 -uroot -ptestingpw -e 'SELECT 1' >/dev/null 2>&1; do
+ if [ "$(docker inspect -f '{{.State.Running}}' $DB)" != true ]; then
+ docker logs $DB | tail -5; exit 1
+ fi
+ sleep 1
+done
+
+# -Wa shows deprecation warnings, i.e. what breaks on the next Django.
+docker run --rm --network $NET \
+ -e SECRET_KEY=ci-only \
+ -e MYSQL_DATABASE=errorreport -e MYSQL_USER=root -e MYSQL_PASSWORD=testingpw \
+ "$IMAGE" python3 -Wa manage.py test --noinput Post
@@ -127,7 +127,7 @@ STATICFILES_FINDERS = (
)
# Make this unique, and don't share it with anybody.
-SECRET_KEY = 'changeme'
+SECRET_KEY = os.environ.get('SECRET_KEY', 'changeme')
MIDDLEWARE = [
'django.middleware.common.CommonMiddleware',
Build the image and test against a throwaway MySQL, as layerindex-web does. -Wa shows deprecation warnings. Read SECRET_KEY from the environment in settings.py.docker, and keep .git and .env out of the image and .env out of git. AI-Generated: Claude Opus 5.5 Signed-off-by: Tim Orling <tim.orling@konsulko.com> --- .dockerignore | 10 ++++++++++ .gitignore | 1 + docker/run-tests.sh | 32 ++++++++++++++++++++++++++++++++ project/settings.py.docker | 2 +- 4 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 .dockerignore create mode 100755 docker/run-tests.sh