Jan Kundrát | d9d26a9 | 2018-02-22 12:49:21 +0100 | [diff] [blame] | 1 | #!/bin/bash |
Jan Kundrát | 73e3bf2 | 2019-02-28 15:44:02 +0100 | [diff] [blame] | 2 | |
| 3 | set -eux -o pipefail |
| 4 | shopt -s failglob |
| 5 | |
| 6 | ZUUL_JOB_NAME=$(jq < ~/zuul-env.json -r '.job') |
Jan Kundrát | 8a91466 | 2019-02-28 18:11:55 +0100 | [diff] [blame] | 7 | ZUUL_TENANT=$(jq < ~/zuul-env.json -r '.tenant') |
Jan Kundrát | 73e3bf2 | 2019-02-28 15:44:02 +0100 | [diff] [blame] | 8 | ZUUL_PROJECT_SRC_DIR=$HOME/$(jq < ~/zuul-env.json -r '.project.src_dir') |
| 9 | ZUUL_PROJECT_SHORT_NAME=$(jq < ~/zuul-env.json -r '.project.short_name') |
Jan Kundrát | dba6358 | 2019-06-06 13:09:30 +0200 | [diff] [blame^] | 10 | ZUUL_GERRIT_HOSTNAME=$(jq < ~/zuul-env.json -r '.project.canonical_hostname') |
Jan Kundrát | 73e3bf2 | 2019-02-28 15:44:02 +0100 | [diff] [blame] | 11 | |
| 12 | CI_PARALLEL_JOBS=$(grep -c '^processor' /proc/cpuinfo) |
| 13 | CMAKE_OPTIONS="" |
| 14 | CFLAGS="" |
| 15 | CXXFLAGS="" |
| 16 | LDFLAGS="" |
| 17 | |
| 18 | if [[ $ZUUL_JOB_NAME =~ .*-clang.* ]]; then |
| 19 | export CC=clang |
| 20 | export CXX=clang++ |
| 21 | export LD=clang |
| 22 | export CXXFLAGS="-stdlib=libc++" |
| 23 | fi |
| 24 | |
| 25 | if [[ $ZUUL_JOB_NAME =~ .*-ubsan ]]; then |
| 26 | export CFLAGS="-fsanitize=undefined ${CFLAGS}" |
| 27 | export CXXFLAGS="-fsanitize=undefined ${CXXFLAGS}" |
| 28 | export LDFLAGS="-fsanitize=undefined ${LDFLAGS}" |
| 29 | fi |
| 30 | |
| 31 | if [[ $ZUUL_JOB_NAME =~ .*-asan ]]; then |
| 32 | export CFLAGS="-fsanitize=address ${CFLAGS}" |
| 33 | export CXXFLAGS="-fsanitize=address ${CXXFLAGS}" |
| 34 | export LDFLAGS="-fsanitize=address ${LDFLAGS}" |
| 35 | fi |
| 36 | |
Jan Kundrát | 7b7c823 | 2019-03-13 14:04:06 +0100 | [diff] [blame] | 37 | if [[ $ZUUL_JOB_NAME =~ .*-tsan ]]; then |
| 38 | export CFLAGS="-fsanitize=thread ${CFLAGS}" |
| 39 | export CXXFLAGS="-fsanitize=thread ${CXXFLAGS}" |
| 40 | export LDFLAGS="-fsanitize=thread ${LDFLAGS}" |
| 41 | fi |
| 42 | |
Jan Kundrát | 73e3bf2 | 2019-02-28 15:44:02 +0100 | [diff] [blame] | 43 | PREFIX=~/target |
| 44 | mkdir ${PREFIX} |
| 45 | BUILD_DIR=~/build |
| 46 | mkdir ${BUILD_DIR} |
| 47 | export PATH=${PREFIX}/bin:$PATH |
| 48 | export LD_LIBRARY_PATH=${PREFIX}/lib64:${PREFIX}/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH} |
| 49 | export PKG_CONFIG_PATH=${PREFIX}/lib64/pkgconfig:${PREFIX}/lib/pkgconfig${PKG_CONFIG_PATH:+:$PKG_CONFIG_PATH} |
| 50 | |
| 51 | ARTIFACT_URL="" |
| 52 | |
Jan Kundrát | df70cb1 | 2019-05-29 12:47:50 +0200 | [diff] [blame] | 53 | if [[ "$(jq < ~/zuul-env.json -r '.artifacts[-1].project')" = "CzechLight/dependencies" && |
| 54 | "$(jq < ~/zuul-env.json -r '.artifacts[-1].name')" = "tarball" ]]; then |
| 55 | ARTIFACT_URL=$(jq < ~/zuul-env.json -r '.artifacts[-1].url') |
Jan Kundrát | 73e3bf2 | 2019-02-28 15:44:02 +0100 | [diff] [blame] | 56 | fi |
| 57 | |
| 58 | DEP_SUBMODULE_COMMIT=$(git ls-tree -l master submodules/dependencies | cut -d ' ' -f 3) |
| 59 | |
| 60 | if [[ -z "${ARTIFACT_URL}" ]]; then |
| 61 | # fallback to a promoted artifact |
Jan Kundrát | dba6358 | 2019-06-06 13:09:30 +0200 | [diff] [blame^] | 62 | ARTIFACT_URL="https://object-store.cloud.muni.cz/swift/v1/ci-artifacts-${ZUUL_TENANT}/${ZUUL_GERRIT_HOSTNAME}/CzechLight/dependencies/${ZUUL_JOB_NAME}/${DEP_SUBMODULE_COMMIT}.tar.xz" |
Jan Kundrát | 73e3bf2 | 2019-02-28 15:44:02 +0100 | [diff] [blame] | 63 | fi |
| 64 | |
| 65 | ARTIFACT_FILE=$(basename ${ARTIFACT_URL}) |
| 66 | DEP_HASH_FROM_ARTIFACT=$(echo "${ARTIFACT_FILE}" | sed -e 's/^czechlight-dependencies-//' -e 's/\.tar\.xz$//') |
| 67 | if [[ "${DEP_HASH_FROM_ARTIFACT}" != "${DEP_SUBMODULE_COMMIT}" ]]; then |
| 68 | echo "Mismatched artifact: HEAD of ./submodules/dependencies does not match artifact commit ref" |
| 69 | exit 1 |
| 70 | fi |
| 71 | curl ${ARTIFACT_URL} --output ${ARTIFACT_FILE} |
| 72 | tar -C ${PREFIX} -xf ${ARTIFACT_FILE} |
| 73 | rm ${ARTIFACT_FILE} |
| 74 | |
| 75 | cd ${BUILD_DIR} |
| 76 | cmake -GNinja -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE:-Debug} -DCMAKE_INSTALL_PREFIX=${PREFIX} ${CMAKE_OPTIONS} ${ZUUL_PROJECT_SRC_DIR} |
| 77 | ninja-build |
| 78 | ctest -j${CI_PARALLEL_JOBS} --output-on-failure |
| 79 | ninja-build doc |
Jan Kundrát | dba6358 | 2019-06-06 13:09:30 +0200 | [diff] [blame^] | 80 | pushd html |
| 81 | zip -r ~/zuul-output/docs/html.zip . |
| 82 | popd |