-
Notifications
You must be signed in to change notification settings - Fork 2
/
.gitlab-ci.yml
88 lines (76 loc) · 2.9 KB
/
.gitlab-ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# Official framework image. Look for the different tagged releases at:
# https://hub.docker.com/r/library/python
image: python:latest
# Pick zero or more services to be used on all builds.
# Only needed when using a docker container to run your tests in.
# Check out: http://docs.gitlab.com/ce/ci/docker/using_docker_images.html#what-is-a-service
services:
- postgres:latest
variables:
POSTGRES_HOST: postgres
POSTGRES_DB: database
POSTGRES_USER: django
POSTGRES_PASSWORD: "password"
#connect:
# image: postgres
#script:
# official way to provide password to psql: http://www.postgresql.org/docs/9.3/static/libpq-envars.html
#- export PGPASSWORD=$POSTGRES_PASSWORD
#- psql -h "postgres" -U "$POSTGRES_USER" -d "$POSTGRES_DB" -c "SELECT 'OK' AS status;"
# This folder is cached between builds
# http://docs.gitlab.com/ce/ci/yaml/README.html#cache
#cache:
# paths:
# - ~/.cache/pip/
stages:
- test
# This is a basic example for a gem or script which doesn't use
# services such as redis or postgres
before_script:
# Update OS
- echo -e "-------------------------------- UPDATE SYSTEM --------------------------------"
- apt-get update -yqq
- apt-get install -y python-dev python-pip
# Print out python version for debugging
- python -V
- pip --version
# Install Django
- echo -e "-------------------------------- INSTALL DJANGO --------------------------------"
- pip install Django
- pip install psycopg2
- pip install djangorestframework
- pip install django-cors-headers
- pip install requests
- apt-get install -y postgresql-client
# Uncomment next line if your Django app needs a JS runtime:
# - apt-get update -q && apt-get install nodejs -yqq
#- pip install -r requirements.txt
# 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:
# variables:
# DATABASE_URL: "postgresql://postgres:postgres@postgres:5432/$POSTGRES_DB"
script:
# official way to provide password to psql: http://www.postgresql.org/docs/9.3/static/libpq-envars.html
- export PGPASSWORD=$POSTGRES_PASSWORD
- psql -h "$POSTGRES_HOST" -U "$POSTGRES_USER" -d "$POSTGRES_DB" -c "SELECT 'OK' AS status;"
- cd cpro_customs/
- echo -e "{\"DB_PASSWORD\"":" \"password\"}" > secrets.json
- sed -i 's/localhost/postgres/g' ./cpro_customs/settings.py
- python manage.py makemigrations
- python manage.py migrate
# - psql -h "postgres" -U "$POSTGRES_USER" -d "$POSTGRES_DB" -c "SELECT table_schema,table_name FROM information_schema.tables ORDER BY table_schema,table_name;"
- python manage.py test backend.tests