Fakultas Ilmu Komputer UI

.gitlab-ci.yml 1.7 KB
Newer Older
Annisa Devi Nurmalasari's avatar
Annisa Devi Nurmalasari committed
1
image: python:3.8
2
stages:
Annisa Devi Nurmalasari's avatar
Annisa Devi Nurmalasari committed
3
  - test
4
  - deploy
5

Annisa Devi Nurmalasari's avatar
Annisa Devi Nurmalasari committed
6
7
variables:
  PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
Ronaldi Tjaidianto's avatar
Ronaldi Tjaidianto committed
8

Annisa Devi Nurmalasari's avatar
Annisa Devi Nurmalasari committed
9
10
11
12
13
14
15
16
17
18
19
20
21
22
cache:
  paths:
    - .cache/pip

# Feel free to remove this in your generated project.
.disable_on_template: &disable_on_template
  rules:
    - if: '$CI_COMMIT_REF_NAME != "template"'

.django_before_script: &django_before_script |-
  pip install -r requirements.txt
  python manage.py collectstatic --no-input

.coverage_artifacts: &coverage_artifacts
Ronaldi Tjaidianto's avatar
Ronaldi Tjaidianto committed
23
24
  artifacts:
    paths:
Annisa Devi Nurmalasari's avatar
Annisa Devi Nurmalasari committed
25
      - .coverage*
Ronaldi Tjaidianto's avatar
Ronaldi Tjaidianto committed
26

Annisa Devi Nurmalasari's avatar
Annisa Devi Nurmalasari committed
27
28
29
30
31
32
33

UnitTest:
  <<: *disable_on_template
  <<: *coverage_artifacts
  stage: test
  before_script:
    - *django_before_script
Ronaldi Tjaidianto's avatar
Ronaldi Tjaidianto committed
34
  script:
Annisa Devi Nurmalasari's avatar
Annisa Devi Nurmalasari committed
35
36
    - coverage run --parallel --include="./*" --omit="manage.py,project_name/*"
      manage.py test --exclude-tag=functional
Ronaldi Tjaidianto's avatar
Ronaldi Tjaidianto committed
37

Annisa Devi Nurmalasari's avatar
Annisa Devi Nurmalasari committed
38
39
40
41
42
43
44
45
46
47
48
49
50
51
FunctionalTest:
  <<: *disable_on_template
  <<: *coverage_artifacts
  stage: test
  before_script:
    - apt-get update -q && apt-get install -yq chromium-driver
    - *django_before_script
  script:
    - coverage run --parallel --include="./*" --omit="manage.py,project_name/*"
      manage.py test --tag=functional


Coverage:
  <<: *disable_on_template
52
53
  stage: deploy
  before_script:
Annisa Devi Nurmalasari's avatar
Annisa Devi Nurmalasari committed
54
55
    - pip install coverage
    - coverage combine
56
  script:
Annisa Devi Nurmalasari's avatar
Annisa Devi Nurmalasari committed
57
58
59
60
61
    - coverage report -m
    - coverage html
  artifacts:
    paths:
      - htmlcov/
62

Annisa Devi Nurmalasari's avatar
Annisa Devi Nurmalasari committed
63
64
65
66
Deployment:
  rules:
    - if: '$CI_COMMIT_REF_NAME == "walkiddie_be_test"'
  image: ruby:2.7
67
68
69
70
71
  stage: deploy
  before_script:
    - gem install dpl
    - wget -qO- https://cli-assets.heroku.com/install-ubuntu.sh | sh
  script:
Annisa Devi Nurmalasari's avatar
Annisa Devi Nurmalasari committed
72
73
    - dpl --provider=heroku --app=$HEROKU_APP_NAME --api-key=$HEROKU_API_KEY
    - heroku run --app $HEROKU_APP_NAME migrate
74
75
  environment:
    name: production
Annisa Devi Nurmalasari's avatar
Annisa Devi Nurmalasari committed
76
    url: https://$HEROKU_APP_NAME.herokuapp.com