Fakultas Ilmu Komputer UI

.gitlab-ci.yml 2.94 KB
Newer Older
Izzan Fakhril Islam's avatar
Izzan Fakhril Islam committed
1
stages:
Izzan Fakhril Islam's avatar
Izzan Fakhril Islam committed
2
  - unit-test
Izzan Fakhril Islam's avatar
Izzan Fakhril Islam committed
3
  - deploy
Izzan Fakhril Islam's avatar
Izzan Fakhril Islam committed
4
  - functional-test
Izzan Fakhril Islam's avatar
Izzan Fakhril Islam committed
5
6

UnitTest:
7
  image: python:3.6
Izzan Fakhril Islam's avatar
Izzan Fakhril Islam committed
8
  stage: unit-test
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
  before_script:
    - apt-get install -f
    - apt-get update -qy
    - apt-get install -y sudo postgresql postgresql-client libpq-dev libxss1 libappindicator1 libindicator7
    - python --version
    - apt-get install -y xvfb
    - service postgresql start
    - sudo -u $DB_DEFAULT_OWNER psql -c "CREATE USER $DB_USERNAME WITH PASSWORD '$DB_PASSWORD' CREATEDB"
    - sudo -u $DB_DEFAULT_OWNER psql -c "CREATE DATABASE $DB_NAME OWNER $DB_USERNAME"
    - pip install --upgrade pip
    - pip install -r requirements.txt
    - pip install --upgrade --ignore-installed urllib3
    - python manage.py makemigrations
    - python manage.py migrate
    - python manage.py collectstatic --no-input
    - python manage.py runserver 8000 &
Izzan Fakhril Islam's avatar
Izzan Fakhril Islam committed
25
26
  when: on_success
  script:
27
    - python manage.py test tutorial_5.unit_tests
Izzan Fakhril Islam's avatar
Izzan Fakhril Islam committed
28
    - python manage.py test tutorial_8.unit_tests
29
    - python manage.py test -p "unit_test*.py"
30
31

DeployToHeroku:
Izzan Fakhril Islam's avatar
Izzan Fakhril Islam committed
32
33
34
35
36
37
  image: ruby:2.4
  stage: deploy
  before_script:
    - gem install dpl
    - wget -qO- https://cli-assets.heroku.com/install-ubuntu.sh | sh
  script:
Izzan Fakhril Islam's avatar
Izzan Fakhril Islam committed
38
39
    - dpl --provider=heroku --app=$HEROKU_APPNAME --api-key=$HEROKU_API_KEY
    - export HEROKU_API_KEY=$HEROKU_API_KEY
Izzan Fakhril Islam's avatar
Izzan Fakhril Islam committed
40
41
42
43
    - heroku run --app $HEROKU_APPNAME migrate
  environment:
    name: production
    url: $HEROKU_APP_HOST
Izzan Fakhril Islam's avatar
Izzan Fakhril Islam committed
44
45

FunctionalTest:
46
  image: python:3.6
Izzan Fakhril Islam's avatar
Izzan Fakhril Islam committed
47
  stage: functional-test
48
49
50
51
52
53
54
55
56
57
58
59
  before_script:
    - apt-get install -f
    - apt-get update -qy
    - apt-get install -y sudo postgresql postgresql-client libpq-dev libxss1 libappindicator1 libindicator7
    - python --version
    - wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
    - echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google.list
    - apt-get update -qq && apt-get install -y -qq unzip
    - apt-get install -y google-chrome-stable
    - export CHROME_BIN=/usr/bin/google-chrome
    - google-chrome --version
    - apt-get install -y xvfb
Izzan Fakhril Islam's avatar
Izzan Fakhril Islam committed
60
    - wget https://chromedriver.storage.googleapis.com/79.0.3945.36/chromedriver_linux64.zip
61
62
63
64
65
66
67
68
69
70
71
    - unzip chromedriver_linux64.zip
    - service postgresql start
    - sudo -u $DB_DEFAULT_OWNER psql -c "CREATE USER $DB_USERNAME WITH PASSWORD '$DB_PASSWORD' CREATEDB"
    - sudo -u $DB_DEFAULT_OWNER psql -c "CREATE DATABASE $DB_NAME OWNER $DB_USERNAME"
    - pip install --upgrade pip
    - pip install -r requirements.txt
    - pip install --upgrade --ignore-installed urllib3
    - python manage.py makemigrations
    - python manage.py migrate
    - python manage.py collectstatic --no-input
    - python manage.py runserver 8000 &
Izzan Fakhril Islam's avatar
Izzan Fakhril Islam committed
72
73
  when: on_success
  script:
74
    - python manage.py test tutorial_5.functional_tests
Izzan Fakhril Islam's avatar
Izzan Fakhril Islam committed
75
    - python manage.py test tutorial_7.functional_tests
76
    - python manage.py test -p "functional_test*.py"
Izzan Fakhril Islam's avatar
Izzan Fakhril Islam committed
77
78
    - coverage run --include='tutorial_7/*' manage.py test tutorial_7
    - coverage report -m