forked from cliqz-oss/browser-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
243 lines (208 loc) · 7.38 KB
/
Jenkinsfile
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
#!/bin/env groovy
def gitCommit = ''
node('ubuntu && docker && !gpu') {
stage('checkout') {
checkout scm
}
helpers = load 'build-helpers.groovy'
props = helpers.entries([
'DOCKER_REGISTRY_URL': 'https://141047255820.dkr.ecr.us-east-1.amazonaws.com',
'AWS_REGION': 'us-east-1'
])
params = []
for (int i = 0; i < props.size(); i++) {
def prop = props.get(i)
def propName = prop[0]
def propValue = prop[1]
def binding = getBinding()
if (!binding.hasVariable(propName)) {
binding.setVariable(propName, propValue)
}
params.push(
string(defaultValue: propValue, description: '', name: propName)
)
}
properties([
parameters(params)
])
gitCommit = helpers.getGitCommit()
// stash dockerfile for use on other nodes without checkout
stash name: "test-helpers", includes: "build-helpers.groovy,run_tests_testem.sh"
def imgName = "navigation-extension/base"
sh "`aws ecr get-login --region=$AWS_REGION`"
docker.withRegistry(DOCKER_REGISTRY_URL) {
timeout(60) {
def image = docker.image(imgName)
image.pull()
docker.image(image.imageName()).inside() {
helpers.withCache {
stage('fern install') {
sh './fern.js install'
}
// mobile build and stash
withEnv(['CLIQZ_CONFIG_PATH=./configs/mobile-dev.json']) {
stage('fern build mobile') {
sh './fern.js build > /dev/null'
// stage built files for mobile testem test
stash name: "mobile-testem-build", includes: "bower_components/,build/,tests/,testem.json"
}
}
// desktop build & test
withEnv(['CLIQZ_CONFIG_PATH=./configs/jenkins.json']) {
stage('fern build desktop') {
sh './fern.js build > /dev/null'
// stage built files for mobile testem test
stash name: "content-testem-build", includes: "bower_components/,build/,tests/,testem.json"
}
stage('fern test') {
sh 'rm -rf unittest-report.xml'
try {
sh './fern.js test --ci unittest-report.xml > /dev/null'
} catch(err) {
print "TESTS FAILED"
currentBuild.result = "FAILURE"
} finally {
step([
$class: 'JUnitResultArchiver',
allowEmptyResults: false,
testResults: 'unittest-report.xml',
])
}
}
}
stage('fresh-tab-frontend tests') {
helpers.reportStatusToGithub 'fresh-tab-frontend', gitCommit, "pending", {
try {
sh 'rm -rf subprojects/fresh-tab-frontend/ember-report.xml'
sh '''
cd subprojects/fresh-tab-frontend
ember test ci --silent > ember-report.xml
'''
return 'subprojects/fresh-tab-frontend/ember-report.xml'
} catch(err) {
print "Ember TESTS FAILED"
currentBuild.result = "FAILURE"
throw err
} finally {
step([
$class: 'JUnitResultArchiver',
allowEmptyResults: false,
testResults: 'subprojects/fresh-tab-frontend/ember-report.xml',
])
}
}
}
}
stage('package') {
sh """
cd build
fab package:beta=True,version=${gitCommit}
"""
}
}
}
}
stage('publish artifacts') {
archive "build/Cliqz.${gitCommit}.xpi"
archive 'run_tests.sh'
}
}
stage('tests') {
// Define version of firefox we want to test
// Full list here: https://ftp.mozilla.org/pub/firefox/releases/
// The extension will be tested on each specified firefox version in parallel
def stepsForParallel = [:]
def firefoxVersions = helpers.firefoxVersions
for (int i = 0; i < firefoxVersions.size(); i++) {
def entry = firefoxVersions.get(i)
def version = entry[0]
def url = entry[1]
stepsForParallel['Firefox ' + version] = {
build(
job: 'cliqz/navigation-extension/nav-ext-browser-matrix-v3',
parameters: [
string(name: 'FIREFOX_VERSION', value: version),
string(name: 'TRIGGERING_BUILD_NUMBER', value: env.BUILD_NUMBER),
string(name: 'TRIGGERING_JOB_NAME', value: env.JOB_NAME),
]
)
}
}
stepsForParallel['testem mobile'] = {
node('ubuntu-docker-gpu') {
def HOST = sh(returnStdout: true, script: '/sbin/ifconfig eth0 | grep "inet addr:" | cut -d: -f2 | awk \'{ print $1}\'').trim()
def NUMBER = env.BUILD_NUMBER.padLeft(5, "00000")
def VNC_PORT = "20${NUMBER[-3..-1]}"
// load files for test into workspace
unstash "mobile-testem-build"
unstash "test-helpers"
def helpers = load 'build-helpers.groovy'
def imgName = "navigation-extension/testem"
sh "`aws ecr get-login --region=$AWS_REGION`"
docker.withRegistry(DOCKER_REGISTRY_URL) {
timeout(20) {
helpers.reportStatusToGithub 'testem mobile', gitCommit, "VNC $HOST:$VNC_PORT", {
def image = docker.image(imgName)
image.pull()
docker.image(image.imageName()).inside("-p $VNC_PORT:5900 --device /dev/nvidia0 --device /dev/nvidiactl") {
sh 'rm -rf report.xml'
try {
sh './run_tests_testem.sh'
return 'report.xml'
} catch(err) {
print "TESTS FAILED"
currentBuild.result = "FAILURE"
throw err
} finally {
step([
$class: 'JUnitResultArchiver',
allowEmptyResults: false,
testResults: 'report.xml',
])
}
}
}
}
}
}
}
stepsForParallel['testem desktop content'] = {
node('ubuntu-docker-gpu') {
def HOST = sh(returnStdout: true, script: '/sbin/ifconfig eth0 | grep "inet addr:" | cut -d: -f2 | awk \'{ print $1}\'').trim()
def NUMBER = env.BUILD_NUMBER.padLeft(5, "00000")
def VNC_PORT = "21${NUMBER[-3..-1]}"
// load files for test into workspace
unstash "content-testem-build"
unstash "test-helpers"
def helpers = load 'build-helpers.groovy'
def imgName = "navigation-extension/testem"
sh "`aws ecr get-login --region=$AWS_REGION`"
docker.withRegistry(DOCKER_REGISTRY_URL) {
timeout(20) {
helpers.reportStatusToGithub 'testem desktop content', gitCommit, "VNC $HOST:$VNC_PORT", {
def image = docker.image(imgName)
image.pull()
docker.image(image.imageName()).inside("-p $VNC_PORT:5900 --device /dev/nvidia0 --device /dev/nvidiactl") {
sh 'rm -rf report.xml'
try {
sh './run_tests_testem.sh'
return 'report.xml'
} catch(err) {
print "TESTS FAILED"
currentBuild.result = "FAILURE"
throw err
} finally {
step([
$class: 'JUnitResultArchiver',
allowEmptyResults: false,
testResults: 'report.xml',
])
}
}
}
}
}
}
}
parallel stepsForParallel
}