Merge branch 'master' into 'master'
[bitmask_android.git] / .gitlab-ci.yml
1 ---
2 stages:
3   - docker_image_sdk
4   - docker_image_other
5   - build
6   - test
7
8 # When using dind, it's wise to use the overlayfs driver for
9 # improved performance.
10 variables:
11   DOCKER_DRIVER: overlay
12
13 .job_template: &build_docker_image
14   image: 0xacab.org:4567/leap/docker/debian:stretch_amd64
15   tags:
16     - docker-in-docker
17   services:
18     - docker:dind
19
20   before_script:
21     - >
22       export LAST_COMMIT=$(curl -s --header "PRIVATE-TOKEN: ${LEAP_CODE_O_MATIC_PRIVATE_TOKEN}" https://0xacab.org/api/v4/projects/578/pipelines |
23       python -c "import sys, json; print json.load(sys.stdin)[1]['sha']")
24
25   script:
26     - docker --version
27     - docker info
28     - if ! .gitlab/build.sh ${DOCKER_IMAGE} >> dockerbuild.log 2>&1; then echo "Image build failed. Please check dockerbuild.log."; exit 1; fi;
29   allow_failure: false
30   artifacts:
31     expire_in: 3d
32     paths:
33     - dockerbuild.log
34
35 docker_image:sdk:
36   stage: docker_image_sdk
37   variables:
38     DOCKER_IMAGE: android-sdk
39   <<: *build_docker_image
40
41 docker_image:ndk:
42   stage: docker_image_other
43   variables:
44     DOCKER_IMAGE: android-ndk
45   <<: *build_docker_image
46
47 docker_image:emulator:
48   stage: docker_image_other
49   variables:
50     DOCKER_IMAGE: android-emulator
51   <<: *build_docker_image
52
53 unit_test:
54   image: "0xacab.org:4567/leap/bitmask_android/android-ndk:latest"
55   stage: test
56   script:
57     - ./gradlew testCustomProductionFatReleaseUnitTest testNormalProductionFatReleaseUnitTest
58   artifacts:
59     paths:
60       - app/build/reports/tests
61     when: on_failure
62     expire_in: 3 days
63
64 #ui_test:
65 #  image: "0xacab.org:4567/leap/bitmask_android/android-emulator:latest"
66 #  stage: test
67 #  script:
68 #    - emulator -avd testApi27 -no-audio -no-window &
69 #    - .gitlab/wait-for-emulator.sh
70 #    - adb devices
71 #    - adb shell settings put global window_animation_scale 0 &
72 #    - adb shell settings put global transition_animation_scale 0 &
73 #    - adb shell settings put global animator_duration_scale 0 &
74 #    - adb shell input keyevent 82 &
75 #    - ./gradlew connectedAndroidTest
76 #    - adb -s testApi27 emu kill
77
78 #expanded_test:
79 #  image: "0xacab.org:4567/leap/bitmask_android/android-emulator:latest"
80 #  stage: test
81 #  script:
82 #    - emulator -avd testApi27 -no-audio -no-window &
83 #    - .gitlab/wait-for-emulator.sh
84 #    - adb devices
85 #    - adb shell settings put global window_animation_scale 0 &
86 #    - adb shell settings put global transition_animation_scale 0 &
87 #    - adb shell settings put global animator_duration_scale 0 &
88 #    - adb shell input keyevent 82 &
89 #    - ./gradlew connectedAndroidTest
90 #    - ./gradlew createProductionDebugCoverageReport
91 #    - adb -s testApi27 emu kill
92 #    - ./gradlew test
93 #  artifacts:
94 #    expire_in: 3 days
95 #    paths:
96 #      - app/build/reports/androidTests/connected/
97 #      - app/build/reports/coverage/production/
98 #      - app/build/tests/
99 #  when: manual
100
101 build:
102   image: "0xacab.org:4567/leap/bitmask_android/android-ndk:latest"
103   stage: build
104   script:
105     - ./cleanProject.sh
106     - ./build_deps.sh >> build_deps.log 2>&1
107     - ./gradlew clean assembleNormalProductionFatDebug --stacktrace >> build.log 2>&1
108   artifacts:
109     paths:
110     - app/build/outputs/
111     - build_deps.log
112     - build.log
113     when: always
114     expire_in: 3 days
115
116 build_release:
117   image: "0xacab.org:4567/leap/bitmask_android/android-ndk:latest"
118   stage: build
119   script:
120     - ./prepareForDistribution.sh build -no-tag >> normalRelease.log 2>&1
121   artifacts:
122     paths:
123       - app/build/outputs/
124       - currentReleases/
125       - normalRelease.log
126     when: always
127     expire_in: 1 week
128   when: manual
129
130 build_fdroid_beta_release:
131   image: "0xacab.org:4567/leap/bitmask_android/android-ndk:latest"
132   stage: build
133   script:
134     - ./prepareForDistribution.sh build -no-tag -beta >> normalBeta.log 2>&1
135   artifacts:
136     paths:
137       - app/build/outputs/
138       - currentReleases/
139       - normalBeta.log
140     when: always
141     expire_in: 1 week
142   when: manual
143
144 build_custom_release:
145   image: "0xacab.org:4567/leap/bitmask_android/android-ndk:latest"
146   stage: build
147   script:
148     - ./prepareForDistribution.sh build -no-tag -custom >> customRelease.log 2>&1
149   artifacts:
150     paths:
151     - app/build/outputs/
152     - currentReleases/
153     - customRelease.log
154     when: always
155     expire_in: 1 week
156   when: manual
157
158 build_fdroid_custom_beta_release:
159   image: "0xacab.org:4567/leap/bitmask_android/android-ndk:latest"
160   stage: build
161   script:
162     - ./prepareForDistribution.sh build -no-tag -beta -custom >> customBeta.log 2>&1
163   artifacts:
164     paths:
165       - app/build/outputs/
166       - currentReleases/
167       - customBeta.log
168     when: always
169     expire_in: 1 week
170   when: manual