Fakultas Ilmu Komputer UI

.gitlab-ci.yml 1.91 KB
Newer Older
Izzan Fakhril Islam's avatar
Izzan Fakhril Islam committed
1
2
3
4
stages:
  - test
  - deploy

5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
before_script:
  - apt-get install -f
  - apt-get update -qy
  - apt-get install -y python-dev python-pip sudo postgresql postgresql-client libpq-dev libxss1 libappindicator1 libindicator7
  - 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
  - wget https://chromedriver.storage.googleapis.com/77.0.3865.40/chromedriver_linux64.zip
  - 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
29
30
31
32
UnitTest:
  stage: test
  when: on_success
  script:
33
34
35
36
37
38
39
40
    - coverage run --include='tutorial_*/*' manage.py test -p "unit_test*.py"
    - coverage report -m

FunctionalTest:
  stage: test
  when: on_success
  script:
    - coverage run --include='tutorial_*/*' manage.py test -p "functional_test*.py"
Izzan Fakhril Islam's avatar
Izzan Fakhril Islam committed
41
42
    - coverage report -m

43
DeployToHeroku:
Izzan Fakhril Islam's avatar
Izzan Fakhril Islam committed
44
45
46
47
48
49
50
51
52
53
54
55
  image: ruby:2.4
  stage: deploy
  before_script:
    - gem install dpl
    - wget -qO- https://cli-assets.heroku.com/install-ubuntu.sh | sh
  script:
    - dpl --provider=heroku --app=$HEROKU_APPNAME --api-key=$HEROKU_APIKEY
    - export HEROKU_APIKEY=$HEROKU_APIKEY
    - heroku run --app $HEROKU_APPNAME migrate
  environment:
    name: production
    url: $HEROKU_APP_HOST