Jenkinsfile 15.9 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)
60
  timeout(time: 30, 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: 30, 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
}

Mufei Li's avatar
Mufei Li committed
97
98
99
def go_test_linux() {
  init_git()
  unpack_lib('dgl-cpu-linux', dgl_linux_libs)
Mufei Li's avatar
Mufei Li committed
100
  timeout(time: 30, unit: 'MINUTES') {
Mufei Li's avatar
Mufei Li committed
101
102
103
104
    sh "bash tests/scripts/task_go_test.sh"
  }
}

105
def is_authorized(name) {
106
  def authorized_user = ['VoVAllen', 'BarclayII', 'jermainewang', 'zheng-da', 'mufeili', 'Rhett-Ying', 'isratnisa']
107
108
  return (name in authorized_user)
}
VoVAllen's avatar
VoVAllen committed
109

Minjie Wang's avatar
Minjie Wang committed
110
pipeline {
Jinjing Zhou's avatar
Jinjing Zhou committed
111
  agent any
112
113
114
  triggers {
        issueCommentTrigger('@dgl-bot .*')
  }
Minjie Wang's avatar
Minjie Wang committed
115
  stages {
116
117
    stage('Regression Test Trigger') {
      agent {
Jinjing Zhou's avatar
Jinjing Zhou committed
118
119
120
121
        docker {
            label 'linux-benchmark-node'
            image 'dgllib/dgl-ci-lint'
            alwaysPull true
Jinjing Zhou's avatar
Jinjing Zhou committed
122
        }
VoVAllen's avatar
VoVAllen committed
123
      }
124
      when { triggeredBy 'IssueCommentCause' }
Minjie Wang's avatar
Minjie Wang committed
125
      steps {
Jinjing Zhou's avatar
Jinjing Zhou committed
126
127
128
        // container('dgl-ci-lint') {
          checkout scm
          script {
129
130
              def comment = env.GITHUB_COMMENT
              def author = env.GITHUB_COMMENT_AUTHOR
131
132
              echo("${env.GIT_URL}")
              echo("${env}")
133
              if (!is_authorized(author)) {
134
                error('Not authorized to launch regression tests')
135
136
              }
              dir('benchmark_scripts_repo') {
Jinjing Zhou's avatar
Jinjing Zhou committed
137
138
                checkout([$class: 'GitSCM', branches: [[name: '*/master']],
                        userRemoteConfigs: [[credentialsId: 'github', url: 'https://github.com/dglai/DGL_scripts.git']]])
139
140
141
142
143
              }
              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
144
145
              pullRequest.comment('Cannot run the regression test due to unknown command')
              error('Unknown command')
146
              } else {
Jinjing Zhou's avatar
Jinjing Zhou committed
147
              pullRequest.comment("Start the Regression test. View at ${RUN_DISPLAY_URL}")
148
              }
149
              def prNumber = env.BRANCH_NAME.replace('PR-', '')
150
151
              dir('benchmarks/scripts') {
                sh('python3 -m pip install boto3')
152
                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}'")
153
154
155
156
              }
              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
157
158
          }
        // }
159
      }
Minjie Wang's avatar
Minjie Wang committed
160
    }
