From 85e593ddb8786687c74c5ce545ff05fd14f03709 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20P=C3=A9pin?= Date: Mon, 13 Feb 2017 17:22:15 +0100 Subject: [PATCH] Removes the test database if the build fails Sometime the test database is not destroyed because the build is interrupted by an uncaught error. This causes an error during the next build. --- .gitlab-ci.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f420a9f5..49023161 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -38,3 +38,12 @@ test: stage: test script: - python manage.py test + +cleanup: + stage: cleanup + script: + # If an uncaught error occurs, the test database has to be destroyed + # manually + - mysql --user=root --password="$MYSQL_ROOT_PASSWORD" --host="$DBHOST" + -e "DROP DATABASE test_$DBNAME" || true + when: on_failure