.gitlab-ci.yml 1.93 KB
Newer Older
1
services:
Zac Wood's avatar
RTFM  
Zac Wood committed
2 3
  - name: registry.srct.gmu.edu/srct/go/db
    alias: mysql
David Haynes's avatar
David Haynes committed
4

5
stages:
6
  - test
7
  - lint
Zac Wood's avatar
Zac Wood committed
8
  - build
9

10 11 12 13
variables:
  MYSQL_DATABASE: go
  MYSQL_ROOT_PASSWORD: root

14 15
before_script:
  - apt-get update -qy
Zac Wood's avatar
Zac Wood committed
16
  - apt-get install -y default-libmysqlclient-dev python-mysqldb redis-server
17
  - pip install -r requirements/ci.txt
David Haynes's avatar
David Haynes committed
18
  - nohup redis-server &
19
  - cd go/
Zac Wood's avatar
Zac Wood committed
20
  - export GO_ENV="test"
Zac Wood's avatar
Zac Wood committed
21
  - export GO_SECRET_KEY=$(python -c 'import random; import string; print("".join([random.SystemRandom().choice("{}{}{}".format(string.ascii_letters, string.digits, string.punctuation)) for i in range(50)]))')
22 23 24
  - export GO_DB_NAME="go"
  - export GO_DB_USER="root"
  - export GO_DB_PASSWORD="root"
Zac Wood's avatar
RTFM  
Zac Wood committed
25
  - export GO_DB_HOST="mysql"
26 27 28 29 30 31 32 33 34 35
  - export GO_DB_PORT=3306
  - export GO_ALLOWED_HOSTS="*"
  - export GO_EMAIL_DOMAIN="@masonlive.gmu.edu"
  - export GO_CAS_URL="https://cas.srct.gmu.edu/"
  - export GO_EMAIL_HOST=
  - export GO_EMAIL_PORT=
  - export GO_EMAIL_HOST_USER=
  - export GO_EMAIL_HOST_PASSWORD=
  - export GO_EMAIL_FROM=
  - export GO_EMAIL_TO=
36 37 38 39 40
  - 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

Zac Wood's avatar
Zac Wood committed
41 42
Go-py3.7:
  image: library/python:3.7
43
  stage: test
David Haynes's avatar
David Haynes committed
44 45 46
  script:
    - python manage.py test

47
Go-flake8:
Zac Wood's avatar
Zac Wood committed
48
  image: library/python:3.7
49 50 51
  stage: lint
  script:
    - pip install flake8
Zac Wood's avatar
Zac Wood committed
52
    - flake8 go/ --statistics --exit-zero
Zac Wood's avatar
Zac Wood committed
53 54 55 56 57 58 59 60 61 62 63 64

build:
  stage: build
  retry: 2
  image:
    name: gcr.io/kaniko-project/executor:debug
    entrypoint: [""]
  script:
    - echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json
    - /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile.prod --destination $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG
  only:
    - tags