[Linux/x86] Enable CI Linux/x86 build job
authorHyeongseok Oh <hseok82.oh@samsung.com>
Fri, 10 Mar 2017 01:17:56 +0000 (10:17 +0900)
committerHyeongseok Oh <hseok82.oh@samsung.com>
Fri, 10 Mar 2017 08:06:12 +0000 (17:06 +0900)
Make new CI job: Linux/x86 build (debug, checked, release)
- Triggered on-demand
- Docker for crossbuild
- Use build-rootfs.sh script to make x86 rootfs

netci.groovy
tests/scripts/x86_ci_script.sh [new file with mode: 0755]

index 4354edc..8e40d05 100755 (executable)
@@ -1068,7 +1068,13 @@ def static addTriggers(def job, def branch, def isPR, def architecture, def os,
             break
         // editor brace matching: }
         case 'x86': // editor brace matching: {
-            assert (os == 'Windows_NT')
+            assert ((os == 'Windows_NT') || ((os == 'Ubuntu') && (scenario == 'default')))
+            if (os == 'Ubuntu') {
+                // on-demand only for ubuntu x86
+                Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} Build",
+                    "(?i).*test\\W+${os}\\W+${architecture}\\W+${configuration}.*")
+                break
+            }
             switch (scenario) {
                 case 'default':
                     if (configuration == 'Checked') {
@@ -1616,6 +1622,12 @@ def static calculateBuildCommands(def newJob, def scenario, def branch, def isPR
                         arch = 'x86'
                     }
 
+                    if (architecture == 'x86' && os == 'Ubuntu') {
+                        // build only, not test yet
+                        buildCommands += "./tests/scripts/x86_ci_script.sh --buildConfig=${lowerConfiguration}"
+                        break;
+                    }
+
                     if (scenario == 'formatting') {
                         buildCommands += "python tests/scripts/format.py -c \${WORKSPACE} -o Linux -a ${arch}"
                         Utilities.addArchival(newJob, "format.patch", "", true, false)
@@ -1798,6 +1810,10 @@ combinedScenarios.each { scenario ->
                             }
                             break
                         case 'x86':
+                            if ((os != 'Ubuntu') && (os != 'Windows_NT')) {
+                                return
+                            }
+                            break
                         case 'x86compatjit':
                             // Skip non-windows
                             if (os != 'Windows_NT') {
@@ -1838,7 +1854,11 @@ combinedScenarios.each { scenario ->
                                 break
                             case 'x64':
                             case 'x86':
-                                // Everything implemented
+                                // x86 ubuntu: default only
+                                if ((os == 'Ubuntu') && (architecture == 'x86')) {
+                                    return
+                                }
+                                // Windows: Everything implemented
                                 break
                             case 'x86compatjit':
                                 // No stress modes for compatjit.dll.
diff --git a/tests/scripts/x86_ci_script.sh b/tests/scripts/x86_ci_script.sh
new file mode 100755 (executable)
index 0000000..ad730a3
--- /dev/null
@@ -0,0 +1,57 @@
+#!/bin/bash
+
+#Parse command line arguments
+__buildConfig=
+for arg in "$@"
+do
+    case $arg in
+    --buildConfig=*)
+        __buildConfig="$(echo ${arg#*=} | awk '{print tolower($0)}')"
+        if [[ "$__buildConfig" != "debug" && "$__buildConfig" != "release" && "$__buildConfig" != "checked" ]]; then
+            exit_with_error "--buildConfig can be only Debug or Release" true
+        fi
+        ;;
+    *)
+        ;;
+    esac
+done
+
+#Check if there are any uncommited changes in the source directory as git adds and removes patches
+if [[ $(git status -s) != "" ]]; then
+   echo 'ERROR: There are some uncommited changes. To avoid losing these changes commit them and try again.'
+   echo ''
+   git status
+   exit 1
+fi
+
+#Change build configuration to the capitalized form to create build product paths correctly
+if [[ "$__buildConfig" == "release" ]]; then
+    __buildConfig="Release"
+elif [[ "$__buildConfig" == "checked" ]]; then
+    __buildConfig="Checked"
+else
+    __buildConfig="Debug"
+fi
+__buildDirName="$__buildOS.$__buildArch.$__buildConfig"
+
+set -x
+set -e
+
+__currentWorkingDir=`pwd`
+__dockerImage=" microsoft/dotnet-buildtools-prereqs:ubuntu1604_cross_prereqs_v3"
+__dockerCmd="sudo docker run --privileged -i --rm -v $__currentWorkingDir:/opt/code -w /opt/code $__dockerImage"
+
+# make rootfs for x86
+__buildRootfsCmd="./cross/build-rootfs.sh x86 xenial --skipunmount"
+(set +x; echo "Build RootFS for x86 xenial")
+$__dockerCmd $__buildRootfsCmd
+sudo chown -R $(id -u -n) cross/rootfs/
+
+# Begin cross build
+# We cannot build nuget package yet
+__buildCmd="./build.sh x86 cross skiptests skipnuget $__buildConfig"
+$__dockerCmd $__buildCmd
+sudo chown -R $(id -u -n) bin/
+
+
+(set +x; echo 'Build complete')