Jenkinsfile 13.7 KB
Newer Older
Lingfan Yu's avatar
Lingfan Yu committed
1
2
#!/usr/bin/env groovy

3
dgl_linux_libs = 'build/libdgl.so, build/runUnitTests, python/dgl/_ffi/_cy3/core.cpython-36m-x86_64-linux-gnu.so, build/tensoradapter/pytorch/*.so'
Minjie Wang's avatar
Minjie Wang committed
4
// Currently DGL on Windows is not working with Cython yet
5
dgl_win64_libs = "build\\dgl.dll, build\\runUnitTests.exe, build\\tensoradapter\\pytorch\\*.dll"
Minjie Wang's avatar
Minjie Wang committed
6
7

def init_git() {
8
  sh 'rm -rf *'
Minjie Wang's avatar
Minjie Wang committed
9
  checkout scm
10
  sh 'git submodule update --recursive --init'
Lingfan Yu's avatar
Lingfan Yu committed
11
12
}

Minjie Wang's avatar
Minjie Wang committed
13
14
def init_git_win64() {
  checkout scm
15
  bat 'git submodule update --recursive --init'
Lingfan Yu's avatar
Lingfan Yu committed
16
17
}

Minjie Wang's avatar
Minjie Wang committed
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// pack libraries for later use
def pack_lib(name, libs) {
  echo "Packing ${libs} into ${name}"
  stash includes: libs, name: name
}

// unpack libraries saved before
def unpack_lib(name, libs) {
  unstash name
  echo "Unpacked ${libs} from ${name}"
}

def build_dgl_linux(dev) {
  init_git()
32
  sh "bash tests/scripts/build_dgl.sh ${dev}"
33
  sh 'ls -lh /usr/lib/x86_64-linux-gnu/'
Minjie Wang's avatar
Minjie Wang committed
34
  pack_lib("dgl-${dev}-linux", dgl_linux_libs)
Lingfan Yu's avatar
Lingfan Yu committed
35
36
}

Minjie Wang's avatar
Minjie Wang committed
37
def build_dgl_win64(dev) {
38
39
  /* Assuming that Windows slaves are already configured with MSBuild VS2017,
   * CMake and Python/pip/setuptools etc. */
Minjie Wang's avatar
Minjie Wang committed
40
  init_git_win64()
41
  bat "CALL tests\\scripts\\build_dgl.bat"
Minjie Wang's avatar
Minjie Wang committed
42
  pack_lib("dgl-${dev}-win64", dgl_win64_libs)
43
44
}

45
def cpp_unit_test_linux(dev) {
Minjie Wang's avatar
Minjie Wang committed
46
  init_git()
47
  unpack_lib("dgl-${dev}-linux", dgl_linux_libs)
48
  sh 'bash tests/scripts/task_cpp_unit_test.sh'
VoVAllen's avatar
VoVAllen committed
49
50
}

Minjie Wang's avatar
Minjie Wang committed
51
52
def cpp_unit_test_win64() {
  init_git_win64()
53
  unpack_lib('dgl-cpu-win64', dgl_win64_libs)
VoVAllen's avatar
VoVAllen committed
54
55
56
  bat "CALL tests\\scripts\\task_cpp_unit_test.bat"
}

Minjie Wang's avatar
Minjie Wang committed
57
def unit_test_linux(backend, dev) {
Minjie Wang's avatar
Minjie Wang committed
58
  init_git()
Minjie Wang's avatar
Minjie Wang committed
59
  unpack_lib("dgl-${dev}-linux", dgl_linux_libs)
Jinjing Zhou's avatar
Jinjing Zhou committed
60
  timeout(time: 20, unit: 'MINUTES') {
61
    sh "bash tests/scripts/task_unit_test.sh ${backend} ${dev}"
Minjie Wang's avatar
Minjie Wang committed
62
  }
Lingfan Yu's avatar
Lingfan Yu committed
63
64
}

65
def unit_test_win64(backend, dev) {
Minjie Wang's avatar
Minjie Wang committed
66
  init_git_win64()
Minjie Wang's avatar
Minjie Wang committed
67
  unpack_lib("dgl-${dev}-win64", dgl_win64_libs)
68
  timeout(time: 10, unit: 'MINUTES') {
69
    bat "CALL tests\\scripts\\task_unit_test.bat ${backend}"
Minjie Wang's avatar
Minjie Wang committed
70
  }
Da Zheng's avatar
Da Zheng committed
71
72
}

