Fakultas Ilmu Komputer UI

.gitlab-ci.yml 1.7 KB
Newer Older
Putu Agastya's avatar
Putu Agastya committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
stages:
  - test
  - sonarqube
  - deploy

UnitTest:
  image: python:3.7
  stage: test
  coverage: '/TOTAL\s+\d+\s+\d+\s+(\d+)%/'
  before_script:
    - pip install -r requirements.txt
    - python manage.py makemigrations
    - python manage.py migrate
    - python manage.py collectstatic --no-input
  when: on_success
  script:
    - coverage run --include="./*" --omit="manage.py,digipus/*,env/*" manage.py test
    - coverage report -m
    - coverage xml
  artifacts:
    paths:
    - coverage.xml

SonarScanner:
25
  image: addianto/sonar-scanner-cli:latest
Putu Agastya's avatar
Putu Agastya committed
26
27
28
29
30
31
32
  stage: sonarqube
  script:
    - sonar-scanner
      -Dsonar.host.url=https://pmpl.cs.ui.ac.id/sonarqube
      -Dsonar.login=$SONARQUBE_TOKEN
      -Dsonar.branch.name=$CI_COMMIT_REF_NAME
      -Dsonar.projectKey=$SONARQUBE_PROJECT_KEY
33
34
35
  only:
    - master
    - staging
Putu Agastya's avatar
Putu Agastya committed
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

Staging:
  image: ruby:2.4
  stage: deploy
  only:
    refs:
      - staging
  before_script:
    - gem install dpl
    - wget -qO- https://cli-assets.heroku.com/install-ubuntu.sh | sh
  script:
    - dpl --provider=heroku --app=$HEROKU_APPNAME_STAGING --api-key=$HEROKU_APIKEY
    - export HEROKU_API_KEY=$HEROKU_APIKEY
    - heroku run --app $HEROKU_APPNAME_STAGING migrate
  environment:
    name: staging
    url: $HEROKU_APP_HOST_STAGING

  
# Deployment:
#   image: ruby:2.4
#   stage: deploy
#   only:
#     refs:
#       - master
#   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_API_KEY=$HEROKU_APIKEY
#     - heroku run --app $HEROKU_APPNAME migrate
#   environment:
#     name: production
#     url: $HEROKU_APP_HOST