161
162
    stage('Bot Instruction') {
      agent {
Jinjing Zhou's avatar
Jinjing Zhou committed
163
164
165
166
        docker {
            label 'linux-benchmark-node'
            image 'dgllib/dgl-ci-lint'
            alwaysPull true
Minjie Wang's avatar
Minjie Wang committed
167
        }
168
169
170
171
172
173
174
      }
      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`')
175
176
            }
          }
177
          echo('Not the first build')
178
        }
Minjie Wang's avatar
Minjie Wang committed
179
180
      }
    }
Jinjing Zhou's avatar
Jinjing Zhou committed
181
182
183
    stage('CI') {
      when { not { triggeredBy 'IssueCommentCause' } }
      stages {
184
185
        stage('Lint Check') {
          agent {
Jinjing Zhou's avatar
Jinjing Zhou committed
186
187
            docker {
              label "linux-cpu-node"
Mufei Li's avatar
Mufei Li committed
188
              image "dgllib/dgl-ci-lint"
Jinjing Zhou's avatar
Jinjing Zhou committed
189
              alwaysPull true
VoVAllen's avatar
VoVAllen committed
190
191
            }
          }
Minjie Wang's avatar
Minjie Wang committed
192
          steps {
193
194
            init_git()
            sh 'bash tests/scripts/task_lint.sh'
VoVAllen's avatar
VoVAllen committed
195
          }
196
197
198
199
200
          post {
            always {
              cleanWs disableDeferredWipeout: true, deleteDirs: true
            }
          }
VoVAllen's avatar
VoVAllen committed
201
        }
Mufei Li's avatar
Mufei Li committed
202

203
204
205
206
        stage('Build') {
          parallel {
            stage('CPU Build') {
              agent {
Jinjing Zhou's avatar
Jinjing Zhou committed
207
208
                docker {
                  label "linux-cpu-node"
Mufei Li's avatar
Mufei Li committed
209
                  image "dgllib/dgl-ci-cpu:cu101_v220217"
Jinjing Zhou's avatar
Jinjing Zhou committed
210
211
                  args "-u root"
                  alwaysPull true
212
                }
Jinjing Zhou's avatar
Jinjing Zhou committed
213
214
              }
              steps {
215
                build_dgl_linux('cpu')
Jinjing Zhou's avatar
Jinjing Zhou committed
216
              }
217
218
219
220
              post {
                always {
                  cleanWs disableDeferredWipeout: true, deleteDirs: true
                }
Minjie Wang's avatar
Minjie Wang committed
221
              }
Lingfan Yu's avatar
Lingfan Yu committed
222
            }
223
224
            stage('GPU Build') {
              agent {
Jinjing Zhou's avatar
Jinjing Zhou committed
225
226
                docker {
                  label "linux-cpu-node"
Mufei Li's avatar
Mufei Li committed
227
                  image "dgllib/dgl-ci-gpu:cu101_v220217"
Jinjing Zhou's avatar
Jinjing Zhou committed
228
229
                  args "-u root"
                  alwaysPull true
230
                }
Minjie Wang's avatar
Minjie Wang committed
231
232
              }
              steps {
233
234
                // sh "nvidia-smi"
                build_dgl_linux('gpu')
Minjie Wang's avatar
Minjie Wang committed
235
              }
236
237
238
239
              post {
                always {
                  cleanWs disableDeferredWipeout: true, deleteDirs: true
                }
Minjie Wang's avatar
Minjie Wang committed
240
              }
241
            }
242
243
244
245
            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
246
              steps {
247
248
249
250
251
252
                build_dgl_win64('cpu')
              }
              post {
                always {
                  cleanWs disableDeferredWipeout: true, deleteDirs: true
                }
Minjie Wang's avatar
Minjie Wang committed
253
              }
Lingfan Yu's avatar
Lingfan Yu committed
254
            }
255
          // Currently we don't have Windows GPU build machines
256
          }
Lingfan Yu's avatar
Lingfan Yu committed
257
        }
258
259
260
261
        stage('Test') {
          parallel {
            stage('C++ CPU') {
              agent {
Jinjing Zhou's avatar
Jinjing Zhou committed
262
263
                docker {
                  label "linux-cpu-node"
Mufei Li's avatar
Mufei Li committed
264
                  image "dgllib/dgl-ci-cpu:cu101_v220217"
Jinjing Zhou's avatar
Jinjing Zhou committed
265
                  alwaysPull true
266
267
                }
              }
Minjie Wang's avatar
Minjie Wang committed
268
              steps {
269
270
271
272
273
274
275
276
277
278
                cpp_unit_test_linux('cpu')
              }
              post {
                always {
                  cleanWs disableDeferredWipeout: true, deleteDirs: true
                }
              }
            }
            stage('C++ GPU') {
              agent {
Jinjing Zhou's avatar
Jinjing Zhou committed
279
280
                docker {
                  label "linux-gpu-node"
Mufei Li's avatar
Mufei Li committed
281
                  image "dgllib/dgl-ci-gpu:cu101_v220217"
Jinjing Zhou's avatar
Jinjing Zhou committed
282
283
                  args "--runtime nvidia"
                  alwaysPull true
284
285
286
287
                }
              }
              steps {
                cpp_unit_test_linux('gpu')
288
289
290
291
292
              }
              post {
                always {
                  cleanWs disableDeferredWipeout: true, deleteDirs: true
                }
Minjie Wang's avatar
Minjie Wang committed
293
294
              }
            }
295
296
            stage('C++ CPU (Win64)') {
              agent { label 'windows' }
Minjie Wang's avatar
Minjie Wang committed
297
              steps {
298
299
300
301
302
303
                cpp_unit_test_win64()
              }
              post {
                always {
                  cleanWs disableDeferredWipeout: true, deleteDirs: true
                }
Minjie Wang's avatar
Minjie Wang committed
304
              }
Minjie Wang's avatar
Minjie Wang committed
305
            }
306
307
            stage('Tensorflow CPU') {
              agent {
Jinjing Zhou's avatar
Jinjing Zhou committed
308
309
                docker {
                  label "linux-cpu-node"
Mufei Li's avatar
Mufei Li committed
310
                  image "dgllib/dgl-ci-cpu:cu101_v220217"
Jinjing Zhou's avatar
Jinjing Zhou committed
311
                  alwaysPull true
312
313
314
                }
              }
              stages {
315
                stage('Tensorflow CPU Unit test') {
316
317
318
319
320
321
322
323
324
325
                  steps {
                    unit_test_linux('tensorflow', 'cpu')
                  }
                }
              }
              post {
                always {
                  cleanWs disableDeferredWipeout: true, deleteDirs: true
                }
              }
326
            }
327
328
            stage('Tensorflow GPU') {
              agent {
Jinjing Zhou's avatar
Jinjing Zhou committed
329
330
                docker {
                  label "linux-gpu-node"
Mufei Li's avatar
Mufei Li committed
331
                  image "dgllib/dgl-ci-gpu:cu101_v220217"
Jinjing Zhou's avatar
Jinjing Zhou committed
332
333
                  args "--runtime nvidia"
                  alwaysPull true
334
335
336
                }
              }
              stages {
337
                stage('Tensorflow GPU Unit test') {
338
339
340
341
342
343
344
345
346
347
                  steps {
                    unit_test_linux('tensorflow', 'gpu')
                  }
                }
              }
              post {
                always {
                  cleanWs disableDeferredWipeout: true, deleteDirs: true
                }
              }
VoVAllen's avatar
VoVAllen committed
348
            }
349
350
            stage('Torch CPU') {
              agent {
Jinjing Zhou's avatar
Jinjing Zhou committed
351
352
                docker {
                  label "linux-cpu-node"
Mufei Li's avatar
Mufei Li committed
353
                  image "dgllib/dgl-ci-cpu:cu101_v220217"
Jinjing Zhou's avatar
Jinjing Zhou committed
354
355
                  args "--shm-size=4gb"
                  alwaysPull true
356
357
358
                }
              }
              stages {
359
                stage('Torch CPU Unit test') {
360
361
362
363
                  steps {
                    unit_test_linux('pytorch', 'cpu')
                  }
                }
364
                stage('Torch CPU Example test') {
365
366
367
368
                  steps {
                    example_test_linux('pytorch', 'cpu')
                  }
                }
369
                stage('Torch CPU Tutorial test') {
370
371
372
373
                  steps {
                    tutorial_test_linux('pytorch')
                  }
                }
Mufei Li's avatar
Mufei Li committed
374
375
376
377
378
                stage('DGL-Go CPU test') {
                  steps {
                    go_test_linux()
                  }
                }
379
380
381
382
383
              }
              post {
                always {
                  cleanWs disableDeferredWipeout: true, deleteDirs: true
                }
VoVAllen's avatar
VoVAllen committed
384
              }
Da Zheng's avatar
Da Zheng committed
385
            }
386
387
388
            stage('Torch CPU (Win64)') {
              agent { label 'windows' }
              stages {
389
                stage('Torch CPU (Win64) Unit test') {
390
391
392
393
                  steps {
                    unit_test_win64('pytorch', 'cpu')
                  }
                }
394
                stage('Torch CPU (Win64) Example test') {
395
396
397
398
399
400
401
402
403
404
                  steps {
                    example_test_win64('pytorch', 'cpu')
                  }
                }
              }
              post {
                always {
                  cleanWs disableDeferredWipeout: true, deleteDirs: true
                }
              }
405
            }
406
407
            stage('Torch GPU') {
              agent {
Jinjing Zhou's avatar
Jinjing Zhou committed
408
409
                docker {
                  label "linux-gpu-node"
Mufei Li's avatar
Mufei Li committed
410
                  image "dgllib/dgl-ci-gpu:cu101_v220217"
Jinjing Zhou's avatar
Jinjing Zhou committed
411
412
                  args "--runtime nvidia --shm-size=8gb"
                  alwaysPull true
413
414
415
                }
              }
              stages {
416
                stage('Torch GPU Unit test') {
417
418
419
420
421
                  steps {
                    sh 'nvidia-smi'
                    unit_test_linux('pytorch', 'gpu')
                  }
                }
422
                stage('Torch GPU Example test') {
423
424
425
426
427
428
429
430
431
432
                  steps {
                    example_test_linux('pytorch', 'gpu')
                  }
                }
              }
              post {
                always {
                  cleanWs disableDeferredWipeout: true, deleteDirs: true
                }
              }
433
            }
434
435
            stage('MXNet CPU') {
              agent {
Jinjing Zhou's avatar
Jinjing Zhou committed
436
437
                docker {
                  label "linux-cpu-node"
Mufei Li's avatar
Mufei Li committed
438
                  image "dgllib/dgl-ci-cpu:cu101_v220217"
Jinjing Zhou's avatar
Jinjing Zhou committed
439
                  alwaysPull true
440
441
442
                }
              }
              stages {
443
                stage('MXNet CPU Unit test') {
444
445
446
447
448
449
450
451
452
453
454
455
456
457
                  steps {
                    unit_test_linux('mxnet', 'cpu')
                  }
                }
              //stage("Tutorial test") {
              //  steps {
              //    tutorial_test_linux("mxnet")
              //  }
              //}
              }
              post {
                always {
                  cleanWs disableDeferredWipeout: true, deleteDirs: true
                }
458
459
              }
            }
460
461
            stage('MXNet GPU') {
              agent {
Jinjing Zhou's avatar
Jinjing Zhou committed
462
463
                docker {
                  label "linux-gpu-node"
Mufei Li's avatar
Mufei Li committed
464
                  image "dgllib/dgl-ci-gpu:cu101_v220217"
Jinjing Zhou's avatar
Jinjing Zhou committed
465
466
                  args "--runtime nvidia"
                  alwaysPull true
467
468
469
                }
              }
              stages {
470
                stage('MXNet GPU Unit test') {
471
472
473
474
475
476
477
478
479
480
481
                  steps {
                    sh 'nvidia-smi'
                    unit_test_linux('mxnet', 'gpu')
                  }
                }
              }
              post {
                always {
                  cleanWs disableDeferredWipeout: true, deleteDirs: true
                }
              }
482
            }
483
484
          }
        }
Minjie Wang's avatar
Minjie Wang committed
485
      }
Minjie Wang's avatar
Minjie Wang committed
486
    }
Minjie Wang's avatar
Minjie Wang committed
487
  }
488
489
  post {
    always {
490
      script {
491
        node("dglci-post-linux") {
492
493
494
495
          docker.image('dgllib/dgl-ci-awscli:v220418').inside("--pull always --entrypoint=''") {
            sh("rm -rf ci_tmp")
            dir('ci_tmp') {
              sh("curl -o cireport.log ${BUILD_URL}consoleText")
Rhett Ying's avatar
Rhett Ying committed
496
497
              sh("curl -o report.py https://raw.githubusercontent.com/dmlc/dgl/master/tests/scripts/ci_report/report.py")
              sh("curl -o status.py https://raw.githubusercontent.com/dmlc/dgl/master/tests/scripts/ci_report/status.py")
498
499
500
501
502
503
504
505
              sh("curl -L ${BUILD_URL}wfapi")
              sh("cat status.py")
              sh("pytest --html=report.html --self-contained-html report.py || true")
              sh("aws s3 sync ./ s3://dgl-ci-result/${JOB_NAME}/${BUILD_NUMBER}/${BUILD_ID}/logs/  --exclude '*' --include '*.log' --acl public-read --content-type text/plain")
              sh("aws s3 sync ./ s3://dgl-ci-result/${JOB_NAME}/${BUILD_NUMBER}/${BUILD_ID}/logs/  --exclude '*.log' --acl public-read")

              def comment = sh(returnStdout: true, script: "python3 status.py").trim()
              echo(comment)
506
507
508
              if ((env.BRANCH_NAME).startsWith('PR-')) {
                pullRequest.comment(comment)
              }
509
510
511
512
513
514
            }
          }
        }
        node('windows') {
            bat(script: "rmvirtualenv ${BUILD_TAG}", returnStatus: true)
        }
515
516
517
      }
    }
  }
Minjie Wang's avatar
Minjie Wang committed
518
}