forked from DGNum/gestioCOF
85e593ddb8
Sometime the test database is not destroyed because the build is interrupted by an uncaught error. This causes an error during the next build.
49 lines
1.3 KiB
YAML
49 lines
1.3 KiB
YAML
services:
|
|
- mysql:latest
|
|
- redis:latest
|
|
|
|
variables:
|
|
# GestioCOF settings
|
|
DJANGO_SETTINGS_MODULE: "cof.settings_dev"
|
|
DBNAME: "cof_gestion"
|
|
DBUSER: "cof_gestion"
|
|
DBPASSWD: "cof_password"
|
|
DBHOST: "mysql"
|
|
REDIS_HOST: "redis"
|
|
|
|
# Cached packages
|
|
PYTHONPATH: "$CI_PROJECT_DIR/vendor/python"
|
|
|
|
# mysql service configuration
|
|
MYSQL_DATABASE: "$DBNAME"
|
|
MYSQL_USER: "$DBUSER"
|
|
MYSQL_PASSWORD: "$DBPASSWD"
|
|
MYSQL_ROOT_PASSWORD: "root_password"
|
|
|
|
|
|
cache:
|
|
paths:
|
|
- vendor/python
|
|
- vendor/pip
|
|
- vendor/apt
|
|
|
|
before_script:
|
|
- mkdir -p vendor/{python,pip,apt}
|
|
- 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"
|
|
-e "GRANT ALL ON test_$DBNAME.* TO '$DBUSER'@'%'"
|
|
- pip install --cache-dir vendor/pip -t vendor/python -r requirements-devel.txt
|
|
|
|
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
|