From 5a4d3c58c71fa4962b6a863b1afbf5de939062f0 Mon Sep 17 00:00:00 2001 From: Dennis Klein Date: Wed, 11 Apr 2018 02:21:16 +0200 Subject: [PATCH] Add CI --- .gitignore | 1 + CMakeLists.txt | 29 ++++++--- CTestConfig.cmake | 9 +++ Dart.sh | 133 ++++++++++++++++++++++++++++++++++++++ Jenkinsfile | 56 ++++++++++++++++ cmake/FairLoggerLib.cmake | 1 - 6 files changed, 220 insertions(+), 9 deletions(-) create mode 100644 .gitignore create mode 100644 CTestConfig.cmake create mode 100755 Dart.sh create mode 100644 Jenkinsfile diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..567609b --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +build/ diff --git a/CMakeLists.txt b/CMakeLists.txt index d20b562..ccd3d87 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,8 +33,8 @@ configure_file(logger/Version.h.in ) add_library(FairLogger SHARED - Logger.cxx - Logger.h + logger/Logger.cxx + logger/Logger.h ) target_include_directories(FairLogger @@ -54,15 +54,19 @@ endif() if(BUILD_TESTING) set(test_targets ${targets} loggerTest) endif() -install( - TARGETS FairLogger ${test_targets} +install(TARGETS + FairLogger + ${test_targets} + EXPORT ${FairLogger_EXPORT_SET} LIBRARY DESTINATION ${FairLogger_INSTALL_LIBDIR} RUNTIME DESTINATION ${FairLogger_INSTALL_BINDIR} ) -install( - FILES logger/Logger.h logger/Version.h +install(FILES + logger/Logger.h + ${CMAKE_BINARY_DIR}/logger/Version.h + DESTINATION ${FairLogger_INSTALL_INCDIR} ) @@ -70,15 +74,24 @@ install_fairlogger_cmake_package() ################################################################################ +# Testing ###################################################################### +if(BUILD_TESTING) + add_test(NAME loggerTest + COMMAND $ + ) +endif() +################################################################################ + + # Summary ###################################################################### message(" ") message(" ${Cyan}COMPONENT BUILT? INFO${CR}") -message(" ${BWhite}library${CR} ${BGreen}YES${CR} (default, always built)") +message(" ${BWhite}library${CR} ${BGreen}YES${CR} (default, always built)") if(BUILD_TESTING) set(testing_summary "${BGreen}YES${CR} (default, disable with ${BMagenta}-DBUILD_TESTING=OFF${CR})") else() set(testing_summary "${BRed} NO${CR} (enable with ${BMagenta}-DBUILD_TESTING=ON${CR})") endif() -message(" ${BWhite}tests${CR} ${testing_summary}") +message(" ${BWhite}tests${CR} ${testing_summary}") message(" ") ################################################################################ diff --git a/CTestConfig.cmake b/CTestConfig.cmake new file mode 100644 index 0000000..5942561 --- /dev/null +++ b/CTestConfig.cmake @@ -0,0 +1,9 @@ +set(CTEST_PROJECT_NAME "FairLogger") +set(CTEST_NIGHTLY_START_TIME "00:00:00 CEST") + +set(CTEST_DROP_METHOD "https") +set(CTEST_DROP_SITE "cdash.gsi.de") +set(CTEST_DROP_LOCATION "/submit.php?project=FairRoot") +set(CTEST_DROP_SITE_CDASH TRUE) + +set(CTEST_TESTING_TIMEOUT 60) diff --git a/Dart.sh b/Dart.sh new file mode 100755 index 0000000..e480b74 --- /dev/null +++ b/Dart.sh @@ -0,0 +1,133 @@ +#!/bin/bash + + +function print_example(){ +echo "##################################################################" +echo "# To set the required parameters as source and the build #" +echo "# directory for ctest, the linux flavour and the SIMPATH #" +echo "# put the export commands below to a separate file which is read #" +echo "# during execution and which is defined on the command line. #" +echo "# Set all parameters according to your needs. #" +echo "# LINUX_FLAVOUR should be set to the distribution you are using #" +echo "# eg Debian, SuSe etc. #" +echo "# An additional varibale NCPU can overwrite the default number #" +echo "# of parallel processes used to compile the project. #" +echo "# This can be usefull if one can use a distributed build system #" +echo "# like icecream. #" +echo "# For example #" +echo "#!/bin/bash #" +echo "export LINUX_FLAVOUR= #" +echo "export FAIRSOFT_VERSION= #" +echo "export SIMPATH= #" +echo "export GIT_BRANCH=< master or dev> #" +echo "export BUILDDIR= #" +echo "export SOURCEDIR= #" +echo "#export NCPU=100 #" +echo "##################################################################" +} + +if [ "$#" -lt "2" ]; then + echo "" + echo "-- Error -- Please start script with two parameters" + echo "-- Error -- The first parameter is the ctest model." + echo "-- Error -- Possible arguments are Nightly, Experimental, " + echo "-- Error -- Continuous or Profile." + echo "-- Error -- The second parameter is the file containg the" + echo "-- Error -- Information about the setup at the client" + echo "-- Error -- installation (see example below)." + echo "" + print_example + exit 1 +fi + +# test if a valid ctest model is defined +if [ "$1" == "Experimental" -o "$1" == "Nightly" -o "$1" == "Continuous" -o "$1" == "Profile" -o "$1" == "alfa_ci" ]; then + echo "" +else + echo "-- Error -- This ctest model is not supported." + echo "-- Error -- Possible arguments are Nightly, Experimental, Continuous or Profile." + exit 1 +fi + +# test if the input file exists and execute it +if [ -e "$2" ];then + source $2 +else + echo "-- Error -- Input file does not exist." + echo "-- Error -- Please choose existing input file." + exit 1 +fi + +# set the ctest model to command line parameter +if [ "$1" == "alfa_ci" ]; then + export ctest_model=Experimental +else + export ctest_model=$1 +fi + + +# test for architecture +arch=$(uname -s | tr '[A-Z]' '[a-z]') +chip=$(uname -m | tr '[A-Z]' '[a-z]') + +# extract information about the system and the machine and set +# environment variables used by ctest +SYSTEM=$arch-$chip +if test -z $CXX ; then + if [ "$arch" == "darwin" ]; then + COMPILER=$(clang --version | head -n 1 | cut -d' ' -f1,2,4 | tr -d ' ') + else + COMPILER=gcc$(gcc -dumpversion) + fi +else + COMPILER=$CXX$($CXX -dumpversion) +fi + +if [ "$1" == "alfa_ci" ]; then + export LABEL1=alfa_ci-$COMPILER-FairRoot_$GIT_BRANCH-FairSoft_$FAIRSOFT_VERSION + export LABEL=$(echo $LABEL1 | sed -e 's#/#_#g') +else + export LABEL1=${LINUX_FLAVOUR}-$chip-$COMPILER-FairRoot_$GIT_BRANCH-FairSoft_$FAIRSOFT_VERSION + export LABEL=$(echo $LABEL1 | sed -e 's#/#_#g') +fi + +# get the number of processors +# and information about the host +if [ "$arch" = "linux" ]; +then + if [ "$NCPU" != "" ]; + then + export number_of_processors=$NCPU + else + export number_of_processors=$(cat /proc/cpuinfo | grep processor | wc -l) + fi + if [ -z "$SITE" ]; then + export SITE=$(hostname -f) + if [ -z "$SITE" ]; then + export SITE=$(uname -n) + fi + fi +elif [ "$arch" = "darwin" ]; +then + if [ "$NCPU" != "" ]; + then + export number_of_processors=$NCPU + else + export number_of_processors=$(sysctl -n hw.ncpu) + fi + if [ -z "$SITE" ]; then + export SITE=$(hostname -s) + fi +fi + +echo "************************" +date +echo "LABEL: " $LABEL +echo "SITE: " $SITE +echo "Model: " ${ctest_model} +echo "Nr. of processes: " $number_of_processors +echo "************************" + +cd $SOURCEDIR + +ctest -D ${ctest_model} -V --VV diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..f0c1708 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,56 @@ +#!groovy + +def specToLabel(Map spec) { + return "${spec.os}-${spec.arch}-${spec.compiler}-FairSoft_${spec.fairsoft}" +} + +def buildMatrix(List specs, Closure callback) { + def nodes = [:] + for (spec in specs) { + def label = specToLabel(spec) + nodes[label] = { + node(label) { + githubNotify(context: "alfa-ci/${label}", description: 'Building ...', status: 'PENDING') + try { + deleteDir() + checkout scm + + callback.call(spec, label) + + deleteDir() + githubNotify(context: "alfa-ci/${label}", description: 'Success', status: 'SUCCESS') + } catch (e) { + deleteDir() + githubNotify(context: "alfa-ci/${label}", description: 'Error', status: 'ERROR') + throw e + } + } + } + } + return nodes +} + +pipeline{ + agent none + stages { + stage("Run Build/Test Matrix") { + steps{ + script { + parallel(buildMatrix([ + [os: 'Debian8', arch: 'x86_64', compiler: 'gcc4.9', fairsoft: 'oct17'], + [os: 'MacOS10.11', arch: 'x86_64', compiler: 'AppleLLVM8.0.0', fairsoft: 'oct17'], + [os: 'MacOS10.13', arch: 'x86_64', compiler: 'AppleLLVM9.0.0', fairsoft: 'oct17'], + ]) { spec, label -> + sh '''\ + echo "export BUILDDIR=$PWD/build" >> Dart.cfg + echo "export SOURCEDIR=$PWD" >> Dart.cfg + echo "export PATH=$SIMPATH/bin:$PATH" >> Dart.cfg + echo "export GIT_BRANCH=$JOB_BASE_NAME" >> Dart.cfg + ''' + sh './Dart.sh alfa_ci Dart.cfg' + }) + } + } + } + } +} diff --git a/cmake/FairLoggerLib.cmake b/cmake/FairLoggerLib.cmake index b9a6095..3a5f1a7 100644 --- a/cmake/FairLoggerLib.cmake +++ b/cmake/FairLoggerLib.cmake @@ -131,7 +131,6 @@ macro(set_fairlogger_defaults) set(FairLogger_INSTALL_LIBDIR ${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME_LOWER}) set(FairLogger_INSTALL_INCDIR ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME_LOWER}) set(FairLogger_INSTALL_DATADIR ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME_LOWER}) - set(FairLogger_INSTALL_CMAKEMODDIR ${FairLogger_INSTALL_DATADIR}/cmake) # Define export set, only one for now set(FairLogger_EXPORT_SET ${PROJECT_NAME}Targets)