-
Notifications
You must be signed in to change notification settings - Fork 34
/
Copy pathazure-pipelines.yml
148 lines (126 loc) · 4.71 KB
/
azure-pipelines.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
147
148
variables:
BUILD_OUTPUT_DIR: app/build/outputs/apk
TESTS_XML_DIR: app/build/outputs/androidTest-results
IMG_NAME: system-images;android-23;google_apis;x86
IMG_ABI: google_apis/x86
DEVICE_TYPE: "Nexus 4"
DEVICE_NAME: Nexus4Emu
DEVICE_VIDEO_DIR: /mnt/sdcard/DCIM
VM_IMAGE: 'macOS 10.13'
NODE_VER: '9.11.2'
NPM_VER: 6.5
jobs:
# Job to Build the Browsers
- job: Cliqz_Android_CI_Build
timeoutInMinutes: 60
pool:
vmImage: $(VM_IMAGE)
steps:
- task: NodeTool@0
displayName: 'Define Node to v$(NODE_VER)'
inputs:
versionSpec: $(NODE_VER)
- bash: |
npm i -g npm@$(NPM_VER)
/usr/local/bin/npm ci
npm run bundle
displayName: 'Build ReactNative'
- task: Gradle@2
inputs:
gradleWrapperFile: 'gradlew'
tasks: $(gradle.flavor)
env:
DISABLE_GOOGLE_SERVICES: true
displayName: 'Run Gradle Task: $(gradle.flavor)'
- bash: |
find $(BUILD_OUTPUT_DIR) -iregex '.*-debug\.apk' -exec cp '{}' $(Build.ArtifactStagingDirectory) ';'
displayName: 'Copy Builds'
- task: PublishBuildArtifacts@1
displayName: 'Publish Builds'
inputs:
pathtoPublish: '$(Build.ArtifactStagingDirectory)'
artifactName: '$(Build.BuildId).Builds'
publishLocation: 'Container'
# Job to Test the Cliqz and Lumen Browser
- job: Cliqz_Android_CI_Test
condition: and(eq(variables['run.tests'], 'true'), ne(variables['Build.Reason'], 'Schedule'))
timeoutInMinutes: 60
pool:
vmImage: $(VM_IMAGE)
steps:
- task: NodeTool@0
displayName: 'Define Node to v$(NODE_VER)'
inputs:
versionSpec: $(NODE_VER)
- bash: |
npm i -g npm@$(NPM_VER)
/usr/local/bin/npm ci
npm run bundle
displayName: 'Build ReactNative'
- bash: |
$ANDROID_HOME/tools/bin/sdkmanager "$(IMG_NAME)"
$ANDROID_HOME/tools/bin/avdmanager create avd --device "$(DEVICE_TYPE)" --package "$(IMG_NAME)" --abi "$(IMG_ABI)" --name "$(DEVICE_NAME)"
$ANDROID_HOME/emulator/emulator -avd $(DEVICE_NAME) &
echo $! > emu.pid
echo "Emulator Started with Process ID: $(cat emu.pid)"
$ANDROID_HOME/platform-tools/adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed | tr -d '\r') ]]; do sleep 1; done; input keyevent 82'
sleep 60
$ANDROID_HOME/platform-tools/adb devices
displayName: 'Setup and Launch Emulator'
- bash: |
$ANDROID_HOME/platform-tools/adb shell """
mount -o rw,remount rootfs /;
chmod 0777 /mnt/sdcard;
exit
"""
sleep 10
$ANDROID_HOME/platform-tools/adb logcat -c
$ANDROID_HOME/platform-tools/adb logcat > $(Build.ArtifactStagingDirectory)/device.log &
echo $! > logcat.pid
echo "Logcat Started with Process ID: $(cat logcat.pid)"
$ANDROID_HOME/platform-tools/adb shell "mkdir -p $(DEVICE_VIDEO_DIR)"
$ANDROID_HOME/platform-tools/adb shell '''
for i in $(seq 1 1 20)
do
screenrecord --bugreport --verbose --time-limit=180 /mnt/sdcard/DCIM/test"${i}".mp4
done
''' > $(Build.ArtifactStagingDirectory)/video.log &
echo $! > video.pid
echo "Video Recorder Started with Process ID: $(cat video.pid)"
displayName: 'Start Video Record and Logcat'
- task: Gradle@2
condition: or(succeeded(), failed())
inputs:
gradleWrapperFile: 'gradlew'
options: '--continue'
publishJUnitResults: true
testResultsFiles: '$(TESTS_XML_DIR)/**/TEST-*.xml'
testRunTitle: 'CliqzAndroidTest'
tasks: 'connectedCliqzDebugAndroidTest'
displayName: 'Run Tests on Cliqz'
# - task: Gradle@2
# condition: or(succeeded(), failed())
# inputs:
# gradleWrapperFile: 'gradlew'
# options: '--continue'
# publishJUnitResults: true
# testResultsFiles: '$(TESTS_XML_DIR)/**/LUMENX86/TEST-*.xml'
# testRunTitle: 'LumenX86AndroidTest'
# tasks: 'connectedLumenX86DebugAndroidTest'
# displayName: 'Run Tests on Lumen'
- bash: |
kill -9 $(cat video.pid) || true
sleep 5
$ANDROID_HOME/platform-tools/adb pull $(DEVICE_VIDEO_DIR) $(Build.ArtifactStagingDirectory) || true
kill -9 $(cat logcat.pid) || true
adb kill-server
kill -9 $(cat emu.pid)
condition: or(succeeded(), failed())
displayName: 'Copy Videos and Clean Up'
- task: PublishBuildArtifacts@1
condition: or(succeeded(), failed())
displayName: 'Publish Tests Archive'
inputs:
pathtoPublish: '$(Build.ArtifactStagingDirectory)'
artifactName: '$(Build.BuildId).TestsArchive'
publishLocation: 'Container'