Skip to content

Commit

Permalink
Improve CI (dmlc#92)
Browse files Browse the repository at this point in the history
* gcn example test code

* GPU test

* use python3

* use functions

* gpu test use functions

* remove root

* use one script to run both cpu and gpu tests
  • Loading branch information
lingfanyu authored Oct 19, 2018
1 parent 3e76bcc commit 49ea781
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 36 deletions.
90 changes: 54 additions & 36 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,38 @@
#!/usr/bin/env groovy

def setup() {
sh 'easy_install nose'
sh 'git submodule init'
sh 'git submodule update'
}

def build_dgl() {
sh 'if [ -d build ]; then rm -rf build; fi; mkdir build'
dir('python') {
sh 'python3 setup.py install'
}
dir ('build') {
sh 'cmake ..'
sh 'make -j$(nproc)'
}
}

def unit_test() {
withEnv(["DGL_LIBRARY_PATH=${env.WORKSPACE}/build"]) {
sh 'nosetests tests -v --with-xunit'
sh 'nosetests tests/pytorch -v --with-xunit'
sh 'nosetests tests/graph_index -v --with-xunit'
}
}

def example_test(dev) {
dir ('tests/scripts') {
withEnv(["DGL_LIBRARY_PATH=${env.WORKSPACE}/build"]) {
sh "./test_examples.sh ${dev}"
}
}
}

pipeline {
agent none
stages {
Expand All @@ -7,36 +42,27 @@ pipeline {
agent {
docker {
image 'lingfanyu/dgl-cpu'
args '-u root'
}
}
stages {
stage('SETUP') {
steps {
sh 'easy_install nose'
sh 'git submodule init'
sh 'git submodule update'
setup()
}
}
stage('BUILD') {
steps {
sh 'if [ -d build ]; then rm -rf build; fi; mkdir build'
dir('python') {
sh 'python3 setup.py install'
}
dir ('build') {
sh 'cmake ..'
sh 'make -j$(nproc)'
}
build_dgl()
}
}
stage('UNIT TEST') {
steps {
unit_test()
}
}
stage('TEST') {
stage('EXAMPLE TEST') {
steps {
withEnv(["DGL_LIBRARY_PATH=${env.WORKSPACE}/build"]) {
sh 'nosetests tests -v --with-xunit'
sh 'nosetests tests/pytorch -v --with-xunit'
sh 'nosetests tests/graph_index -v --with-xunit'
}
example_test('CPU')
}
}
}
Expand All @@ -50,36 +76,28 @@ pipeline {
agent {
docker {
image 'lingfanyu/dgl-gpu'
args '--runtime nvidia -u root'
args '--runtime nvidia'
}
}
stages {
stage('SETUP') {
steps {
sh 'easy_install nose'
sh 'git submodule init'
sh 'git submodule update'
setup()
}
}
stage('BUILD') {
steps {
sh 'if [ -d build ]; then rm -rf build; fi; mkdir build'
dir('python') {
sh 'python3 setup.py install'
}
dir ('build') {
sh 'cmake ..'
sh 'make -j$(nproc)'
}
build_dgl()
}
}
stage('UNIT TEST') {
steps {
unit_test()
}
}
stage('TEST') {
stage('EXAMPLE TEST') {
steps {
withEnv(["DGL_LIBRARY_PATH=${env.WORKSPACE}/build"]) {
sh 'nosetests tests -v --with-xunit'
sh 'nosetests tests/pytorch -v --with-xunit'
sh 'nosetests tests/graph_index -v --with-xunit'
}
example_test('GPU')
}
}
}
Expand Down
36 changes: 36 additions & 0 deletions tests/scripts/test_examples.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/bash

GCN_EXAMPLE_DIR="../../examples/pytorch/gcn"

function fail {
echo FAIL: $@
exit -1
}

function usage {
echo "Usage: $0 [CPU|GPU]"
}

# check arguments
if [ $# -ne 1 ]; then
usage
fail "Error: must specify device"
fi

if [ "$1" == "CPU" ]; then
dev=-1
elif [ "$1" == "GPU" ]; then
export CUDA_VISIBLE_DEVICES=0
dev=0
else
usage
fail "Unknown device $1"
fi

pushd $GCN_EXAMPLE_DIR> /dev/null

# test CPU
python3 gcn.py --dataset cora --gpu $dev || fail "run gcn.py on $1"
python3 gcn_spmv.py --dataset cora --gpu $dev || fail "run gcn_spmv.py on $1"

popd > /dev/null

0 comments on commit 49ea781

Please sign in to comment.