Commit 0221960c authored by Dominik Charousset's avatar Dominik Charousset

Port build pipeline to latest CAF CI scaffold

parent 546ea7b1
#!/bin/sh
set -x
set -e
# This script expects the CAF source tree under 'sources', builds in 'build' and
# installs to 'bundle'. Additionally, the script expects the CMake pre-load
# script 'cmake-init.txt' in the current working directorys.
BaseDir="$PWD"
InitFile="$PWD/cmake-init.txt"
SourceDir="$PWD/sources"
BuildDir="$PWD/build"
cat "$InitFile"
# Prefer cmake3 over "regular" cmake (cmake == cmake2 on RHEL).
if command -v cmake3 >/dev/null 2>&1 ; then
CMakeCommand="cmake3"
CTestCommand="ctest3"
elif command -v cmake >/dev/null 2>&1 ; then
CMakeCommand="cmake"
CTestCommand="ctest"
else
echo "No CMake found."
exit 1
fi
LeakSanCheck="
#include <cstdlib>
int main() {
int* ptr = new int(EXIT_SUCCESS);
return *ptr;
}
"
# Check that LeakSanitizer works if configured for this build.
if [ "${CAF_CHECK_LEAKS}" == "ON" ]; then
mkdir -p "$BaseDir/LeakCheck"
cd "$BaseDir/LeakCheck"
echo "${LeakSanCheck}" > check.cpp
c++ check.cpp -o check -fsanitize=address -fno-omit-frame-pointer
out=`./check 2>&1 | grep -o LeakSanitizer`
if [ "$out" != "LeakSanitizer" ]; then
echo "unable to detected memory leaks on this platform!"
return 1
fi
cd "$BaseDir"
fi
# Make sure all directories exist, then enter build directory.
mkdir -p "$BuildDir"
cd "$BuildDir"
# Run CMake and CTest.
$CMakeCommand -C "$InitFile" "$SourceDir"
if [ -z "$CAF_NUM_CORES" ]; then
$CMakeCommand --build . --target install
else
$CMakeCommand --build . --target install -- -j $CAF_NUM_CORES
fi
$CTestCommand --output-on-failure
#!/bin/sh
WorkingDir="$PWD"
UsageString="
$0 build CMAKE_INIT_FILE SOURCE_DIR BUILD_DIR
OR $0 test BUILD_DIR
OR $0 assert WHAT
"
usage() {
echo "$UsageString"
exit 1
}
set -e
if [ $# = 4 ]; then
if [ "$1" = 'build' ] && [ -f "$2" ] && [ -d "$3" ]; then
Mode='build'
InitFile="$2"
SourceDir="$3"
BuildDir="$4"
mkdir -p "$BuildDir"
else
usage
fi
elif [ $# = 2 ]; then
if [ "$1" = 'test' ] && [ -d "$2" ]; then
Mode='test'
BuildDir="$2"
elif [ "$1" = 'assert' ] && [ "$2" = 'LeakSanitizer' ]; then
Mode='assert'
else
usage
fi
else
usage
fi
set -x
# Prefer cmake3 over "regular" cmake (cmake == cmake2 on RHEL).
if command -v cmake3 >/dev/null 2>&1 ; then
CMakeCommand="cmake3"
CTestCommand="ctest3"
elif command -v cmake >/dev/null 2>&1 ; then
CMakeCommand="cmake"
CTestCommand="ctest"
else
echo "No CMake found."
exit 1
fi
runBuild() {
cat "$InitFile"
cd "$BuildDir"
$CMakeCommand -C "$InitFile" "$SourceDir"
if [ -z "$CAF_NUM_CORES" ]; then
$CMakeCommand --build . --target install
else
$CMakeCommand --build . --target install -- -j $CAF_NUM_CORES
fi
cd "$WorkingDir"
}
runTest() {
cd "$BuildDir"
$CTestCommand --output-on-failure
cd "$WorkingDir"
}
runLeakSanitizerCheck() {
LeakSanCheckStr="
int main() {
int* ptr = new int(0);
return *ptr;
}
"
echo "${LeakSanCheckStr}" > LeakSanCheck.cpp
c++ LeakSanCheck.cpp -o LeakSanCheck -fsanitize=address -fno-omit-frame-pointer
out=`./LeakSanCheck 2>&1 | grep -o 'detected memory leaks'`
if [ -z "$out" ]; then
echo "unable to detected memory leaks on this platform!"
return 1
fi
}
if [ "$Mode" = 'build' ]; then
runBuild
elif [ "$Mode" = 'test' ]; then
runTest
else
runLeakSanitizerCheck
fi
......@@ -47,8 +47,10 @@ set(CAF_LOG_LEVEL "QUIET" CACHE STRING "Set log verbosity of CAF components")
set(CAF_SANITIZERS "" CACHE STRING
"Comma separated sanitizers, e.g., 'address,undefined'")
set(CAF_INSTALL_CMAKEDIR
"${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/cmake/CAF" CACHE STRING
"${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/cmake/CAF" CACHE PATH
"Path for installing CMake files, enables 'find_package(CAF)'")
set(CAF_BUILD_INFO_FILE_PATH "" CACHE FILEPATH
"Optional path for writing CMake and compiler version information")
# -- macOS-specific options ----------------------------------------------------
......@@ -370,3 +372,11 @@ install(
"${CMAKE_CURRENT_BINARY_DIR}/CAFConfigVersion.cmake"
DESTINATION
"${CAF_INSTALL_CMAKEDIR}")
# -- extra file output (primarily for CAF CI) ----------------------------------
if(CAF_BUILD_INFO_FILE_PATH)
configure_file("${PROJECT_SOURCE_DIR}/cmake/caf-build-info.txt.in"
"${CAF_BUILD_INFO_FILE_PATH}"
@ONLY)
endif()
......@@ -2,19 +2,10 @@
@Library('caf-continuous-integration') _
// Default CMake flags for release builds.
defaultReleaseBuildFlags = [
'CAF_ENABLE_RUNTIME_CHECKS:BOOL=ON',
'CAF_ENABLE_ACTOR_PROFILER:BOOL=ON',
]
// Default CMake flags for debug builds.
defaultDebugBuildFlags = defaultReleaseBuildFlags + [
'CAF_LOG_LEVEL:STRING=TRACE',
]
// Configures the behavior of our stages.
config = [
// Version dependency for the caf-continuous-integration library.
ciLibVersion: 1.0,
// GitHub path to repository.
repository: 'actor-framework/actor-framework',
// List of enabled checks for email notifications.
......@@ -24,71 +15,90 @@ config = [
'tests',
// 'coverage', TODO: fix kcov setup
],
// Default CMake flags by build type.
buildFlags: [
'CAF_ENABLE_RUNTIME_CHECKS:BOOL=ON',
'CAF_ENABLE_ACTOR_PROFILER:BOOL=ON',
],
extraDebugFlags: [
'CAF_LOG_LEVEL:STRING=TRACE',
],
// Our build matrix. Keys are the operating system labels and values are build configurations.
buildMatrix: [
// Various Linux builds for debug and release.
// Various Linux builds.
['centos-7', [
numCores: 4,
tags: ['docker'],
builds: ['debug', 'release'],
builds: ['release'],
]],
['centos-8', [
numCores: 4,
tags: ['docker'],
builds: ['debug', 'release'],
builds: ['release'],
]],
['debian-9', [
numCores: 4,
tags: ['docker'],
builds: ['debug', 'release'],
builds: ['release'],
]],
['debian-10', [
numCores: 4,
tags: ['docker'],
builds: ['debug', 'release'],
builds: ['release'],
]],
['ubuntu-16.04', [
numCores: 4,
tags: ['docker'],
builds: ['debug', 'release'],
builds: ['release'],
]],
['ubuntu-18.04', [
numCores: 4,
tags: ['docker'],
builds: ['debug', 'release'],
builds: ['release'],
]],
['ubuntu-20.04', [
numCores: 4,
tags: ['docker'],
builds: ['debug', 'release'],
builds: ['release'],
]],
['fedora-31', [
numCores: 4,
tags: ['docker'],
builds: ['debug', 'release'],
builds: ['release'],
]],
['fedora-32', [
numCores: 4,
tags: ['docker'],
builds: ['debug', 'release'],
extraDebugFlags: ['CAF_SANITIZERS:STRING=address'],
builds: ['release'],
]],
// One extra debug build with exceptions disabled.
['centos-7', [
numCores: 4,
tags: ['docker'],
builds: ['debug'],
extraDebugFlags: [
extraBuildFlags: [
'CAF_ENABLE_EXCEPTIONS:BOOL=OFF',
'CMAKE_CXX_FLAGS:STRING=-fno-exceptions',
],
]],
// One extra debug build for leak checking.
['fedora-32', [
numCores: 4,
tags: ['docker', 'LeakSanitizer'],
builds: ['debug'],
extraBuildFlags: [
'CAF_SANITIZERS:STRING=address',
],
extraBuildEnv: [
'ASAN_OPTIONS=detect_leaks=1',
],
]],
// One extra debug build with static libraries.
['debian-10', [
numCores: 4,
tags: ['docker'],
builds: ['debug', 'release'],
extraDebugFlags: [
builds: ['debug'],
extraBuildFlags: [
'BUILD_SHARED_LIBS:BOOL=OFF',
],
]],
......@@ -96,16 +106,20 @@ config = [
['macOS', [
numCores: 4,
builds: ['debug', 'release'],
extraFlags: [
'OPENSSL_ROOT_DIR=/usr/local/opt/openssl',
'OPENSSL_INCLUDE_DIR=/usr/local/opt/openssl/include',
extraBuildFlags: [
'OPENSSL_ROOT_DIR:PATH=/usr/local/opt/openssl',
'OPENSSL_INCLUDE_DIR:PATH=/usr/local/opt/openssl/include',
],
extraDebugBuildFlags: [
'CAF_SANITIZERS:STRING=address',
],
extraDebugFlags: ['CAF_SANITIZERS:STRING=address,undefined'],
]],
['FreeBSD', [
numCores: 4,
builds: ['debug', 'release'],
extraDebugFlags: ['CAF_SANITIZERS:STRING=address,undefined'],
extraBuildFlags: [
'CAF_SANITIZERS:STRING=address',
],
]],
// Non-UNIX systems.
['Windows', [
......@@ -113,45 +127,10 @@ config = [
// TODO: debug build currently broken
//builds: ['debug', 'release'],
builds: ['release'],
extraFlags: ['CAF_ENABLE_OPENSSL_MODULE:BOOL=OFF'],
]],
],
// Platform-specific environment settings.
buildEnvironments: [
'fedora-32 && debug': [
'CAF_CHECK_LEAKS=ON',
'ASAN_OPTIONS=detect_leaks=1',
],
nop: [], // Dummy value for getting the proper types.
],
// Default CMake flags by build type.
defaultBuildFlags: [
debug: defaultDebugBuildFlags,
release: defaultReleaseBuildFlags,
],
// CMake flags by OS and build type to override defaults for individual builds.
buildFlags: [
nop: [],
],
// Default CMake flags by build type.
defaultBuildFlags: [
debug: defaultDebugBuildFlags,
release: defaultReleaseBuildFlags,
],
// Configures what binary the coverage report uses and what paths to exclude.
coverage: [
binaries: [
'build/libcaf_core/caf-core-test',
'build/libcaf_io/caf-io-test',
],
relativeExcludePaths: [
'examples',
'tools',
'libcaf_test',
'libcaf_core/test',
'libcaf_io/test',
'libcaf_openssl/test',
extraBuildFlags: [
'CAF_ENABLE_OPENSSL_MODULE:BOOL=OFF'
],
]],
],
]
......@@ -167,7 +146,6 @@ pipeline {
environment {
PrettyJobBaseName = env.JOB_BASE_NAME.replace('%2F', '/')
PrettyJobName = "CAF/$PrettyJobBaseName #${env.BUILD_NUMBER}"
ASAN_OPTIONS = 'detect_leaks=1'
}
stages {
stage('Checkout') {
......@@ -203,7 +181,7 @@ pipeline {
}
stage('Build') {
steps {
buildParallel(config, PrettyJobBaseName)
buildParallel(config)
}
}
stage('Notify') {
......
Compiler: @CMAKE_CXX_COMPILER_ID@ @CMAKE_CXX_COMPILER_VERSION@
CMake: @CMAKE_VERSION@
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment