Fix CI script

Finally, the old test database is destroyed before the build which
is simpler and makes more sense.
This commit is contained in:
Martin Pépin 2017-02-13 17:43:10 +01:00
parent e8d21882fb
commit 451fddaff0

View file

@ -32,22 +32,12 @@ before_script:
- apt-get update -q && apt-get -o dir::cache::archives="vendor/apt" install -yqq mysql-client - apt-get update -q && apt-get -o dir::cache::archives="vendor/apt" install -yqq mysql-client
- mysql --user=root --password="$MYSQL_ROOT_PASSWORD" --host="$DBHOST" - mysql --user=root --password="$MYSQL_ROOT_PASSWORD" --host="$DBHOST"
-e "GRANT ALL ON test_$DBNAME.* TO '$DBUSER'@'%'" -e "GRANT ALL ON test_$DBNAME.* TO '$DBUSER'@'%'"
# Remove the old test database if it has not been done yet
- mysql --user=root --password="$MYSQL_ROOT_PASSWORD" --host="$DBHOST"
-e "DROP DATABASE test_$DBNAME" || true
- pip install --cache-dir vendor/pip -t vendor/python -r requirements-devel.txt - pip install --cache-dir vendor/pip -t vendor/python -r requirements-devel.txt
stages:
- test
- cleanup
test: test:
stage: test stage: test
script: script:
- python manage.py test - 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