Minjie Wang's avatar
Minjie Wang committed
73
def example_test_linux(backend, dev) {
Minjie Wang's avatar
Minjie Wang committed
74
  init_git()
Minjie Wang's avatar
Minjie Wang committed
75
  unpack_lib("dgl-${dev}-linux", dgl_linux_libs)
Minjie Wang's avatar
Minjie Wang committed
76
77
  timeout(time: 20, unit: 'MINUTES') {
    sh "bash tests/scripts/task_example_test.sh ${dev}"
Minjie Wang's avatar
Minjie Wang committed
78
79
80
  }
}

81
def example_test_win64(backend, dev) {
Minjie Wang's avatar
Minjie Wang committed
82
  init_git_win64()
Minjie Wang's avatar
Minjie Wang committed
83
  unpack_lib("dgl-${dev}-win64", dgl_win64_libs)
Minjie Wang's avatar
Minjie Wang committed
84
85
  timeout(time: 20, unit: 'MINUTES') {
    bat "CALL tests\\scripts\\task_example_test.bat ${dev}"
86
87
88
  }
}

Minjie Wang's avatar
Minjie Wang committed
89
def tutorial_test_linux(backend) {
Minjie Wang's avatar
Minjie Wang committed
90
  init_git()
91
  unpack_lib('dgl-cpu-linux', dgl_linux_libs)
Minjie Wang's avatar
Minjie Wang committed
92
93
  timeout(time: 20, unit: 'MINUTES') {
    sh "bash tests/scripts/task_${backend}_tutorial_test.sh"
Minjie Wang's avatar
Minjie Wang committed
94
  }
Lingfan Yu's avatar
Lingfan Yu committed
95
96
}

97
98
99
100
def is_authorized(name) {
  def authorized_user = ['VoVAllen', 'BarclayII', 'jermainewang', 'zheng-da', 'mufeili']
  return (name in authorized_user)
}
VoVAllen's avatar
VoVAllen committed
101

