forked from guardianproject/checkey
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
146 lines (132 loc) · 4.74 KB
/
.gitlab-ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
image: registry.gitlab.com/fdroid/ci-images-client:latest
cache:
paths:
- .gradle/wrapper
- .gradle/caches
stages:
- test
- deploy
.android-template: &android-template
before_script:
- export GRADLE_USER_HOME=$PWD/.gradle
- export ANDROID_COMPILE_SDK=`sed -n 's,.*compileSdkVersion\s*\([0-9][0-9]*\).*,\1,p' app/build.gradle`
- alias sdkmanager="sdkmanager --no_https"
- echo y | sdkmanager "platforms;android-${ANDROID_COMPILE_SDK}" > /dev/null
- apt-get update
- apt-get -qy install gradle --no-install-recommends
.test-template: &test-template
<<: *android-template
stage: test
artifacts:
name: "${CI_PROJECT_PATH}_${CI_JOB_STAGE}_${CI_COMMIT_REF_NAME}_${CI_COMMIT_SHA}"
paths:
- logcat.txt
- app/build/reports
- app/build/outputs/*ml
- app/build/outputs/apk
expire_in: 1 week
when: on_failure
after_script:
- echo "Download debug artifacts from https://gitlab.com/${CI_PROJECT_PATH}/-/jobs"
test_lint:
<<: *test-template
script:
# always report on lint errors to the build log
- sed -i -e 's,textReport .*,textReport true,' app/build.gradle
- gradle build
# once these prove stable, the task should be switched to
# connectedCheck to test all the build flavors
.connected-template: &connected-template
script:
- gradle assembleDebug
- export AVD_SDK=`echo $CI_JOB_NAME | awk '{print $2}'`
- export AVD_TAG=`echo $CI_JOB_NAME | awk '{print $3}'`
- export AVD_ARCH=`echo $CI_JOB_NAME | awk '{print $4}'`
- export AVD_PACKAGE="system-images;android-${AVD_SDK};${AVD_TAG};${AVD_ARCH}"
- echo $AVD_PACKAGE
- emulator -accel-check || true
# download proven emulator version, based on
# https://aur.archlinux.org/android-emulator.git
- rm -rf $ANDROID_HOME/emulator
- wget -q http://dl.google.com/android/repository/emulator-linux-5264690.zip
- echo "48c1cda2bdf3095d9d9d5c010fbfb3d6d673e3ea emulator-linux-5264690.zip" | sha1sum -c
- unzip -qq -d $ANDROID_HOME emulator-linux-5264690.zip
- grep Revision $ANDROID_HOME/emulator/source.properties
- alias sdkmanager
- echo y | sdkmanager "platforms;android-$AVD_SDK" > /dev/null
- if ! avdmanager list avd | grep "Name. avd$AVD_SDK$"; then
set -x;
rm -rf ~/.android/avd $ANDROID_HOME/system-images;
echo y | sdkmanager "$AVD_PACKAGE" > /dev/null;
echo no | avdmanager create avd --name avd$AVD_SDK --tag "$AVD_TAG" --package "$AVD_PACKAGE" --sdcard 64M --device "Nexus 5";
export RAMSIZE="`sed -n 's,^MemAvailable:[^0-9]*\([0-9][0-9]*\)[^0-9]*$,\1,p' /proc/meminfo`";
if [ $RAMSIZE -le 2048 ]; then
sed -i '/^hw\.ramSize\s*=.*/d' ~/.android/avd/*.avd/config.ini;
echo "hw.ramSize=1024" >> ~/.android/avd/*.avd/config.ini;
fi;
avdmanager list avd;
set +x;
fi
- grep -v '^License' $ANDROID_HOME/system-images/android-$AVD_SDK/$AVD_TAG/$AVD_ARCH/source.properties
- adb start-server
- ls -l ~/.android
- emulator -version
- emulator -avd avd$AVD_SDK
-no-audio
-no-jni
-no-snapstorage
-no-window
-skip-adb-auth
-verbose
-wipe-data
&
- wait-for-emulator
- adb devices
- adb shell input keyevent 82 &
- test $AVD_SDK -ge 25 || export FLAG=-Pandroid.testInstrumentationRunnerArguments.notAnnotation=android.support.test.filters.LargeTest
- gradle connectedDebugAndroidTest $FLAG || (adb -e logcat -d > logcat.txt; exit 1)
connected 22 default armeabi-v7a:
retry: 1
<<: *test-template
<<: *connected-template
.website-template: &website-template
image: debian:buster-slim
variables:
GIT_SUBMODULE_STRATEGY: normal
script:
- apt-get update
- apt-get -qy install --no-install-recommends hugo
- sed -i "s,^baseURL\x3a.*,baseURL\x3a https://${CI_PROJECT_NAMESPACE}.gitlab.io/${CI_PROJECT_NAME}/," config.yaml
- hugo
- test -e public/es/index.html
website:
stage: test
except:
- master
<<: *website-template
pages:
stage: deploy
only:
- master
artifacts:
paths:
- public
<<: *website-template
deploy_nightly:
<<: *android-template
stage: deploy
only:
- master
script:
- test -z "$DEBUG_KEYSTORE" && exit 0
- sed -i
's,<string name="app_name">.*</string>,<string name="app_name">Checkey Nightly</string>,'
app/src/main/res/values*/strings.xml
- sed -i "s,^\(\s*versionCode\) *[0-9].*,\1 $(date '+%s')," app/build.gradle
# build the APKs!
- gradle assembleDebug
- fdroid nightly -v
after_script:
# this file changes every time but should not be cached
- rm -f $GRADLE_USER_HOME/caches/modules-2/modules-2.lock
- rm -fr $GRADLE_USER_HOME/caches/*/plugin-resolution/