Fakultas Ilmu Komputer UI

.gitlab-ci.yml 1.75 KB
Newer Older
Johanes Steven's avatar
Johanes Steven committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
stages:
  - build
  - test
  - deploy
  - sonar

image: gradle:6.8.3-jdk15
before_script:
  - export GRADLE_USER_HOME=`pwd`/.gradle

variables:
  GRADLE_OPTS: "-Dorg.gradle.daemon=false"

build:
  stage: build
  script:
    - gradle assemble
18 19 20 21 22 23
  cache:
    key: $CI_COMMIT_REF_NAME
    policy: push
    paths:
      - build
      - .gradle
Johanes Steven's avatar
Johanes Steven committed
24 25 26

test:
  stage: test
Achmad Afriza's avatar
Achmad Afriza committed
27 28 29 30
  services:
    - name: postgres:13.2-alpine
      alias: postgres
  variables:
Johanes Steven's avatar
Johanes Steven committed
31 32 33 34 35 36
    POSTGRES_DB: $DATABASE_DB
    POSTGRES_USER: $DATABASE_USERNAME
    POSTGRES_PASSWORD: $DATABASE_PASSWORD
    SPRING_DATASOURCE_URL: jdbc:$DATABASE_URL
    SPRING_DATASOURCE_USERNAME: $DATABASE_USERNAME
    SPRING_DATASOURCE_PASSWORD: $DATABASE_PASSWORD
Johanes Steven's avatar
Johanes Steven committed
37 38
  script:
    - gradle check
Achmad Afriza's avatar
Achmad Afriza committed
39
      -Dspring.profiles.active=ci
Johanes Steven's avatar
Johanes Steven committed
40 41 42
    - gradle jacocoTestReport
    - gradle jacocoTestCoverageVerification
    - gradle jacocoMergeTest
Achmad Afriza's avatar
Achmad Afriza committed
43
    - grep Total build/reports/jacoco/test/html/index.html
44 45 46 47 48 49
  cache:
    key: $CI_COMMIT_REF_NAME
    policy: pull-push
    paths:
      - build
      - .gradle
Johanes Steven's avatar
Johanes Steven committed
50
  artifacts:
Achmad Afriza's avatar
Achmad Afriza committed
51 52
    when: always
    reports:
Achmad Afriza's avatar
Achmad Afriza committed
53 54
      junit: build/test-results/test/TEST-*.xml
  when: on_success
Johanes Steven's avatar
Johanes Steven committed
55

Achmad Afriza's avatar
Achmad Afriza committed
56
staging:
Johanes Steven's avatar
Johanes Steven committed
57
  stage: deploy
58
  image: ruby:2.7.3-buster
Johanes Steven's avatar
Johanes Steven committed
59 60 61
  before_script:
    - gem install dpl
  script:
Achmad Afriza's avatar
Achmad Afriza committed
62
    - dpl --provider=heroku --app=$HEROKU_APP_NAME_DEV --api-key=$HEROKU_API_KEY
63
  cache: {}
Achmad Afriza's avatar
Achmad Afriza committed
64 65 66
  only:
    - dev

67
production:
Achmad Afriza's avatar
Achmad Afriza committed
68 69 70 71 72
  stage: deploy
  image: ruby:2.7.3-buster
  before_script:
    - gem install dpl
  script:
73 74
    - dpl --provider=heroku --app=$HEROKU_APPNAME_PROD --api-key=$HEROKU_API_KEY
  cache: {}
Achmad Afriza's avatar
Achmad Afriza committed
75 76
  only:
    - master
Johanes Steven's avatar
Johanes Steven committed
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91

sonarCheck:
  stage: sonar
  needs:
    - job: test
  script:
    - gradle sonarqube -Dsonar.login=$SONAR_TOKEN


cache:
  key: "$CI_COMMIT_REF_NAME"
  paths:
    - $GRADLE_USER_HOME/wrapper
    - $GRADLE_USER_HOME/caches