From 06561ac143c864b59b9ecc2268137f49bd749497 Mon Sep 17 00:00:00 2001 From: /dev/urandom Date: Thu, 15 Sep 2016 08:25:12 +0200 Subject: [PATCH] Jenkinsfile: Attempt on unit testing on Linux. --- Jenkinsfile | 59 ++++++++++++++++++++++++++++----------- jenkins/wine32.Dockerfile | 37 ++++++++++++++++++++++++ 2 files changed, 79 insertions(+), 17 deletions(-) create mode 100644 jenkins/wine32.Dockerfile diff --git a/Jenkinsfile b/Jenkinsfile index c386bf10..fe4c178b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -84,19 +84,29 @@ def doBuild(name, wsid, premakeFlags, configuration) { // This will run the unit tests for IW4x. // We need a Windows Server with MW2 on it. -def doUnitTests(name, wsid) { - node("windows") { - ws("IW4x/testing/$wsid") { - mw2dir = tool "Modern Warfare 2" +def doUnitTests(label, name, wsid) { + ws("IW4x/testing/$wsid") { + mw2dir = tool "Modern Warfare 2" - unstash "$name" + unstash "$name" - // Get installed localization for correct zonefiles directory junction - def localization = readFile("$mw2dir\\localization.txt").split("\r?\n")[0] + // Get installed localization for correct zonefiles directory junction + def localization = readFile("$mw2dir/localization.txt").split("\r?\n")[0] - try { - timeout(time: 180, unit: "MINUTES") { - // Set up environment + try { + timeout(time: 180, unit: "MINUTES") { + // Set up environment + if (isUnix()) { + sh """ + mkdir -p zone + for f in main zone/dlc \"zone/$localization\"; do + ln -sfv \"$mw2dir/\$f\" \"\$f\" + done + for f in \"$mw2dir\"/*.dll \"$mw2dir\"/*.txt \"$mw2dir\"/*.bmp; do + ln -sfv \"\$f\" \"\$(basename \"\$f\")\" + done + """ + } else { bat """ mklink /J \"main\" \"$mw2dir\\main\" mkdir \"zone\" @@ -106,20 +116,26 @@ def doUnitTests(name, wsid) { copy /y \"$mw2dir\\*.txt\" copy /y \"$mw2dir\\*.bmp\" """ + } - // Run tests - getIW4xExecutable() + // Run tests + getIW4xExecutable() + if (isUnix()) { + sh "wine-wrapper iw4x.exe -tests" + } else { bat "iw4x.exe -tests" } - } finally { - // In all cases make sure to at least remove the directory junctions! + } + } finally { + // In all cases make sure to at least remove the directory junctions! + if (!isUnix()) { bat """ rmdir \"main\" rmdir \"zone\\dlc\" rmdir \"zone\\$localization\" """ - deleteDir() } + deleteDir() } } } @@ -170,8 +186,17 @@ gitlabBuilds(builds: ["Checkout & Versioning", "Build", "Testing", "Archiving"]) for (int i = 0; i < configurations.size(); i++) { def configuration = configurations[i] - executions["$configuration"] = { - doUnitTests("IW4x $configuration (unit tests)", configuration) + executions["$configuration on Windows"] = { + node("windows") { + doUnitTests("IW4x $configuration (unit tests)", configuration) + } + } + executions["$configuration on Linux"] = { + node("docker && linux && amd64") { + docker.build("", "--rm --force-rm -f jenkins/wine32.Dockerfile").inside { + doUnitTests("IW4x $configuration (unit tests)", configuration) + } + } } } parallel executions diff --git a/jenkins/wine32.Dockerfile b/jenkins/wine32.Dockerfile new file mode 100644 index 00000000..1061c8e5 --- /dev/null +++ b/jenkins/wine32.Dockerfile @@ -0,0 +1,37 @@ +# Requires a decent modern Docker version (v1.10.x at least ideally) + +# Use semi-official Arch Linux image with fixed versioning +FROM pritunl/archlinux:2016-09-10 + +# Environment variables +ENV WINEPREFIX /wine32 +ENV WINEARCH win32 +ENV WINEDEBUG -all + +# Install Wine (32-bit) +RUN \ + echo -e "#!/bin/sh\nwine \$@\nretval=\$?\ntail --pid=\$(pidof wineserver 2>/dev/null||echo 0) -f /dev/null\nexit \$retval" > /usr/local/bin/wine-wrapper &&\ + chmod +x /usr/local/bin/wine-wrapper &&\ +\ + (\ + echo '' &&\ + echo '[multilib]' &&\ + echo 'Include = /etc/pacman.d/mirrorlist'\ + ) >> /etc/pacman.conf &&\ + pacman -Sy --noconfirm wine wget xorg-server-xvfb &&\ +\ + wine-wrapper wineboot.exe -i &&\ + wget -Ovcredist_x86.exe https://download.microsoft.com/download/d/d/9/dd9a82d0-52ef-40db-8dab-795376989c03/vcredist_x86.exe &&\ + xvfb-run sh -c 'wine-wrapper vcredist_x86.exe /q' &&\ + rm vcredist_x86.exe &&\ +\ + pacman -Rs --noconfirm xorg-server-xvfb wget &&\ +\ + find /. -name "*~" -type f -delete &&\ + rm -rf /tmp/* /var/tmp/* /usr/share/man/* /usr/share/info/* /usr/share/doc/* &&\ + pacman -Scc --noconfirm &&\ + paccache -rk0 &&\ + pacman-optimize &&\ + rm -rf /var/lib/pacman/sync/* + +USER 0