Minjie Wang's avatar
Minjie Wang committed
102
pipeline {
Jinjing Zhou's avatar
Jinjing Zhou committed
103
  agent any
104
105
106
  triggers {
        issueCommentTrigger('@dgl-bot .*')
  }
Minjie Wang's avatar
Minjie Wang committed
107
  stages {
108
109
    stage('Regression Test Trigger') {
      agent {
Jinjing Zhou's avatar
Jinjing Zhou committed
110
111
112
113
        kubernetes {
          yamlFile 'docker/pods/ci-lint.yaml'
          defaultContainer 'dgl-ci-lint'
        }
VoVAllen's avatar
VoVAllen committed
114
      }
115
      when { triggeredBy 'IssueCommentCause' }
Minjie Wang's avatar
Minjie Wang committed
116
      steps {
Jinjing Zhou's avatar
Jinjing Zhou committed
117
118
119
        // container('dgl-ci-lint') {
          checkout scm
          script {
120
121
              def comment = env.GITHUB_COMMENT
              def author = env.GITHUB_COMMENT_AUTHOR
122
123
              echo("${env.GIT_URL}")
              echo("${env}")
124
              if (!is_authorized(author)) {
125
                error('Not authorized to launch regression tests')
126
127
              }
              dir('benchmark_scripts_repo') {
Jinjing Zhou's avatar
Jinjing Zhou committed
128
129
                checkout([$class: 'GitSCM', branches: [[name: '*/master']],
                        userRemoteConfigs: [[credentialsId: 'github', url: 'https://github.com/dglai/DGL_scripts.git']]])
130
131
132
133
134
              }
              sh('cp benchmark_scripts_repo/benchmark/* benchmarks/scripts/')
              def command_lists = comment.split(' ')
              def instance_type = command_lists[2].replace('.', '')
              if (command_lists.size() != 5) {
Jinjing Zhou's avatar
Jinjing Zhou committed
135
136
              pullRequest.comment('Cannot run the regression test due to unknown command')
              error('Unknown command')
137
              } else {
Jinjing Zhou's avatar
Jinjing Zhou committed
138
              pullRequest.comment("Start the Regression test. View at ${RUN_DISPLAY_URL}")
139
              }
140
              def prNumber = env.BRANCH_NAME.replace('PR-', '')
141
142
              dir('benchmarks/scripts') {
                sh('python3 -m pip install boto3')
143
                sh("PYTHONUNBUFFERED=1 GIT_PR_ID=${prNumber} GIT_URL=${env.GIT_URL} GIT_BRANCH=${env.CHANGE_BRANCH} python3 run_reg_test.py --data-folder ${env.GIT_COMMIT}_${instance_type} --run-cmd '${comment}'")
144
145
146
147
              }
              pullRequest.comment("Finished the Regression test. Result table is at https://dgl-asv-data.s3-us-west-2.amazonaws.com/${env.GIT_COMMIT}_${instance_type}/results/result.csv. Jenkins job link is ${RUN_DISPLAY_URL}. ")
              currentBuild.result = 'SUCCESS'
              return
Jinjing Zhou's avatar
Jinjing Zhou committed
148
149
          }
        // }
150
      }
Minjie Wang's avatar
Minjie Wang committed
151
    }
152
153
    stage('Bot Instruction') {
      agent {
Jinjing Zhou's avatar
Jinjing Zhou committed
154
155
156
        kubernetes {
          yamlFile 'docker/pods/ci-lint.yaml'
          defaultContainer 'dgl-ci-lint'
Minjie Wang's avatar
Minjie Wang committed
157
        }
158
159
160
161
162
163
164
      }
      steps {
        script {
          def prOpenTriggerCause = currentBuild.getBuildCauses('jenkins.branch.BranchEventCause')
          if (prOpenTriggerCause) {
            if (env.BUILD_ID == '1') {
              pullRequest.comment('To trigger regression tests: \n - `@dgl-bot run [instance-type] [which tests] [compare-with-branch]`; \n For example: `@dgl-bot run g4dn.4xlarge all dmlc/master` or `@dgl-bot run c5.9xlarge kernel,api dmlc/master`')
165
166
            }
          }
167
          echo('Not the first build')
168
        }
Minjie Wang's avatar
Minjie Wang committed
169
170
      }
    }
Jinjing Zhou's avatar
Jinjing Zhou committed
171
172
173
    stage('CI') {
      when { not { triggeredBy 'IssueCommentCause' } }
      stages {
174
175
        stage('Lint Check') {
          agent {
Jinjing Zhou's avatar
Jinjing Zhou committed
176
177
178
            kubernetes {
              yamlFile 'docker/pods/ci-lint.yaml'
              defaultContainer 'dgl-ci-lint'
VoVAllen's avatar
VoVAllen committed
179
180
            }
          }
Minjie Wang's avatar
Minjie Wang committed
181
          steps {
182
183
            init_git()
            sh 'bash tests/scripts/task_lint.sh'
VoVAllen's avatar
VoVAllen committed
184
          }
185
186
187
188
189
          post {
            always {
              cleanWs disableDeferredWipeout: true, deleteDirs: true
            }
          }
VoVAllen's avatar
VoVAllen committed
190
        }
Jinjing Zhou's avatar
Jinjing Zhou committed
191
        
192
193
194
195
        stage('Build') {
          parallel {
            stage('CPU Build') {
              agent {
Jinjing Zhou's avatar
Jinjing Zhou committed
196
197
198
                kubernetes {
                  yamlFile 'docker/pods/ci-compile-cpu.yaml'
                  defaultContainer 'dgl-ci-cpu-compile'
199
                }
Jinjing Zhou's avatar
Jinjing Zhou committed
200
201
              }
              steps {
202
                build_dgl_linux('cpu')
Jinjing Zhou's avatar
Jinjing Zhou committed
203
              }
204
205
206
207
              post {
                always {
                  cleanWs disableDeferredWipeout: true, deleteDirs: true
                }
Minjie Wang's avatar
Minjie Wang committed
208
              }
Lingfan Yu's avatar
Lingfan Yu committed
209
            }
210
211
            stage('GPU Build') {
              agent {
Jinjing Zhou's avatar
Jinjing Zhou committed
212
213
214
                kubernetes {
                  yamlFile 'docker/pods/ci-compile-gpu.yaml'
                  defaultContainer 'dgl-ci-gpu-compile'
215
                }
Minjie Wang's avatar
Minjie Wang committed
216
217
              }
              steps {
218
219
                // sh "nvidia-smi"
                build_dgl_linux('gpu')
Minjie Wang's avatar
Minjie Wang committed
220
              }
221
222
223
224
              post {
                always {
                  cleanWs disableDeferredWipeout: true, deleteDirs: true
                }
Minjie Wang's avatar
Minjie Wang committed
225
              }
226
            }
227
228
229
230
            stage('CPU Build (Win64)') {
              // Windows build machines are manually added to Jenkins master with
              // "windows" label as permanent agents.
              agent { label 'windows' }
Minjie Wang's avatar
Minjie Wang committed
231
              steps {
232
233
234
235
236
237
                build_dgl_win64('cpu')
              }
              post {
                always {
                  cleanWs disableDeferredWipeout: true, deleteDirs: true
                }
Minjie Wang's avatar
Minjie Wang committed
238
              }
Lingfan Yu's avatar
Lingfan Yu committed
239
            }
240
          // Currently we don't have Windows GPU build machines
241
          }
Lingfan Yu's avatar
Lingfan Yu committed
242
        }
243
244
245
246
        stage('Test') {
          parallel {
            stage('C++ CPU') {
              agent {
Jinjing Zhou's avatar
Jinjing Zhou committed
247
248
249
                kubernetes {
                  yamlFile 'docker/pods/ci-cpu.yaml'
                  defaultContainer 'dgl-ci-cpu'
250
251
                }
              }
Minjie Wang's avatar
Minjie Wang committed
252
              steps {
253
254
255
256
257
258
259
260
261
262
                cpp_unit_test_linux('cpu')
              }
              post {
                always {
                  cleanWs disableDeferredWipeout: true, deleteDirs: true
                }
              }
            }
            stage('C++ GPU') {
              agent {
Jinjing Zhou's avatar
Jinjing Zhou committed
263
264
265
                kubernetes {
                  yamlFile 'docker/pods/ci-gpu.yaml'
                  defaultContainer 'dgl-ci-gpu'
266
267
268
269
                }
              }
              steps {
                cpp_unit_test_linux('gpu')
270
271
272
273
274
              }
              post {
                always {
                  cleanWs disableDeferredWipeout: true, deleteDirs: true
                }
Minjie Wang's avatar
Minjie Wang committed
275
276
              }
            }
277
278
            stage('C++ CPU (Win64)') {
              agent { label 'windows' }
Minjie Wang's avatar
Minjie Wang committed
279
              steps {
280
281
282
283
284
285
                cpp_unit_test_win64()
              }
              post {
                always {
                  cleanWs disableDeferredWipeout: true, deleteDirs: true
                }
Minjie Wang's avatar
Minjie Wang committed
286
              }
Minjie Wang's avatar
Minjie Wang committed
287
            }
288
289
            stage('Tensorflow CPU') {
              agent {
Jinjing Zhou's avatar
Jinjing Zhou committed
290
291
292
                kubernetes {
                  yamlFile 'docker/pods/ci-cpu.yaml'
                  defaultContainer 'dgl-ci-cpu'
293
294
295
296
297
298
299
300
301
302
303
304
305
306
                }
              }
              stages {
                stage('Unit test') {
                  steps {
                    unit_test_linux('tensorflow', 'cpu')
                  }
                }
              }
              post {
                always {
                  cleanWs disableDeferredWipeout: true, deleteDirs: true
                }
              }
307
            }
308
309
            stage('Tensorflow GPU') {
              agent {
Jinjing Zhou's avatar
Jinjing Zhou committed
310
311
312
                kubernetes {
                  yamlFile 'docker/pods/ci-gpu.yaml'
                  defaultContainer 'dgl-ci-gpu'
313
314
315
316
317
318
319
320
321
322
323
324
325
326
                }
              }
              stages {
                stage('Unit test') {
                  steps {
                    unit_test_linux('tensorflow', 'gpu')
                  }
                }
              }
              post {
                always {
                  cleanWs disableDeferredWipeout: true, deleteDirs: true
                }
              }
VoVAllen's avatar
VoVAllen committed
327
            }
328
329
            stage('Torch CPU') {
              agent {
Jinjing Zhou's avatar
Jinjing Zhou committed
330
331
332
                kubernetes {
                  yamlFile 'docker/pods/ci-cpu.yaml'
                  defaultContainer 'dgl-ci-cpu'
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
                }
              }
              stages {
                stage('Unit test') {
                  steps {
                    unit_test_linux('pytorch', 'cpu')
                  }
                }
                stage('Example test') {
                  steps {
                    example_test_linux('pytorch', 'cpu')
                  }
                }
                stage('Tutorial test') {
                  steps {
Jinjing Zhou's avatar
Jinjing Zhou committed
348
349
                    sh 'ls -l /tmp/dataset/*'
                    sh 'ls -l /tmp/dataset/'
350
351
352
353
354
355
356
357
                    tutorial_test_linux('pytorch')
                  }
                }
              }
              post {
                always {
                  cleanWs disableDeferredWipeout: true, deleteDirs: true
                }
VoVAllen's avatar
VoVAllen committed
358
              }
Da Zheng's avatar
Da Zheng committed
359
            }
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
            stage('Torch CPU (Win64)') {
              agent { label 'windows' }
              stages {
                stage('Unit test') {
                  steps {
                    unit_test_win64('pytorch', 'cpu')
                  }
                }
                stage('Example test') {
                  steps {
                    example_test_win64('pytorch', 'cpu')
                  }
                }
              }
              post {
                always {
                  cleanWs disableDeferredWipeout: true, deleteDirs: true
                }
              }
379
            }
380
381
            stage('Torch GPU') {
              agent {
Jinjing Zhou's avatar
Jinjing Zhou committed
382
383
384
                kubernetes {
                  yamlFile 'docker/pods/ci-gpu.yaml'
                  defaultContainer 'dgl-ci-gpu'
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
                }
              }
              stages {
                stage('Unit test') {
                  steps {
                    sh 'nvidia-smi'
                    unit_test_linux('pytorch', 'gpu')
                  }
                }
                stage('Example test') {
                  steps {
                    example_test_linux('pytorch', 'gpu')
                  }
                }
              }
              post {
                always {
                  cleanWs disableDeferredWipeout: true, deleteDirs: true
                }
              }
405
            }
406
407
            stage('MXNet CPU') {
              agent {
Jinjing Zhou's avatar
Jinjing Zhou committed
408
409
410
                kubernetes {
                  yamlFile 'docker/pods/ci-cpu.yaml'
                  defaultContainer 'dgl-ci-cpu'
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
                }
              }
              stages {
                stage('Unit test') {
                  steps {
                    unit_test_linux('mxnet', 'cpu')
                  }
                }
              //stage("Tutorial test") {
              //  steps {
              //    tutorial_test_linux("mxnet")
              //  }
              //}
              }
              post {
                always {
                  cleanWs disableDeferredWipeout: true, deleteDirs: true
                }
429
430
              }
            }
431
432
            stage('MXNet GPU') {
              agent {
Jinjing Zhou's avatar
Jinjing Zhou committed
433
434
435
                kubernetes {
                  yamlFile 'docker/pods/ci-gpu.yaml'
                  defaultContainer 'dgl-ci-gpu'
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
                }
              }
              stages {
                stage('Unit test') {
                  steps {
                    sh 'nvidia-smi'
                    unit_test_linux('mxnet', 'gpu')
                  }
                }
              }
              post {
                always {
                  cleanWs disableDeferredWipeout: true, deleteDirs: true
                }
              }
451
            }
452
453
          }
        }
Minjie Wang's avatar
Minjie Wang committed
454
      }
Minjie Wang's avatar
Minjie Wang committed
455
    }
Minjie Wang's avatar
Minjie Wang committed
456
  }
457
458
459
460
461
462
463
  post {
    always {
      node('windows') {
        bat "rmvirtualenv ${BUILD_TAG}"
      }
    }
  }
Minjie Wang's avatar
Minjie Wang committed
464
}