blob: 1c0ca6b772039ee61b381fc016b826cddd3b14d4 [file] [log] [blame]
Jan Kundrátd9d26a92018-02-22 12:49:21 +01001#!/bin/bash
2
3set -eux -o pipefail
4shopt -s failglob
5
6# We're reusing our artifacts, so we absolutely need a stable destdir.
7# Turbo-hipster takes care of cleaning up the mess betweeb builds.
8PREFIX=~/target
9mkdir ${PREFIX}
10export PATH=${PREFIX}/bin:$PATH
11export LD_LIBRARY_PATH=${PREFIX}/lib64:${PREFIX}/lib
12export PKG_CONFIG_PATH=${PREFIX}/lib64/pkgconfig:${PREFIX}/lib/pkgconfig
13
14if [[ $TH_JOB_NAME =~ .*-sanitizers-.* ]]; then
15 # https://gitlab.kitware.com/cmake/cmake/issues/16609
16 CMAKE_OPTIONS="${CMAKE_OPTIONS} -DTHREADS_HAVE_PTHREAD_ARG:BOOL=ON"
17fi
18
19# force-enable tests for packages which use, eh, interesting setup
20# - libyang and libnetconf2 copmare CMAKE_BUILD_TYPE to lowercase "debug"...
21CMAKE_OPTIONS="${CMAKE_OPTIONS} -DENABLE_BUILD_TESTS=ON -DENABLE_VALGRIND_TESTS=OFF"
22
Jan Kundrátd47f6552018-03-02 13:40:11 +010023build_dep_cmake() {
24 pushd ${TH_JOB_WORKING_DIR}
25 mkdir build-$1
26 pushd build-$1
27 ${CMAKE} -GNinja ${CMAKE_OPTIONS} -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE:-Debug} -DCMAKE_INSTALL_PREFIX=${PREFIX} ${TH_GIT_PATH}/submodules/$1
28 ninja-build install
29 popd
30 popd
31}
32
33do_test_dep_cmake() {
34 pushd ${TH_JOB_WORKING_DIR}/build-$1
35 shift
36 ${CTEST} --output-on-failure "$@"
37 popd
38}
39
40emerge_dep() {
41 if [[ -f ${TH_GIT_PATH}/submodules/$1/CMakeLists.txt ]]; then
42 build_dep_cmake $1
43 else
44 echo "Unrecognized buildsystem for $1"
45 exit 1
46 fi
47}
48
49ARTIFACT=netconf-cli-$(git --git-dir ${TH_GIT_PATH}/.git rev-parse HEAD:submodules/).tar.xz
50
51scp th-ci-logs@ci-logs.gerrit.cesnet.cz:artifacts/${TH_JOB_NAME}/${ARTIFACT} . \
52 || true # ignore network errors
53
54if [[ -f ${TH_JOB_WORKING_DIR}/${ARTIFACT} ]]; then
55 tar -C ~/target -xvJf ${TH_JOB_WORKING_DIR}/${ARTIFACT}
56else
57 # rebuild everything from scratch
58
59 emerge_dep Catch
60 do_test_dep_cmake Catch -j${CI_PARALLEL_JOBS}
61
62 # Trompeloeil is a magic snowflake because it attempts to download and build Catch and kcov when building in a debug mode...
63 CMAKE_BUILD_TYPE=Release emerge_dep trompeloeil
64
65 emerge_dep docopt.cpp
66 do_test_dep_cmake docopt.cpp -j${CI_PARALLEL_JOBS}
67
68 emerge_dep spdlog
69 do_test_dep_cmake spdlog -j${CI_PARALLEL_JOBS}
70
71 # boost-spirit doesn't require installation
72
73 tar -C ~/target -cvJf ${TH_JOB_WORKING_DIR}/${ARTIFACT} .
74 ssh th-ci-logs@ci-logs.gerrit.cesnet.cz mkdir -p artifacts/${TH_JOB_NAME} \
75 || true # ignore network errors
76 rsync ${TH_JOB_WORKING_DIR}/${ARTIFACT} th-ci-logs@ci-logs.gerrit.cesnet.cz:artifacts/${TH_JOB_NAME}/ \
77 || true # ignore network errors
78fi
79
Jan Kundrátd9d26a92018-02-22 12:49:21 +010080mkdir -p ${ZUUL_PROJECT}/build
81cd ${ZUUL_PROJECT}/build
82${CMAKE} -GNinja \
83 -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE:-Debug} \
84 -DCMAKE_INSTALL_PREFIX=${PREFIX} \
85 ${CMAKE_OPTIONS} \
86 ${TH_GIT_PATH}
87ninja-build
88
89${CTEST} --output-on-failure