From 78d5d4dd5ce5a537ed04cd1bf242c9e9ea2c391a Mon Sep 17 00:00:00 2001 From: hyukjinkwon Date: Thu, 8 Sep 2016 08:26:59 -0700 Subject: [SPARK-17200][PROJECT INFRA][BUILD][SPARKR] Automate building and testing on Windows (currently SparkR only) ## What changes were proposed in this pull request? This PR adds the build automation on Windows with [AppVeyor](https://www.appveyor.com/) CI tool. Currently, this only runs the tests for SparkR as we have been having some issues with testing Windows-specific PRs (e.g. https://github.com/apache/spark/pull/14743 and https://github.com/apache/spark/pull/13165) and hard time to verify this. One concern is, this build is dependent on [steveloughran/winutils](https://github.com/steveloughran/winutils) for pre-built Hadoop bin package (who is a Hadoop PMC member). ## How was this patch tested? Manually, https://ci.appveyor.com/project/HyukjinKwon/spark/build/88-SPARK-17200-build-profile This takes roughly 40 mins. Some tests are already being failed and this was found in https://github.com/apache/spark/pull/14743#issuecomment-241405287. Author: hyukjinkwon Closes #14859 from HyukjinKwon/SPARK-17200-build. --- dev/appveyor-guide.md | 168 ++++++++++++++++++++++++++++++++++ dev/appveyor-install-dependencies.ps1 | 126 +++++++++++++++++++++++++ 2 files changed, 294 insertions(+) create mode 100644 dev/appveyor-guide.md create mode 100644 dev/appveyor-install-dependencies.ps1 (limited to 'dev') diff --git a/dev/appveyor-guide.md b/dev/appveyor-guide.md new file mode 100644 index 0000000000..d2e00b4847 --- /dev/null +++ b/dev/appveyor-guide.md @@ -0,0 +1,168 @@ +# AppVeyor Guides + +Currently, SparkR on Windows is being tested with [AppVeyor](https://ci.appveyor.com). This page describes how to set up AppVeyor with Spark, how to run the build, check the status and stop the build via this tool. There is the documenation for AppVeyor [here](https://www.appveyor.com/docs). Please refer this for full details. + + +### Setting up AppVeyor + +#### Sign up AppVeyor. + +- Go to https://ci.appveyor.com, and then click "SIGN UP FOR FREE". + + 2016-09-04 11 07 48 + +- As Apache Spark is one of open source projects, click "FREE - for open-source projects". + + 2016-09-04 11 07 58 + +- Click "Github". + + 2016-09-04 11 08 10 + + +#### After signing up, go to profile to link Github and AppVeyor. + +- Click your account and then click "Profile". + + 2016-09-04 11 09 43 + +- Enable the link with GitHub via clicking "Link Github account". + + 2016-09-04 11 09 52 + +- Click "Authorize application" in Github site. + +2016-09-04 11 10 05 + + +#### Add a project, Spark to enable the builds. + +- Go to the PROJECTS menu. + + 2016-08-30 12 16 31 + +- Click "NEW PROJECT" to add Spark. + + 2016-08-30 12 16 35 + +- Since we will use Github here, click the "GITHUB" button and then click "Authorize Github" so that AppVeyor can access to the Github logs (e.g. commits). + + 2016-09-04 11 10 22 + +- Click "Authorize application" from Github (the above step will pop up this page). + + 2016-09-04 11 10 27 + +- Come back to https://ci.appveyor.com/projects/new and then adds "spark". + + 2016-09-04 11 10 36 + + +#### Check if any event supposed to run the build actually triggers the build. + +- Click "PROJECTS" menu. + + 2016-08-30 12 16 31 + +- Click Spark project. + + 2016-09-04 11 22 37 + + +### Checking the status, restarting and stopping the build + +- Click "PROJECTS" menu. + + 2016-08-30 12 16 31 + +- Locate "spark" and click it. + + 2016-09-04 11 22 37 + +- Here, we can check the status of current build. Also, "HISTORY" shows the past build history. + + 2016-09-04 11 23 24 + +- If the build is stopped, "RE-BUILD COMMIT" button appears. Click this button to restart the build. + + 2016-08-30 12 29 41 + +- If the build is running, "CANCEL BUILD" buttom appears. Click this button top cancel the current build. + + 2016-08-30 1 11 13 + + +### Specifying the branch for building and setting the build schedule + +Note: It seems the configurations in UI and `appveyor.yml` are mutually exclusive according to the [documentation](https://www.appveyor.com/docs/build-configuration/#configuring-build). + + +- Click the settings button on the right. + + 2016-08-30 1 19 12 + +- Set the default branch to build as above. + + 2016-08-30 12 42 25 + +- Specify the branch in order to exclude the builds in other branches. + + 2016-08-30 12 42 33 + +- Set the Crontab expression to regularly start the build. AppVeyor uses Crontab expression, [atifaziz/NCrontab](https://github.com/atifaziz/NCrontab/wiki/Crontab-Expression). Please refer the examples [here](https://github.com/atifaziz/NCrontab/wiki/Crontab-Examples). + + + 2016-08-30 12 42 43 + + +### Filtering commits and Pull Requests + +Currently, AppVeyor is only used for SparkR. So, the build is only triggered when R codes are changed. + +This is specified in `.appveyor.yml` as below: + +``` +only_commits: + files: + - R/ +``` + +Please refer https://www.appveyor.com/docs/how-to/filtering-commits for more details. + + +### Checking the full log of the build + +Currently, the console in AppVeyor does not print full details. This can be manually checked. For example, AppVeyor shows the failed tests as below in console + +``` +Failed ------------------------------------------------------------------------- +1. Error: union on two RDDs (@test_binary_function.R#38) ----------------------- +1: textFile(sc, fileName) at C:/projects/spark/R/lib/SparkR/tests/testthat/test_binary_function.R:38 +2: callJMethod(sc, "textFile", path, getMinPartitions(sc, minPartitions)) +3: invokeJava(isStatic = FALSE, objId$id, methodName, ...) +4: stop(readString(conn)) +``` + +After downloading the log by clicking the log button as below: + +![2016-09-08 11 37 17](https://cloud.githubusercontent.com/assets/6477701/18335227/b07d0782-75b8-11e6-94da-1b88cd2a2402.png) + +the details can be checked as below (e.g. exceptions) + +``` +Failed ------------------------------------------------------------------------- +1. Error: spark.lda with text input (@test_mllib.R#655) ------------------------ + org.apache.spark.sql.AnalysisException: Path does not exist: file:/C:/projects/spark/R/lib/SparkR/tests/testthat/data/mllib/sample_lda_data.txt; + at org.apache.spark.sql.execution.datasources.DataSource$$anonfun$12.apply(DataSource.scala:376) + at org.apache.spark.sql.execution.datasources.DataSource$$anonfun$12.apply(DataSource.scala:365) + at scala.collection.TraversableLike$$anonfun$flatMap$1.apply(TraversableLike.scala:241) + at scala.collection.TraversableLike$$anonfun$flatMap$1.apply(TraversableLike.scala:241) + ... + + 1: read.text("data/mllib/sample_lda_data.txt") at C:/projects/spark/R/lib/SparkR/tests/testthat/test_mllib.R:655 + 2: dispatchFunc("read.text(path)", x, ...) + 3: f(x, ...) + 4: callJMethod(read, "text", paths) + 5: invokeJava(isStatic = FALSE, objId$id, methodName, ...) + 6: stop(readString(conn)) +``` diff --git a/dev/appveyor-install-dependencies.ps1 b/dev/appveyor-install-dependencies.ps1 new file mode 100644 index 0000000000..087b8666cc --- /dev/null +++ b/dev/appveyor-install-dependencies.ps1 @@ -0,0 +1,126 @@ +<# +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +#> + +$CRAN = "https://cloud.r-project.org" + +Function InstallR { + if ( -not(Test-Path Env:\R_ARCH) ) { + $arch = "i386" + } + Else { + $arch = $env:R_ARCH + } + + $urlPath = "" + $latestVer = $(ConvertFrom-JSON $(Invoke-WebRequest http://rversions.r-pkg.org/r-release).Content).version + If ($rVer -ne $latestVer) { + $urlPath = ("old/" + $rVer + "/") + } + + $rurl = $CRAN + "/bin/windows/base/" + $urlPath + "R-" + $rVer + "-win.exe" + + # Downloading R + Start-FileDownload $rurl "R-win.exe" + + # Running R installer + Start-Process -FilePath .\R-win.exe -ArgumentList "/VERYSILENT /DIR=C:\R" -NoNewWindow -Wait + + $RDrive = "C:" + echo "R is now available on drive $RDrive" + + $env:PATH = $RDrive + '\R\bin\' + $arch + ';' + 'C:\MinGW\msys\1.0\bin;' + $env:PATH + + # Testing R installation + Rscript -e "sessionInfo()" +} + +Function InstallRtools { + $rtoolsver = $rToolsVer.Split('.')[0..1] -Join '' + $rtoolsurl = $CRAN + "/bin/windows/Rtools/Rtools$rtoolsver.exe" + + # Downloading Rtools + Start-FileDownload $rtoolsurl "Rtools-current.exe" + + # Running Rtools installer + Start-Process -FilePath .\Rtools-current.exe -ArgumentList /VERYSILENT -NoNewWindow -Wait + + $RtoolsDrive = "C:" + echo "Rtools is now available on drive $RtoolsDrive" + + if ( -not(Test-Path Env:\GCC_PATH) ) { + $gccPath = "gcc-4.6.3" + } + Else { + $gccPath = $env:GCC_PATH + } + $env:PATH = $RtoolsDrive + '\Rtools\bin;' + $RtoolsDrive + '\Rtools\MinGW\bin;' + $RtoolsDrive + '\Rtools\' + $gccPath + '\bin;' + $env:PATH + $env:BINPREF=$RtoolsDrive + '/Rtools/mingw_$(WIN)/bin/' +} + +# create tools directory outside of Spark directory +$up = (Get-Item -Path ".." -Verbose).FullName +$tools = "$up\tools" +if (!(Test-Path $tools)) { + New-Item -ItemType Directory -Force -Path $tools | Out-Null +} + +# ========================== Maven +Push-Location $tools + +$mavenVer = "3.3.9" +Start-FileDownload "https://archive.apache.org/dist/maven/maven-3/$mavenVer/binaries/apache-maven-$mavenVer-bin.zip" "maven.zip" + +# extract +Invoke-Expression "7z.exe x maven.zip" + +# add maven to environment variables +$env:Path += ";$tools\apache-maven-$mavenVer\bin" +$env:M2_HOME = "$tools\apache-maven-$mavenVer" +$env:MAVEN_OPTS = "-Xmx2g -XX:MaxPermSize=512M -XX:ReservedCodeCacheSize=512m" + +Pop-Location + +# ========================== Hadoop bin package +$hadoopVer = "2.6.0" +$hadoopPath = "$tools\hadoop" +if (!(Test-Path $hadoopPath)) { + New-Item -ItemType Directory -Force -Path $hadoopPath | Out-Null +} +Push-Location $hadoopPath + +Start-FileDownload "https://github.com/steveloughran/winutils/archive/master.zip" "winutils-master.zip" + +# extract +Invoke-Expression "7z.exe x winutils-master.zip" + +# add hadoop bin to environment variables +$env:HADOOP_HOME = "$hadoopPath/winutils-master/hadoop-$hadoopVer" + +Pop-Location + +# ========================== R +$rVer = "3.3.1" +$rToolsVer = "3.4.0" + +InstallR +InstallRtools + +$env:R_LIBS_USER = 'c:\RLibrary' +if ( -not(Test-Path $env:R_LIBS_USER) ) { + mkdir $env:R_LIBS_USER +} + -- cgit v1.2.3