Fakultas Ilmu Komputer UI

.gitlab-ci.yml 2.06 KB
Newer Older
Wulan Mantiri's avatar
Wulan Mantiri committed
1
2
3
4
5
6
7
8
9
10
11
12
13
before_script:
  - >
    if [[ "${CI_COMMIT_REF_NAME}" == "master" ]];
    then
      ENV=PRODUCTION
    else
      ENV=STAGING
    fi
  - API_BASE_URL=${ENV}_API_BASE_URL
  - GOOGLE_CLIENT_ID=${ENV}_GOOGLE_CLIENT_ID
  - echo -e "API_BASE_URL=${!API_BASE_URL}\n" >> .env
  - echo -e "GOOGLE_CLIENT_ID=${!GOOGLE_CLIENT_ID}\n" >> .env

wulanmantiri's avatar
wulanmantiri committed
14
15
16
17
18
19
20
21
cache:
  key: ${CI_COMMIT_REF_SLUG}
  paths:
    - node_modules/
    - android/
    - ios/

stages:
22
  - lint
23
  - test
Wulan Mantiri's avatar
Wulan Mantiri committed
24
  - sonar-scanner
wulanmantiri's avatar
wulanmantiri committed
25
26
  - build

27
28
29
lint:
  image: node:slim
  stage: lint
30
31
32
  before_script:
    - yarn install
  script:
33
    - yarn lint
34
35
36
37
38

test:
  image: node:slim
  stage: test
  script:
Wulan Mantiri's avatar
Wulan Mantiri committed
39
    - yarn install
40
    - yarn test --silent
41
  artifacts:
42
    expire_in: 1 week
43
44
    paths:
      - coverage
45

46
47
48
49
pbi-sonar-scanner:
  image:
    name: sonarsource/sonar-scanner-cli:latest
    entrypoint: ['']
Wulan Mantiri's avatar
Wulan Mantiri committed
50
51
52
  stage: sonar-scanner
  before_script:
    - ''
53
54
55
56
57
58
59
60
61
62
63
  script:
    - sonar-scanner
      -Dsonar.host.url=$SONARQUBE_URL
      -Dsonar.login=$SONARQUBE_TOKEN
      -Dsonar.branch.name=$CI_COMMIT_REF_NAME
      -Dsonar.branch.target=staging
      -Dsonar.projectKey=$SONARQUBE_PROJECT_KEY
  except:
    - staging
    - master

Wulan Mantiri's avatar
Wulan Mantiri committed
64
65
66
sonar-scanner:
  image:
    name: sonarsource/sonar-scanner-cli:latest
67
    entrypoint: ['']
Wulan Mantiri's avatar
Wulan Mantiri committed
68
  stage: sonar-scanner
Wulan Mantiri's avatar
Wulan Mantiri committed
69
70
  before_script:
    - ''
Wulan Mantiri's avatar
Wulan Mantiri committed
71
72
73
74
75
76
  script:
    - sonar-scanner
      -Dsonar.host.url=$SONARQUBE_URL
      -Dsonar.login=$SONARQUBE_TOKEN
      -Dsonar.branch.name=$CI_COMMIT_REF_NAME
      -Dsonar.projectKey=$SONARQUBE_PROJECT_KEY
77
78
79
  only:
    - staging
    - master
Wulan Mantiri's avatar
Wulan Mantiri committed
80

Wulan Mantiri's avatar
Wulan Mantiri committed
81
android:
82
  image: reactnativecommunity/react-native-android
wulanmantiri's avatar
wulanmantiri committed
83
  stage: build
Wulan Mantiri's avatar
Wulan Mantiri committed
84
  script:
wulanmantiri's avatar
wulanmantiri committed
85
86
87
    - yarn install
    - export ANDROID_SDK_ROOT=/usr/lib/android-sdk
    - cd android
88
    - chmod +x gradlew && ./gradlew clean && ./gradlew assembleRelease
89
    - cd .. && cp android/app/build/outputs/apk/release/app-release.apk $CI_PROJECT_NAME-$CI_COMMIT_REF_NAME.apk
wulanmantiri's avatar
wulanmantiri committed
90
  artifacts:
91
    expire_in: 1 week
92
    name: '$CI_PROJECT_NAME-$CI_COMMIT_REF_NAME'
wulanmantiri's avatar
wulanmantiri committed
93
    paths:
94
95
96
      - $CI_PROJECT_NAME-$CI_COMMIT_REF_NAME.apk
  except:
    changes:
97
      - 'README.md'
wulanmantiri's avatar
wulanmantiri committed
98
99
100
  only:
    - staging
    - master