Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CI] Jenkins on Windows builds #324

Merged
merged 12 commits into from
Dec 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
115 changes: 77 additions & 38 deletions Jenkinsfile
Original file line number Diff line number Diff line change
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"
}
BarclayII marked this conversation as resolved.
Show resolved Hide resolved

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}"
}
}
BarclayII marked this conversation as resolved.
Show resolved Hide resolved

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") }
}
}
BarclayII marked this conversation as resolved.
Show resolved Hide resolved
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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"