Jenkinsfile: Attempt on unit testing on Linux.

This commit is contained in:
/dev/urandom 2016-09-15 08:25:12 +02:00
parent c8cf116a78
commit 06561ac143
No known key found for this signature in database
GPG Key ID: 41322B973E0F295E
2 changed files with 79 additions and 17 deletions

59
Jenkinsfile vendored
View File

@ -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

37
jenkins/wine32.Dockerfile Normal file
View File

@ -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