.gitlab-ci.yml 1.96 KB
Newer Older
1
---
2 3 4 5 6 7
# Official framework image. Look for the different tagged releases at:
# https://hub.docker.com/r/library/python
image: python:3.7

# Pick zero or more services to be used on all builds.
# Only needed when using a docker container to run your tests in.
8 9
# Check out:
# http://docs.gitlab.com/ce/ci/docker/using_docker_images.html#what-is-a-service
10
services:
11
    # - mysql:latest
12
    - postgres:latest
13 14

variables:
15
    POSTGRES_DB: manhattan
16 17 18 19

# This folder is cached between builds
# http://docs.gitlab.com/ce/ci/yaml/README.html#cache
cache:
20 21
    paths:
        - ~/.cache/pip/
22 23 24 25

# This is a basic example for a gem or script which doesn't use
# services such as redis or postgres
before_script:
26
    - python3.7 -V  # Print out python version for debugging
27 28
    # Uncomment next line if your Django app needs a JS runtime:
    # - apt-get update -q && apt-get install nodejs -yqq
29
    - apt-get update -q && apt-get install python3.7-dev python3-distutils libxmlsec1-dev pandoc pkg-config -yqq
30 31 32 33 34
    - cp manhattan_project/settings-sample.py manhattan_project/settings.py
    - pip install --user -r requirements.txt
    - pip install --user coverage
    - export PATH="$PATH:$HOME/.local/bin"
    - python3.7 manage.py collectstatic --noinput
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52

# To get Django tests to work you may need to create a settings file using
# the following DATABASES:
#
# DATABASES = {
#     'default': {
#        'ENGINE': 'django.db.backends.postgresql_psycopg2',
#        'NAME': 'ci',
#        'USER': 'postgres',
#        'PASSWORD': 'postgres',
#        'HOST': 'postgres',
#        'PORT': '5432',
#    },
# }
#
# and then adding `--settings app.settings.ci` (or similar) to the test command

test:
53 54 55 56 57 58 59 60 61 62
    variables:
        DB_NAME: "manhattan"
        DB_USER: "postgres"
        DB_PASSWORD: "postgres"
        DB_HOST: "postgres"
        DATABASE_URL: "postgresql://postgres:postgres@postgres:5432/$POSTGRES_DB"
    script:
        - coverage run manage.py test
        - coverage report
    coverage: "/TOTAL.+ ([0-9]{1,3}%)/"