Fakultas Ilmu Komputer UI

.gitlab-ci.yml 2.85 KB
Newer Older
1
2
3
4
5
6
7
stages:
  - lint
  - test
  - sonarqube
  - build
  - deploy

8
9
10
11
.flutter_before_script: &flutter_before_script |-
  export PATH=$PATH:/sdk/android-sdk-linux/platform-tools/
  mv $FLUTTER_ENV .env
  flutter pub get
12

13
image: poipole/bisago-be:2.0.5-4.6.0.2311
14

15
16
17
before_script:
  - *flutter_before_script

18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
Lint:
  stage: lint
  script:
    - flutter analyze

Test:
  stage: test
  script:
    - flutter test --coverage
    - flutter test --machine > tests.output
    - lcov --summary coverage/lcov.info
    - genhtml coverage/lcov.info --output=coverage
  artifacts:
    expire_in: 1 hour
    paths:
      - coverage/lcov.info
      - tests.output

Sonarqube:
  dependencies:
    - Test
  stage: sonarqube
40
  allow_failure: true
41
42
43
44
  before_script:
    - export PATH=$PATH:/sdk/flutter/bin/cache/dart-sdk/bin
    - flutter pub get
  script:
45
    - sonar-scanner
46
      -Dsonar.host.url=$SONARQUBE_HOST
47
48
49
      -Dsonar.login=$SONARQUBE_TOKEN
      -Dsonar.branch.name=$CI_COMMIT_REF_NAME
      -Dsonar.projectKey=$SONARQUBE_PROJECT_KEY
50

Muhammad Ariq Basyar's avatar
Muhammad Ariq Basyar committed
51
Build:
52
  stage: build
53
54
55
56
  only:
    refs:
      - staging
      - development
57
  before_script:
58
    - *flutter_before_script
59
60
    - mv $KEY_PROPERTIES_ANDROID android/key.properties
    - echo $KEYSTORE_ANDROID | base64 -d > android/app/upload.keystore
61
62
    - BUILD_NUMBER=$((BASE_BUILD_NUMBER + CI_PIPELINE_IID))
    - echo "building with build number $BUILD_NUMBER"
63
    - mkdir symbols
Muhammad Ariq Basyar's avatar
Coldfix    
Muhammad Ariq Basyar committed
64
    - if [ $CI_COMMIT_REF_NAME == 'staging' ]; then
Muhammad Ariq Basyar's avatar
Muhammad Ariq Basyar committed
65
66
67
68
        target=lib/main_staging.dart;
      else
        target=lib/main_dev.dart;
      fi
69
    - echo "building with target $target"
70
  script:
71
72
73
    - flutter build apk
      --build-name $BUILD_NAME
      --build-number $BUILD_NUMBER
74
      -t $target
75
76
77
    - flutter build appbundle
      --build-name $BUILD_NAME
      --build-number $BUILD_NUMBER
78
      -t $target
79
80
81
82
  artifacts:
    paths:
      - build/app/outputs/bundle/release
      - build/app/outputs/apk/release
83
      - android/local.properties
84
      - symbols
85
    expire_in: 6 hour
86

Muhammad Ariq Basyar's avatar
Muhammad Ariq Basyar committed
87
PlayStore:
88
89
  image: ruby:2.6.5
  stage: deploy
90
91
92
93
  only:
    refs:
      - staging
      - development
94
95
96
97
  variables:
    LC_ALL: "en_US.UTF-8"
    LANG: "en_US.UTF-8"
  dependencies:
Muhammad Ariq Basyar's avatar
Muhammad Ariq Basyar committed
98
    - Build
99
100
  before_script:
    - mv $KEY_FASTLANE_ANDROID android/key_fastlane.json
101
    - BUILD_NUMBER=$((BASE_BUILD_NUMBER + CI_PIPELINE_IID))
102
    - mv android/fastlane/metadata/android/id/changelogs/changelogs.txt
103
      android/fastlane/metadata/android/id/changelogs/$BUILD_NUMBER.txt
104
105
106
    - cd android
    - gem install bundler
    - bundle install
107
108
    # track alpha for Closed Testing (development)
    # track beta for Open Testing (staging)
Muhammad Ariq Basyar's avatar
Coldfix    
Muhammad Ariq Basyar committed
109
    - if [ $CI_COMMIT_REF_NAME == 'staging' ]; then
Muhammad Ariq Basyar's avatar
Muhammad Ariq Basyar committed
110
111
112
113
        TRACK=beta;
      else
        TRACK=alpha;
      fi
114
    - echo "uploading app bundle with track $TRACK"
115
  script:
116
117
    - bundle exec fastlane supply
      --aab ../build/app/outputs/bundle/release/app-release.aab
118
      --track $TRACK