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
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
|
// Manages communication with github for reporting important status
// events. Relies on Github integration plugin https://github.com/jenkinsci/github-plugin
class GithubStatus {
// Repository to send status e.g: '/username/repo'
String Repository
// Commit hash to send status e.g: `909b76f97e`
String Commit_id
// Build url send status e.g: `https://jenkins/build/123`
String BUILD_URL
// Set pending status for this pull request
def setPending(script, String context_name, String result_status_when_set_commit_failure = "UNSTABLE") {
this.setBuildStatusStep(script, context_name, "In Progress", "PENDING", result_status_when_set_commit_failure)
}
// Set failed status for this pull request
def setFailed(script, String context_name, String result_status_when_set_commit_failure = "UNSTABLE") {
this.setBuildStatusStep(script, context_name, "Complete", "FAILURE", result_status_when_set_commit_failure)
}
// Set success status for this pull request
def setSuccess(script, String context_name, String result_status_when_set_commit_failure = "UNSTABLE") {
this.setBuildStatusStep(script, context_name, "Complete", "SUCCESS", result_status_when_set_commit_failure)
}
// Manually set PR status via GitHub integration plugin. Manual status updates are needed
// Due to pipeline stage retries not propagating updates back to Github automatically
def setBuildStatusStep(script, String context_name, String message, String state, String result_status_when_set_commit_failure) {
def commitContextName = context_name
def build_url_secret = this.BUILD_URL.replace("icl-jenkins.sc", "llvm-ci")
script.retry(4) {
script.step([
$class : "GitHubCommitStatusSetter",
reposSource : [$class: "ManuallyEnteredRepositorySource", url: "https://github.com/${this.Repository}"],
contextSource : [$class: "ManuallyEnteredCommitContextSource", context: commitContextName],
errorHandlers : [],
commitShaSource : [$class: "ManuallyEnteredShaSource", sha: this.Commit_id],
//statusBackrefSource: [$class: "ManuallyEnteredBackrefSource", backref: "${this.BUILD_URL}flowGraphTable/"],
statusBackrefSource: [$class: "ManuallyEnteredBackrefSource", backref: "${build_url_secret}"],
statusResultSource : [$class: "ConditionalStatusResultSource", results: [[$class: "AnyBuildResult", message: message, state: state]]]
])
}
}
}
def fill_task_name_description (String oneapi_package_date = "Default") {
script {
short_commit_sha = env.Commit_id.substring(0,10)
currentBuild.displayName = "PR#${env.PR_number}-No.${env.BUILD_NUMBER}"
currentBuild.description = "PR number: ${env.PR_number} / Commit id: ${short_commit_sha} / Oneapi package date: ${oneapi_package_date}"
}
}
def githubStatus = new GithubStatus(
Repository: params.Repository,
Commit_id: params.Commit_id,
BUILD_URL: env.RUN_DISPLAY_URL
)
build_ok = true
fail_stage = ""
user_in_github_group = false
pipeline {
agent { label "oneDPL_scheduler" }
options {
durabilityHint 'PERFORMANCE_OPTIMIZED'
timeout(time: 5, unit: 'HOURS')
timestamps()
}
environment {
def NUMBER = sh(script: "expr ${env.BUILD_NUMBER}", returnStdout: true).trim()
def TIMESTEMP = sh(script: "date +%s", returnStdout: true).trim()
def DATESTEMP = sh(script: "date +\"%Y-%m-%d\"", returnStdout: true).trim()
def TEST_TIMEOUT = 1400
}
parameters {
string(name: 'Commit_id', defaultValue: 'None', description: '',)
string(name: 'PR_number', defaultValue: 'None', description: '',)
string(name: 'Repository', defaultValue: 'oneapi-src/oneDPL', description: '',)
string(name: 'User', defaultValue: 'None', description: '',)
string(name: 'OneAPI_Package_Date', defaultValue: 'Default', description: '',)
}
triggers {
GenericTrigger(
genericVariables: [
[key: 'Commit_id', value: '$.pull_request.head.sha', defaultValue: 'None'],
[key: 'PR_number', value: '$.number', defaultValue: 'None'],
[key: 'Repository', value: '$.pull_request.base.repo.full_name', defaultValue: 'None'],
[key: 'User', value: '$.pull_request.user.login', defaultValue: 'None'],
[key: 'action', value: '$.action', defaultValue: 'None']
],
causeString: 'Triggered on $PR_number',
token: 'oneDPL-pre-ci',
printContributedVariables: true,
printPostContent: true,
silentResponse: false,
regexpFilterText: '$action',
regexpFilterExpression: '(opened|reopened|synchronize)'
)
}
stages {
stage('Check_User_in_Org') {
agent {
label "oneDPL_scheduler"
}
steps {
script {
try {
retry(2) {
fill_task_name_description()
def check_user_return = sh(script: "python3 /export/users/oneDPL_CI/check_user_in_group.py -u ${env.User}", returnStatus: true, label: "Check User in Group")
echo "check_user_return value is $check_user_return"
if (check_user_return == 0) {
user_in_github_group = true
if (env.OneAPI_Package_Date == "Default") {
sh(script: "bash /export/users/oneDPL_CI/get_good_compiler.sh ", label: "Get good compiler stamp")
if (fileExists('./Oneapi_Package_Date.txt')) {
env.OneAPI_Package_Date = readFile('./Oneapi_Package_Date.txt')
}
}
echo "Oneapi package date is: " + env.OneAPI_Package_Date.toString()
fill_task_name_description(env.OneAPI_Package_Date)
githubStatus.setPending(this, "Jenkins/UB1804_Check")
}
else {
user_in_github_group = false
currentBuild.result = 'UNSTABLE'
}
}
}
catch (e) {
fail_stage = fail_stage + " " + "Check_User_in_Org"
user_in_github_group = false
echo "Exception occurred when check User:${env.User} in group. Will skip build this time"
sh script: "exit -1", label: "Set Failure"
}
}
}
}
stage('UB1804_Check') {
when {
expression { user_in_github_group }
}
agent { label "oneDPL_UB18" }
stages {
stage('Git-monorepo') {
steps {
script {
try {
retry(2) {
deleteDir()
if (fileExists('./src')) {
sh script: 'rm -rf src', label: "Remove Src Folder"
}
sh script: 'cp -rf /export/users/oneDPL_CI/oneDPL-src/src ./', label: "Copy src Folder"
sh script: "cd ./src; git config --local --add remote.origin.fetch +refs/pull/${env.PR_number}/head:refs/remotes/origin/pr/${env.PR_number}", label: "Set Git Config"
sh script: "cd ./src; git pull origin; git checkout ${env.Commit_id}", label: "Checkout Commit"
if (fileExists('./oneAPI-samples')) {
sh script: 'rm -rf oneAPI-samples', label: "Remove oneAPI-samples Folder"
}
sh script: 'cp -rf /export/users/oneDPL_CI/oneAPI-samples ./', label: "Copy oneAPI-samples Folder"
sh script: 'cd ./oneAPI-samples; git pull origin master', label: "Git Pull oneAPI-samples Folder"
}
}
catch (e) {
build_ok = false
fail_stage = fail_stage + " " + "Git-monorepo"
sh script: "exit -1", label: "Set failure"
}
}
}
}
stage('Setting_Env') {
steps {
script {
try {
sh script: """
bash /export/users/oneDPL_CI/generate_env_file.sh ${env.OneAPI_Package_Date}
if [ ! -f ./envs_tobe_loaded.txt ]; then
echo "Environment file not generated."
exit -1
fi
""", label: "Generate environment vars"
}
catch (e) {
build_ok = false
fail_stage = fail_stage + " " + "Setting_Env"
sh script: "exit -1", label: "Set failure"
}
}
}
}
stage('Tests_dpcpp_cpu_cxx_17') {
steps {
timeout(time: 2, unit: 'HOURS') {
script {
try {
dir("./src/build") {
withEnv(readFile('../../envs_tobe_loaded.txt').split('\n') as List) {
sh script: """
rm -rf *
cmake -DCMAKE_CXX_COMPILER=dpcpp -DCMAKE_CXX_STANDARD=17 -DONEDPL_BACKEND=dpcpp -DONEDPL_DEVICE_TYPE=CPU -DCMAKE_BUILD_TYPE=release ..
make VERBOSE=1 build-all -j`nproc` -k || true
ctest --output-on-failure --timeout ${TEST_TIMEOUT}
""", label: "All tests"
}
}
}
catch(e) {
build_ok = false
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh script: """
exit -1
"""
}
}
}
}
}
}
stage('Tests_g++_tbb_cxx_17') {
steps {
timeout(time: 2, unit: 'HOURS') {
script {
try {
dir("./src/build") {
withEnv(readFile('../../envs_tobe_loaded.txt').split('\n') as List) {
sh script: """
rm -rf *
cmake -DCMAKE_CXX_COMPILER=g++ -DCMAKE_CXX_STANDARD=17 -DONEDPL_BACKEND=tbb -DONEDPL_DEVICE_TYPE=HOST -DCMAKE_BUILD_TYPE=release ..
make VERBOSE=1 build-all -j`nproc` -k || true
ctest --output-on-failure --timeout ${TEST_TIMEOUT}
""", label: "All tests"
}
}
}
catch(e) {
build_ok = false
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh script: """
exit -1
"""
}
}
}
}
}
}
stage('Check_Samples') {
steps {
timeout(time: 1, unit: 'HOURS') {
script {
try {
withEnv(readFile('envs_tobe_loaded.txt').split('\n') as List) {
def gamma_return_value = sh(
script: """
cd oneAPI-samples/Libraries/oneDPL/gamma-correction/
mkdir build
cd build/
cmake ..
make
make run
exit \$?""",
returnStatus: true, label: "gamma_return_value Step")
def stable_sort_return_value = sh(
script: """
cd oneAPI-samples/Libraries/oneDPL/stable_sort_by_key/
mkdir build
cd build/
cmake ..
make
make run
exit \$?""",
returnStatus: true, label: "stable_sort_return_value Step")
if (gamma_return_value != 0 || stable_sort_return_value !=0) {
echo "gamma-correction or stable_sort_by_key check failed. Please check log to fix the issue."
sh script: "exit -1", label: "Set failure"
}
}
}
catch(e) {
build_ok = false
fail_stage = fail_stage + " " + "Check_Samples"
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "exit -1"
}
}
}
}
}
}
}
}
}
post {
always {
script {
if (user_in_github_group) {
if (build_ok) {
currentBuild.result = "SUCCESS"
githubStatus.setSuccess(this, "Jenkins/UB1804_Check")
} else {
currentBuild.result = "FAILURE"
githubStatus.setFailed(this, "Jenkins/UB1804_Check")
}
}
}
}
}
}
|