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") ...@@ -47,8 +47,10 @@ set(CAF_LOG_LEVEL "QUIET" CACHE STRING "Set log verbosity of CAF components")
set(CAF_SANITIZERS "" CACHE STRING set(CAF_SANITIZERS "" CACHE STRING
"Comma separated sanitizers, e.g., 'address,undefined'") "Comma separated sanitizers, e.g., 'address,undefined'")
set(CAF_INSTALL_CMAKEDIR 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)'") "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 ---------------------------------------------------- # -- macOS-specific options ----------------------------------------------------
...@@ -370,3 +372,11 @@ install( ...@@ -370,3 +372,11 @@ install(
"${CMAKE_CURRENT_BINARY_DIR}/CAFConfigVersion.cmake" "${CMAKE_CURRENT_BINARY_DIR}/CAFConfigVersion.cmake"
DESTINATION DESTINATION
"${CAF_INSTALL_CMAKEDIR}") "${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 @@ ...@@ -2,19 +2,10 @@
@Library('caf-continuous-integration') _ @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. // Configures the behavior of our stages.
config = [ config = [
// Version dependency for the caf-continuous-integration library.
ciLibVersion: 1.0,
// GitHub path to repository. // GitHub path to repository.
repository: 'actor-framework/actor-framework', repository: 'actor-framework/actor-framework',
// List of enabled checks for email notifications. // List of enabled checks for email notifications.
...@@ -24,71 +15,90 @@ config = [ ...@@ -24,71 +15,90 @@ config = [
'tests', 'tests',
// 'coverage', TODO: fix kcov setup // '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. // Our build matrix. Keys are the operating system labels and values are build configurations.
buildMatrix: [ buildMatrix: [
// Various Linux builds for debug and release. // Various Linux builds.
['centos-7', [ ['centos-7', [
numCores: 4, numCores: 4,
tags: ['docker'], tags: ['docker'],
builds: ['debug', 'release'], builds: ['release'],
]], ]],
['centos-8', [ ['centos-8', [
numCores: 4, numCores: 4,
tags: ['docker'], tags: ['docker'],
builds: ['debug', 'release'], builds: ['release'],
]], ]],
['debian-9', [ ['debian-9', [
numCores: 4, numCores: 4,
tags: ['docker'], tags: ['docker'],
builds: ['debug', 'release'], builds: ['release'],
]], ]],
['debian-10', [ ['debian-10', [
numCores: 4, numCores: 4,
tags: ['docker'], tags: ['docker'],
builds: ['debug', 'release'], builds: ['release'],
]], ]],
['ubuntu-16.04', [ ['ubuntu-16.04', [
numCores: 4, numCores: 4,
tags: ['docker'], tags: ['docker'],
builds: ['debug', 'release'], builds: ['release'],
]], ]],
['ubuntu-18.04', [ ['ubuntu-18.04', [
numCores: 4, numCores: 4,
tags: ['docker'], tags: ['docker'],
builds: ['debug', 'release'], builds: ['release'],
]], ]],
['ubuntu-20.04', [ ['ubuntu-20.04', [
numCores: 4, numCores: 4,
tags: ['docker'], tags: ['docker'],
builds: ['debug', 'release'], builds: ['release'],
]], ]],
['fedora-31', [ ['fedora-31', [
numCores: 4, numCores: 4,
tags: ['docker'], tags: ['docker'],
builds: ['debug', 'release'], builds: ['release'],
]], ]],
['fedora-32', [ ['fedora-32', [
numCores: 4, numCores: 4,
tags: ['docker'], tags: ['docker'],
builds: ['debug', 'release'], builds: ['release'],
extraDebugFlags: ['CAF_SANITIZERS:STRING=address'],
]], ]],
// One extra debug build with exceptions disabled. // One extra debug build with exceptions disabled.
['centos-7', [ ['centos-7', [
numCores: 4, numCores: 4,
tags: ['docker'], tags: ['docker'],
builds: ['debug'], builds: ['debug'],
extraDebugFlags: [ extraBuildFlags: [
'CAF_ENABLE_EXCEPTIONS:BOOL=OFF', 'CAF_ENABLE_EXCEPTIONS:BOOL=OFF',
'CMAKE_CXX_FLAGS:STRING=-fno-exceptions', '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. // One extra debug build with static libraries.
['debian-10', [ ['debian-10', [
numCores: 4, numCores: 4,
tags: ['docker'], tags: ['docker'],
builds: ['debug', 'release'], builds: ['debug'],
extraDebugFlags: [ extraBuildFlags: [
'BUILD_SHARED_LIBS:BOOL=OFF', 'BUILD_SHARED_LIBS:BOOL=OFF',
], ],
]], ]],
...@@ -96,16 +106,20 @@ config = [ ...@@ -96,16 +106,20 @@ config = [
['macOS', [ ['macOS', [
numCores: 4, numCores: 4,
builds: ['debug', 'release'], builds: ['debug', 'release'],
extraFlags: [ extraBuildFlags: [
'OPENSSL_ROOT_DIR=/usr/local/opt/openssl', 'OPENSSL_ROOT_DIR:PATH=/usr/local/opt/openssl',
'OPENSSL_INCLUDE_DIR=/usr/local/opt/openssl/include', 'OPENSSL_INCLUDE_DIR:PATH=/usr/local/opt/openssl/include',
],
extraDebugBuildFlags: [
'CAF_SANITIZERS:STRING=address',
], ],
extraDebugFlags: ['CAF_SANITIZERS:STRING=address,undefined'],
]], ]],
['FreeBSD', [ ['FreeBSD', [
numCores: 4, numCores: 4,
builds: ['debug', 'release'], builds: ['debug', 'release'],
extraDebugFlags: ['CAF_SANITIZERS:STRING=address,undefined'], extraBuildFlags: [
'CAF_SANITIZERS:STRING=address',
],
]], ]],
// Non-UNIX systems. // Non-UNIX systems.
['Windows', [ ['Windows', [
...@@ -113,46 +127,11 @@ config = [ ...@@ -113,46 +127,11 @@ config = [
// TODO: debug build currently broken // TODO: debug build currently broken
//builds: ['debug', 'release'], //builds: ['debug', 'release'],
builds: ['release'], builds: ['release'],
extraFlags: ['CAF_ENABLE_OPENSSL_MODULE:BOOL=OFF'], extraBuildFlags: [
'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',
],
],
] ]
// Declarative pipeline for triggering all stages. // Declarative pipeline for triggering all stages.
...@@ -167,7 +146,6 @@ pipeline { ...@@ -167,7 +146,6 @@ pipeline {
environment { environment {
PrettyJobBaseName = env.JOB_BASE_NAME.replace('%2F', '/') PrettyJobBaseName = env.JOB_BASE_NAME.replace('%2F', '/')
PrettyJobName = "CAF/$PrettyJobBaseName #${env.BUILD_NUMBER}" PrettyJobName = "CAF/$PrettyJobBaseName #${env.BUILD_NUMBER}"
ASAN_OPTIONS = 'detect_leaks=1'
} }
stages { stages {
stage('Checkout') { stage('Checkout') {
...@@ -203,7 +181,7 @@ pipeline { ...@@ -203,7 +181,7 @@ pipeline {
} }
stage('Build') { stage('Build') {
steps { steps {
buildParallel(config, PrettyJobBaseName) buildParallel(config)
} }
} }
stage('Notify') { 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