.gitlab-ci.yml 1.59 KB
Newer Older
1 2
services:
  - mysql:latest
David Haynes's avatar
David Haynes committed
3

4
types:
5
  - test
6

7 8 9 10
variables:
  MYSQL_DATABASE: go
  MYSQL_ROOT_PASSWORD: root

11 12
before_script:
  - apt-get update -qy
13
  - apt-get install -y libldap2-dev libsasl2-dev mysql-client libmysqlclient-dev python-mysqldb
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
  - pip install -r requirements.txt
  - cd go/
  - cp settings/settings.py.template settings/settings.py
  - cp settings/secret.py.template settings/secret.py
  - export SECRET_KEY=$(dd if=/dev/urandom count=100 | tr -dc "A-Za-z0-9" | fold -w 60 | head -n1 2>/dev/null)
  - export DJANGO_DEBUG="True"
  - sed -i settings/secret.py -e 's/DB_NAME.*/DB_NAME = \"go\"/'
  - sed -i settings/secret.py -e 's/DB_USER.*/DB_USER = \"root\"/'
  - sed -i settings/secret.py -e 's/DB_PASSWORD.*/DB_PASSWORD = \"root\"/'
  - sed -i settings/secret.py -e 's/DB_HOST.*/DB_HOST = \"mysql\"/'
  - sed -i settings/secret.py -e 's/SECRET_KEY.*/SECRET_KEY = \"${SECRET_KEY}\"/'
  - python manage.py makemigrations
  - python manage.py makemigrations go
  - python manage.py migrate
  - echo "from django.contrib.auth import get_user_model; User = get_user_model(); User.objects.create_superuser('root', 'root@srct.gmu.edu', 'root') " | python manage.py shell

David Haynes's avatar
David Haynes committed
30 31
Go-py2.7:
  image: library/python:2.7
32
  type: test
David Haynes's avatar
David Haynes committed
33
  script:
34
    - python manage.py test
David Haynes's avatar
David Haynes committed
35 36 37

Go-py3.6:
  image: library/python:3.6
38
  type: test
David Haynes's avatar
David Haynes committed
39
  script:
40
    - pip install coverage
41
    - coverage run --source=go --omit=*migrations/*,*admin.py,*manage.py,*wsgi.py,*settings.py,*secret.py,*__init__.py,*.pyc,*templates/*,*static/* manage.py test 
42
    - coverage html -i && grep pc_cov htmlcov/index.html | egrep -o "[0-9]+\%" | awk '{ print "covered " $1;}'