mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
Update CI with testing framework from eigen_ci_cross_testing.
This commit is contained in:
committed by
Rasmus Munk Larsen
parent
b2814d53a7
commit
34fd46a9b4
31
ci/scripts/build.linux.script.sh
Normal file
31
ci/scripts/build.linux.script.sh
Normal file
@@ -0,0 +1,31 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -x
|
||||
|
||||
# Create and enter build directory.
|
||||
rootdir=`pwd`
|
||||
mkdir -p ${EIGEN_CI_BUILDDIR}
|
||||
cd ${EIGEN_CI_BUILDDIR}
|
||||
|
||||
# Configure build.
|
||||
cmake -G Ninja \
|
||||
-DCMAKE_CXX_COMPILER=${EIGEN_CI_CXX_COMPILER} \
|
||||
-DCMAKE_C_COMPILER=${EIGEN_CI_C_COMPILER} \
|
||||
-DCMAKE_CXX_COMPILER_TARGET=${EIGEN_CI_CXX_COMPILER_TARGET} \
|
||||
${EIGEN_CI_ADDITIONAL_ARGS} ${rootdir}
|
||||
|
||||
target=""
|
||||
if [[ ${EIGEN_CI_BUILD_TARGET} ]]; then
|
||||
target="--target ${EIGEN_CI_BUILD_TARGET}"
|
||||
fi
|
||||
|
||||
# Builds (particularly gcc) sometimes get killed, potentially when running
|
||||
# out of resources. In that case, keep trying to build the remaining
|
||||
# targets (k0), then try to build again with a single thread (j1) to minimize
|
||||
# resource use.
|
||||
cmake --build . ${target} -- -k0 || cmake --build . ${target} -- -k0 -j1
|
||||
|
||||
# Return to root directory.
|
||||
cd ${rootdir}
|
||||
|
||||
set +x
|
||||
42
ci/scripts/build.windows.script.ps1
Normal file
42
ci/scripts/build.windows.script.ps1
Normal file
@@ -0,0 +1,42 @@
|
||||
# Find Visual Studio installation directory.
|
||||
$VS_INSTALL_DIR = &"${Env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -latest -property installationPath
|
||||
|
||||
# Run VCVarsAll.bat initialization script and extract environment variables.
|
||||
# http://allen-mack.blogspot.com/2008/03/replace-visual-studio-command-prompt.html
|
||||
cmd.exe /c "`"${VS_INSTALL_DIR}\VC\Auxiliary\Build\vcvarsall.bat`" $EIGEN_CI_MSVC_ARCH -vcvars_ver=$EIGEN_CI_MSVC_VER & set" |
|
||||
foreach {
|
||||
if ($_ -match "=") {
|
||||
$v = $_.split("="); set-item -force -path "ENV:\$($v[0])" -value "$($v[1])"
|
||||
}
|
||||
}
|
||||
|
||||
# Create and enter build directory.
|
||||
$rootdir = Get-Location
|
||||
mkdir $EIGEN_CI_BUILDDIR
|
||||
cd $EIGEN_CI_BUILDDIR
|
||||
|
||||
# We need to split EIGEN_CI_ADDITIONAL_ARGS, otherwise they are interpretted
|
||||
# as a single argument. Split by space, unless double-quoted.
|
||||
$split_args = [regex]::Split(${EIGEN_CI_ADDITIONAL_ARGS}, ' (?=(?:[^"]|"[^"]*")*$)' )
|
||||
|
||||
# Configure build.
|
||||
cmake -G Ninja -DCMAKE_BUILD_TYPE=MinSizeRel `
|
||||
-DEIGEN_TEST_CUSTOM_CXX_FLAGS="${EIGEN_CI_TEST_CUSTOM_CXX_FLAGS}" `
|
||||
${split_args} "${rootdir}"
|
||||
|
||||
$target = ""
|
||||
if (${EIGEN_CI_BUILD_TARGET}) {
|
||||
$target = "--target ${EIGEN_CI_BUILD_TARGET}"
|
||||
}
|
||||
|
||||
# Windows builds sometimes fail due heap errors. In that case, try
|
||||
# building the rest, then try to build again with a single thread.
|
||||
cmake --build . ${target} -- -k0 || cmake --build . ${target} -- -k0 -j1
|
||||
|
||||
$success = $LASTEXITCODE
|
||||
|
||||
# Return to root directory.
|
||||
cd ${rootdir}
|
||||
|
||||
# Explicitly propagate exit code to indicate pass/failure of build command.
|
||||
if($success -ne 0) { Exit $success }
|
||||
48
ci/scripts/common.linux.before_script.sh
Normal file
48
ci/scripts/common.linux.before_script.sh
Normal file
@@ -0,0 +1,48 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -x
|
||||
|
||||
echo "Running ${CI_JOB_NAME}"
|
||||
|
||||
# Get architecture and display CI configuration.
|
||||
export ARCH=`uname -m`
|
||||
export NPROC=`nproc`
|
||||
echo "arch=$ARCH, target=${EIGEN_CI_TARGET_ARCH}"
|
||||
echo "Processors: ${NPROC}"
|
||||
echo "CI Variables:"
|
||||
export | grep EIGEN
|
||||
|
||||
# Set noninteractive, otherwise tzdata may be installed and prompt for a
|
||||
# geographical region.
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
apt-get update -y > /dev/null
|
||||
apt-get install -y --no-install-recommends software-properties-common ninja-build cmake git > /dev/null
|
||||
add-apt-repository -y ppa:ubuntu-toolchain-r/test > /dev/null
|
||||
apt-get update -y > /dev/null
|
||||
|
||||
# Install required dependencies and set up compilers.
|
||||
# These are required even for testing to ensure that dynamic runtime libraries
|
||||
# are available.
|
||||
if [[ "$ARCH" == "${EIGEN_CI_TARGET_ARCH}" ]]; then
|
||||
apt-get install -y --no-install-recommends ${EIGEN_CI_INSTALL} > /dev/null;
|
||||
export EIGEN_CI_CXX_IMPLICIT_INCLUDE_DIRECTORIES="";
|
||||
export EIGEN_CI_CXX_COMPILER_TARGET="";
|
||||
else
|
||||
apt-get install -y --no-install-recommends ${EIGEN_CI_CROSS_INSTALL} > /dev/null;
|
||||
export EIGEN_CI_C_COMPILER=${EIGEN_CI_CROSS_C_COMPILER};
|
||||
export EIGEN_CI_CXX_COMPILER=${EIGEN_CI_CROSS_CXX_COMPILER};
|
||||
export EIGEN_CI_CXX_COMPILER_TARGET=${EIGEN_CI_CROSS_TARGET_TRIPLE};
|
||||
# Tell the compiler where to find headers and libraries if using clang.
|
||||
# NOTE: this breaks GCC since it messes with include path order
|
||||
# (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70129)
|
||||
if [[ "${EIGEN_CI_CROSS_CXX_COMPILER}" == *"clang"* ]]; then
|
||||
export CPLUS_INCLUDE_PATH="/usr/${EIGEN_CI_CROSS_TARGET_TRIPLE}/include";
|
||||
export LIBRARY_PATH="/usr/${EIGEN_CI_CROSS_TARGET_TRIPLE}/lib64";
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "Compilers: ${EIGEN_CI_C_COMPILER} ${EIGEN_CI_CXX_COMPILER}"
|
||||
|
||||
if [ -n "$EIGEN_CI_BEFORE_SCRIPT" ]; then eval "$EIGEN_CI_BEFORE_SCRIPT"; fi
|
||||
|
||||
set +x
|
||||
7
ci/scripts/common.windows.before_script.ps1
Normal file
7
ci/scripts/common.windows.before_script.ps1
Normal file
@@ -0,0 +1,7 @@
|
||||
echo "Running ${CI_JOB_NAME}"
|
||||
|
||||
# Print configuration variables.
|
||||
Get-Variable | findstr EIGEN
|
||||
|
||||
# Run a custom before-script command.
|
||||
if ("${EIGEN_CI_BEFORE_SCRIPT}") { Invoke-Expression -Command "${EIGEN_CI_BEFORE_SCRIPT}" }
|
||||
19
ci/scripts/test.linux.after_script.sh
Normal file
19
ci/scripts/test.linux.after_script.sh
Normal file
@@ -0,0 +1,19 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -x
|
||||
|
||||
# Enter build directory.
|
||||
rootdir=`pwd`
|
||||
cd ${EIGEN_CI_BUILDDIR}
|
||||
|
||||
# Install xml processor.
|
||||
apt-get update -y
|
||||
apt-get install --no-install-recommends -y xsltproc
|
||||
|
||||
# Generate test results.
|
||||
xsltproc ${rootdir}/ci/CTest2JUnit.xsl Testing/`head -n 1 < Testing/TAG`/Test.xml > "JUnitTestResults_$CI_JOB_ID.xml"
|
||||
|
||||
# Return to root directory.
|
||||
cd ${rootdir}
|
||||
|
||||
set +x
|
||||
28
ci/scripts/test.linux.script.sh
Normal file
28
ci/scripts/test.linux.script.sh
Normal file
@@ -0,0 +1,28 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -x
|
||||
|
||||
# Enter build directory.
|
||||
rootdir=`pwd`
|
||||
cd ${EIGEN_CI_BUILDDIR}
|
||||
|
||||
target=""
|
||||
if [[ ${EIGEN_CI_TEST_REGEX} ]]; then
|
||||
target="-R ${EIGEN_CI_TEST_REGEX}"
|
||||
elif [[ ${EIGEN_CI_TEST_LABEL} ]]; then
|
||||
target="-L ${EIGEN_CI_TEST_LABEL}"
|
||||
fi
|
||||
|
||||
# Repeat tests up to three times to ignore flakes. Do not re-run with -T test,
|
||||
# otherwise we lose test results for those that passed.
|
||||
# Note: starting with CMake 3.17, we can use --repeat until-pass:3, but we have
|
||||
# no way of easily installing this on ppc64le.
|
||||
ctest --parallel ${NPROC} --output-on-failure --no-compress-output \
|
||||
--build-no-clean -T test ${target} || \
|
||||
ctest -j${NPROC} --output-on-failure --no-compress-output --rerun-failed || \
|
||||
ctest -j${NPROC} --output-on-failure --no-compress-output --rerun-failed
|
||||
|
||||
# Return to root directory.
|
||||
cd ${rootdir}
|
||||
|
||||
set +x
|
||||
17
ci/scripts/test.windows.after_script.ps1
Normal file
17
ci/scripts/test.windows.after_script.ps1
Normal file
@@ -0,0 +1,17 @@
|
||||
# Change to build directory.
|
||||
$rootdir = Get-Location
|
||||
cd ${EIGEN_CI_BUILDDIR}
|
||||
|
||||
# Determine the appropriate test tag and results file.
|
||||
$TEST_TAG = Get-Content Testing\TAG | select -first 1
|
||||
|
||||
# PowerShell equivalent to xsltproc:
|
||||
$XSL_FILE = Resolve-Path "..\ci\CTest2JUnit.xsl"
|
||||
$INPUT_FILE = Resolve-Path Testing\$TEST_TAG\Test.xml
|
||||
$OUTPUT_FILE = Join-Path -Path $pwd -ChildPath JUnitTestResults_$CI_JOB_ID.xml
|
||||
$xslt = New-Object System.Xml.Xsl.XslCompiledTransform;
|
||||
$xslt.Load($XSL_FILE)
|
||||
$xslt.Transform($INPUT_FILE,$OUTPUT_FILE)
|
||||
|
||||
# Return to root directory.
|
||||
cd ${rootdir}
|
||||
30
ci/scripts/test.windows.script.ps1
Normal file
30
ci/scripts/test.windows.script.ps1
Normal file
@@ -0,0 +1,30 @@
|
||||
# Change to build directory.
|
||||
$rootdir = Get-Location
|
||||
cd $EIGEN_CI_BUILDDIR
|
||||
|
||||
# Determine number of processors for parallel tests.
|
||||
$NPROC=${Env:NUMBER_OF_PROCESSORS}
|
||||
|
||||
# Set target based on regex or label.
|
||||
$target = ""
|
||||
if (${EIGEN_CI_TEST_REGEX}) {
|
||||
$target = "-R","${EIGEN_CI_TEST_REGEX}"
|
||||
} elseif (${EIGEN_CI_TEST_LABEL}) {
|
||||
$target = "-L","${EIGEN_CI_TEST_LABEL}"
|
||||
}
|
||||
|
||||
# Repeat tests up to three times to ignore flakes. Do not re-run with -T test,
|
||||
# otherwise we lose test results for those that passed.
|
||||
# Note: starting with CMake 3.17, we can use --repeat until-pass:3, but we have
|
||||
# no way of easily installing this on ppc64le.
|
||||
ctest -j$NPROC --output-on-failure --no-compress-output --build-no-clean -T test $target || `
|
||||
ctest -j$NPROC --output-on-failure --no-compress-output --rerun-failed || `
|
||||
ctest -j$NPROC --output-on-failure --no-compress-output --rerun-failed
|
||||
|
||||
$success = $LASTEXITCODE
|
||||
|
||||
# Return to root directory.
|
||||
cd ${rootdir}
|
||||
|
||||
# Explicitly propagate exit code to indicate pass/failure of test command.
|
||||
if($success -ne 0) { Exit $success }
|
||||
12
ci/scripts/vars.linux.sh
Normal file
12
ci/scripts/vars.linux.sh
Normal file
@@ -0,0 +1,12 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Initialize default variables used by the CI.
|
||||
export EIGEN_CI_ADDITIONAL_ARGS=""
|
||||
export EIGEN_CI_BEFORE_SCRIPT=""
|
||||
export EIGEN_CI_BUILD_TARGET="buildtests"
|
||||
export EIGEN_CI_BUILDDIR=".build"
|
||||
export EIGEN_CI_C_COMPILER="clang"
|
||||
export EIGEN_CI_CXX_COMPILER="clang++"
|
||||
export EIGEN_CI_TEST_CUSTOM_CXX_FLAGS=""
|
||||
export EIGEN_CI_TEST_LABEL="Official"
|
||||
export EIGEN_CI_TEST_REGEX=""
|
||||
10
ci/scripts/vars.windows.ps1
Normal file
10
ci/scripts/vars.windows.ps1
Normal file
@@ -0,0 +1,10 @@
|
||||
# Initialize default variables used by the CI.
|
||||
$EIGEN_CI_ADDITIONAL_ARGS = ""
|
||||
$EIGEN_CI_BEFORE_SCRIPT = ""
|
||||
$EIGEN_CI_BUILD_TARGET = "buildtests"
|
||||
$EIGEN_CI_BUILDDIR = ".build"
|
||||
$EIGEN_CI_MSVC_ARCH = "x64"
|
||||
$EIGEN_CI_MSVC_VER = "14.29"
|
||||
$EIGEN_CI_TEST_CUSTOM_CXX_FLAGS = "/d2ReducedOptimizeHugeFunctions /DEIGEN_STRONG_INLINE=inline /Os"
|
||||
$EIGEN_CI_TEST_LABEL = "Official"
|
||||
$EIGEN_CI_TEST_REGEX = ""
|
||||
Reference in New Issue
Block a user