Skip to content

Commit

Permalink
[CI] Jenkins on Windows builds (#324)
Browse files Browse the repository at this point in the history
* Jenkins build & test on Windows

* oops

* still running nohup on Windows slaves

* ooops again

* squishing vcvars and cmake

* another try

* reverting back

* --user

* switching to msbuild

* made the graph size in cache testing bigger

* put commands into script files

* oooops
  • Loading branch information
BarclayII authored and jermainewang committed Dec 22, 2018
1 parent 01e8794 commit 75e2af7
Show file tree
Hide file tree
Showing 7 changed files with 181 additions and 39 deletions.
115 changes: 77 additions & 38 deletions Jenkinsfile
Expand Up @@ -5,47 +5,49 @@ def init_git_submodule() {
sh "git submodule update"
}

def setup() {
init_git_submodule()
def init_git_submodule_win64() {
bat "git submodule init"
bat "git submodule update"
}

def build_dgl() {
sh "if [ -d build ]; then rm -rf build; fi; mkdir build"
sh "rm -rf _download"
dir ("build") {
sh "cmake .."
sh "make -j4"
}
dir("python") {
sh "rm -rf build *.egg-info dist"
sh "pip3 uninstall -y dgl"
sh "python3 setup.py install"
}
sh "bash tests/scripts/build_dgl.sh"
}

def pytorch_unit_test(dev) {
withEnv(["DGL_LIBRARY_PATH=${env.WORKSPACE}/build", "PYTHONPATH=${env.WORKSPACE}/python"]) {
sh "python3 -m nose -v --with-xunit tests"
sh "python3 -m nose -v --with-xunit tests/pytorch"
sh "python3 -m nose -v --with-xunit tests/graph_index"
def build_dgl_win64() {
/* Assuming that Windows slaves are already configured with MSBuild VS2017,
* CMake and Python/pip/setuptools etc. */
bat "CALL tests\\scripts\\build_dgl.bat"
}

def unit_test(backend, dev) {
withEnv(["DGL_LIBRARY_PATH=${env.WORKSPACE}/build", "PYTHONPATH=${env.WORKSPACE}/python", "DGLBACKEND=${backend}"]) {
sh "bash tests/scripts/task_unit_test.sh ${backend}"
}
}

def mxnet_unit_test(dev) {
withEnv(["DGL_LIBRARY_PATH=${env.WORKSPACE}/build", "PYTHONPATH=${env.WORKSPACE}/python"]) {
sh "python3 -m nose -v --with-xunit tests/mxnet"
sh "python3 -m nose -v --with-xunit tests/graph_index"
def unit_test_win64(backend, dev) {
withEnv(["DGL_LIBRARY_PATH=${env.WORKSPACE}\\build", "PYTHONPATH=${env.WORKSPACE}\\python", "DGLBACKEND=${backend}"]) {
bat "CALL tests\\scripts\\task_unit_test.bat ${backend}"
}
}

def example_test(dev) {
withEnv(["DGL_LIBRARY_PATH=${env.WORKSPACE}/build", "PYTHONPATH=${env.WORKSPACE}/python"]) {
def example_test(backend, dev) {
withEnv(["DGL_LIBRARY_PATH=${env.WORKSPACE}/build", "PYTHONPATH=${env.WORKSPACE}/python", "DGLBACKEND=${backend}"]) {
dir ("tests/scripts") {
sh "bash task_example_test.sh ${dev}"
}
}
}

def example_test_win64(backend, dev) {
withEnv(["DGL_LIBRARY_PATH=${env.WORKSPACE}\\build", "PYTHONPATH=${env.WORKSPACE}\\python", "DGLBACKEND=${backend}"]) {
dir ("tests\\scripts") {
bat "CALL task_example_test ${dev}"
}
}
}

def pytorch_tutorials() {
withEnv(["DGL_LIBRARY_PATH=${env.WORKSPACE}/build", "PYTHONPATH=${env.WORKSPACE}/python"]) {
dir ("tests/scripts") {
Expand All @@ -65,7 +67,9 @@ pipeline {
agent none
stages {
stage("Lint Check") {
agent { docker { image "dgllib/dgl-ci-lint" } }
agent {
docker { image "dgllib/dgl-ci-lint" }
}
steps {
init_git_submodule()
sh "bash tests/scripts/task_lint.sh"
Expand All @@ -74,9 +78,11 @@ pipeline {
stage("Build") {
parallel {
stage("CPU Build") {
agent { docker { image "dgllib/dgl-ci-cpu" } }
agent {
docker { image "dgllib/dgl-ci-cpu" }
}
steps {
setup()
init_git_submodule()
build_dgl()
}
}
Expand All @@ -88,29 +94,56 @@ pipeline {
}
}
steps {
setup()
init_git_submodule()
build_dgl()
}
}
stage("MXNet CPU Build (temp)") {
agent { docker { image "dgllib/dgl-ci-mxnet-cpu" } }
agent {
docker { image "dgllib/dgl-ci-mxnet-cpu" }
}
steps {
setup()
init_git_submodule()
build_dgl()
}
}
stage("CPU Build (Win64/PyTorch)") {
agent {
label "windows"
}
steps {
init_git_submodule_win64()
build_dgl_win64()
}
}
}
}
stage("Test") {
parallel {
stage("Pytorch CPU") {
agent { docker { image "dgllib/dgl-ci-cpu" } }
agent {
docker { image "dgllib/dgl-ci-cpu" }
}
stages {
stage("TH CPU unittest") {
steps { pytorch_unit_test("CPU") }
steps { unit_test("pytorch", "CPU") }
}
stage("TH CPU example test") {
steps { example_test("CPU") }
steps { example_test("pytorch", "CPU") }
}
}
post {
always { junit "*.xml" }
}
}
stage("Pytorch CPU (Windows)") {
agent { label "windows" }
stages {
stage("TH CPU Win64 unittest") {
steps { unit_test_win64("pytorch", "CPU") }
}
stage("TH CPU Win64 example test") {
steps { example_test_win64("pytorch", "CPU") }
}
}
post {
Expand All @@ -130,7 +163,7 @@ pipeline {
// steps { pytorch_unit_test("GPU") }
//}
stage("TH GPU example test") {
steps { example_test("GPU") }
steps { example_test("pytorch", "GPU") }
}
}
// TODO: have GPU unittest
Expand All @@ -139,10 +172,12 @@ pipeline {
//}
}
stage("MXNet CPU") {
agent { docker { image "dgllib/dgl-ci-mxnet-cpu" } }
agent {
docker { image "dgllib/dgl-ci-mxnet-cpu" }
}
stages {
stage("MX Unittest") {
steps { mxnet_unit_test("CPU") }
steps { unit_test("mxnet", "CPU") }
}
}
post {
Expand All @@ -154,13 +189,17 @@ pipeline {
stage("Doc") {
parallel {
stage("TH Tutorial") {
agent { docker { image "dgllib/dgl-ci-cpu" } }
agent {
docker { image "dgllib/dgl-ci-cpu" }
}
steps {
pytorch_tutorials()
}
}
stage("MX Tutorial") {
agent { docker { image "dgllib/dgl-ci-mxnet-cpu" } }
agent {
docker { image "dgllib/dgl-ci-mxnet-cpu" }
}
steps {
mxnet_tutorials()
}
Expand Down
2 changes: 1 addition & 1 deletion tests/pytorch/test_graph.py
Expand Up @@ -94,7 +94,7 @@ def test_incmat():

def test_incmat_cache():
n = 1000
p = 2 * math.log(n) / n
p = 10 * math.log(n) / n
a = sp.random(n, n, p, data_rvs=lambda n: np.ones(n))
g = dgl.DGLGraph(a)
# the first call should contruct the inc
Expand Down
21 changes: 21 additions & 0 deletions tests/scripts/build_dgl.bat
@@ -0,0 +1,21 @@
@ECHO OFF
SETLOCAL EnableDelayedExpansion

DEL /S /Q build
DEL /S /Q _download
MD build

PUSHD build
CALL "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Auxiliary\Build\vcvars64.bat"
cmake -DCMAKE_CXX_FLAGS="/DDGL_EXPORTS" -DCMAKE_CONFIGURATION_TYPES="Release" .. -G "Visual Studio 15 2017 Win64" || EXIT /B 1
msbuild dgl.sln || EXIT /B 1
COPY Release\dgl.dll .
POPD

PUSHD python
DEL /S /Q build *.egg-info dist
pip install -e . --force-reinstall --user || EXIT /B 1
POPD

ENDLOCAL
EXIT /B
19 changes: 19 additions & 0 deletions tests/scripts/build_dgl.sh
@@ -0,0 +1,19 @@
#!/bin/bash

if [ -d build ]; then
rm -rf build
fi
mkdir build

rm -rf _download

pushd build
cmake ..
make -j4
popd

pushd python
rm -rf build *.egg-info dist
pip3 uninstall -y dgl
python3 setup.py install
popd
28 changes: 28 additions & 0 deletions tests/scripts/task_example_test.bat
@@ -0,0 +1,28 @@
@ECHO OFF
SETLOCAL EnableDelayedExpansion

IF x%1x==xx (
ECHO Must supply CPU or GPU
GOTO :FAIL
) ELSE IF x%1x==xCPUx (
SET DEV=-1
) ELSE IF x%1x==xGPUx (
SET DEV=0
SET CUDA_VISIBLE_DEVICES=0
) ELSE (
ECHO Must supply CPU or GPU
GOTO :FAIL
)

PUSHD ..\..\examples\pytorch
python pagerank.py || GOTO :FAIL
python gcn\gcn.py --dataset cora --gpu !dev! || GOTO :FAIL
python gcn\gcn_spmv.py --dataset cora --gpu !dev! || GOTO :FAIL
POPD
ENDLOCAL
EXIT /B

:FAIL
ECHO Example test failed
ENDLOCAL
EXIT /B 1
14 changes: 14 additions & 0 deletions tests/scripts/task_unit_test.bat
@@ -0,0 +1,14 @@
@ECHO OFF
SETLOCAL EnableDelayedExpansion

IF x%1x==xx (
ECHO Specify backend
EXIT /B 1
) ELSE (
SET BACKEND=%1
)

python -m nose -v --with-xunit tests || EXIT /B 1
python -m nose -v --with-xunit tests\!BACKEND! || EXIT /B 1
python -m nose -v --with-xunit tests\graph_index || EXIT /B 1
EXIT /B
21 changes: 21 additions & 0 deletions tests/scripts/task_unit_test.sh
@@ -0,0 +1,21 @@
#!/bin/bash

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

function usage {
echo "Usage: $0 backend"
}

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

BACKEND=$1

python3 -m nose -v --with-xunit tests || fail "tests"
python3 -m nose -v --with-xunit tests/$BACKEND || fail "backend"
python3 -m nose -v --with-xunit tests/graph_index || fail "graph_index"

0 comments on commit 75e2af7

Please sign in to comment.