image: "python:3.5" variables: # GestioCOF settings DJANGO_SETTINGS_MODULE: "cof.settings.prod" DBHOST: "postgres" REDIS_HOST: "redis" REDIS_PASSWD: "dummy" # Cached packages PIP_CACHE_DIR: "$CI_PROJECT_DIR/vendor/pip" # postgres service configuration POSTGRES_PASSWORD: "4KZt3nGPLVeWSvtBZPSM3fSzXpzEU4" POSTGRES_USER: "cof_gestion" POSTGRES_DB: "cof_gestion" # psql password authentication PGPASSWORD: $POSTGRES_PASSWORD .test_template: before_script: - mkdir -p vendor/{pip,apt} - apt-get update -q && apt-get -o dir::cache::archives="vendor/apt" install -yqq postgresql-client - sed -E 's/^REDIS_HOST.*/REDIS_HOST = "redis"/' cof/settings/secret_example.py > cof/settings/secret.py - sed -i.bak -E 's;^REDIS_PASSWD = .*$;REDIS_PASSWD = "";' cof/settings/secret.py # Remove the old test database if it has not been done yet - psql --username=$POSTGRES_USER --host=$DBHOST -c "DROP DATABASE IF EXISTS test_$POSTGRES_DB" - pip install --upgrade -r requirements-prod.txt coverage tblib - python --version script: - coverage run manage.py test --parallel after_script: - coverage report services: - postgres:9.6 - redis:latest cache: key: test paths: - vendor/ # For GitLab CI to get coverage from build. # Keep this disabled for now, as it may kill GitLab... # coverage: '/TOTAL.*\s(\d+\.\d+)\%$/' test35: extends: ".test_template" image: "python:3.5" stage: test test37: extends: ".test_template" image: "python:3.7" stage: test linters: image: python:3.6 stage: test before_script: - mkdir -p vendor/pip - pip install --upgrade black isort flake8 script: - black --check . - isort --recursive --check-only --diff bda bds clubs cof events gestioncof kfet petitscours provisioning shared utils # Print errors only - flake8 --exit-zero bda bds clubs cof events gestioncof kfet petitscours provisioning shared utils cache: key: linters paths: - vendor/ # Check whether there are some missing migrations. migration_checks: stage: test before_script: - mkdir -p vendor/{pip,apt} - apt-get update -q && apt-get -o dir::cache::archives="vendor/apt" install -yqq postgresql-client - cp cof/settings/secret_example.py cof/settings/secret.py - pip install --upgrade -r requirements-prod.txt - python --version script: python manage.py makemigrations --dry-run --check services: # this should not be necessary… - postgres:9.6 cache: key: migration_checks paths: - vendor/