diff --git a/contrib/teamcity/build-configurations.sh b/contrib/teamcity/build-configurations.sh index f32883028..e2fd5b208 100755 --- a/contrib/teamcity/build-configurations.sh +++ b/contrib/teamcity/build-configurations.sh @@ -1,42 +1,42 @@ #!/usr/bin/env bash export LC_ALL=C -set -e +set -euxo pipefail if [ -z "$ABC_BUILD_NAME" ]; then echo "Error: Environment variable ABC_BUILD_NAME must be set" exit 1 fi echo "Running build configuration '${ABC_BUILD_NAME}'..." TOPLEVEL=$(git rev-parse --show-toplevel) cd "${TOPLEVEL}/contrib/teamcity" case "$ABC_BUILD_NAME" in build-asan) export CONFIGURE_FLAGS="--enable-debug --with-sanitizers=address --disable-ccache" ./build.sh ;; build-ubsan) export CONFIGURE_FLAGS="--enable-debug --with-sanitizers=undefined --disable-ccache CC=clang CXX=clang++" ./build.sh ;; build-default) ./build.sh ./build-secp256k1.sh ;; build-without-wallet) export DISABLE_WALLET=1 ./build.sh ;; *) echo "Error: Invalid build name '${ABC_BUILD_NAME}'" exit 2 ;; esac diff --git a/contrib/teamcity/build-secp256k1.sh b/contrib/teamcity/build-secp256k1.sh index fd3369af5..af7a06b9f 100755 --- a/contrib/teamcity/build-secp256k1.sh +++ b/contrib/teamcity/build-secp256k1.sh @@ -1,32 +1,32 @@ #!/usr/bin/env bash export LC_ALL=C -set -eu +set -euxo pipefail TOPLEVEL=$(git rev-parse --show-toplevel) if [[ -z "${TOPLEVEL}" ]]; then echo "No .git directory found, assuming pwd" TOPLEVEL=$(pwd -P) fi SECP_DIR="${TOPLEVEL}/src/secp256k1" # Generate necessary autoconf files cd ${SECP_DIR} ./autogen.sh # Setup build directory BUILD_DIR="${SECP_DIR}/build" mkdir -p ${BUILD_DIR} cd ${BUILD_DIR} # Determine the number of build threads THREADS=$(nproc || sysctl -n hw.ncpu) ../configure --enable-jni --enable-experimental --enable-module-ecdh # Run build make -j ${THREADS} # Run Java tests make check-java diff --git a/contrib/teamcity/build.sh b/contrib/teamcity/build.sh index e77fc9d78..5dd2cbba2 100755 --- a/contrib/teamcity/build.sh +++ b/contrib/teamcity/build.sh @@ -1,90 +1,90 @@ #!/usr/bin/env bash export LC_ALL=C -set -eu +set -euxo pipefail TOPLEVEL=$(git rev-parse --show-toplevel) if [[ -z "${TOPLEVEL}" ]]; then echo "No .git directory found, assuming pwd" TOPLEVEL=$(pwd -P) fi BUILD_DIR="${TOPLEVEL}/build" mkdir -p ${BUILD_DIR} ## Generate necessary autoconf files cd ${TOPLEVEL} ./autogen.sh cd ${BUILD_DIR} rm -f build.status test_bitcoin.xml ## Determine the number of build threads THREADS=$(nproc || sysctl -n hw.ncpu) # Default to nothing : "${DISABLE_WALLET:=}" : "${CONFIGURE_FLAGS:=}" read -a CONFIGURE_FLAGS <<< "$CONFIGURE_FLAGS --prefix=$(pwd)" if [[ -n "${DISABLE_WALLET}" ]]; then echo "*** Building without wallet" CONFIGURE_FLAGS+=("--disable-wallet") fi ../configure "${CONFIGURE_FLAGS[@]}" # Base directories for sanitizer related files SAN_SUPP_DIR="${TOPLEVEL}/test/sanitizer_suppressions" SAN_LOG_DIR="${BUILD_DIR}/sanitizer_logs" # Create the log directory if it doesn't exist and clear it mkdir -p "${SAN_LOG_DIR}" rm -rf "${SAN_LOG_DIR:?}"/* # Sanitizers options, not used if sanitizers are not enabled export ASAN_OPTIONS="malloc_context_size=0:log_path=${SAN_LOG_DIR}/asan.log" export LSAN_OPTIONS="suppressions=${SAN_SUPP_DIR}/lsan:log_path=${SAN_LOG_DIR}/lsan.log" export TSAN_OPTIONS="suppressions=${SAN_SUPP_DIR}/tsan:log_path=${SAN_LOG_DIR}/tsan.log" export UBSAN_OPTIONS="suppressions=${SAN_SUPP_DIR}/ubsan:print_stacktrace=1:halt_on_error=1:log_path=${SAN_LOG_DIR}/ubsan.log" function print_sanitizers_log() { for log in "${SAN_LOG_DIR}"/*.log.* do echo "*** Output of ${log} ***" cat "${log}" done } # Run build make -j ${THREADS} # Default to nothing : "${DISABLE_TESTS:=}" # If DISABLE_TESTS is unset (default), run the tests if [[ -z "${DISABLE_TESTS}" ]]; then echo "*** Running tests" # Run unit tests make -j ${THREADS} check || (print_sanitizers_log && exit 1) mkdir -p output/ BRANCH=$(git rev-parse --abbrev-ref HEAD) JUNIT_DEFAULT="junit_results_default.xml" JUNIT_NEXT_UPGRADE="junit_results_next_upgrade.xml" if [[ -n "${DISABLE_WALLET}" ]]; then echo "Skipping rpc testing due to disabled wallet functionality." elif [[ "${BRANCH}" == "master" ]]; then ./test/functional/test_runner.py -J="${JUNIT_DEFAULT}" --cutoff=600 --tmpdirprefix=output ./test/functional/test_runner.py -J="${JUNIT_NEXT_UPGRADE}" --cutoff=600 --tmpdirprefix=output --with-gravitonactivation else ./test/functional/test_runner.py -J="${JUNIT_DEFAULT}" --tmpdirprefix=output ./test/functional/test_runner.py -J="${JUNIT_NEXT_UPGRADE}" --tmpdirprefix=output --with-gravitonactivation fi else echo "*** Tests have been skipped" fi diff --git a/contrib/teamcity/gitian.sh b/contrib/teamcity/gitian.sh index dd8f911a5..92b2e0588 100755 --- a/contrib/teamcity/gitian.sh +++ b/contrib/teamcity/gitian.sh @@ -1,37 +1,37 @@ #!/usr/bin/env bash export LC_ALL=C -set -e +set -euxo pipefail cd "$(dirname "$0")" COMMIT=$(git rev-parse HEAD) export COMMIT PROJECT_ROOT=$(git rev-parse --show-toplevel) export PROJECT_ROOT export USE_LXC=1 export GITIAN_HOST_IP=10.0.3.1 export LXC_BRIDGE=lxcbr0 export LXC_GUEST_IP=10.0.3.5 cd ~/gitian-builder if [[ "${OS_NAME}" == "osx" ]]; then wget https://storage.googleapis.com/f4936e83b2dcbca742be51fb9692b153/MacOSX10.11.sdk.tar.gz echo "4732b52b5ebe300c8c91cbeed6d19d59c1ff9c56c7a1dd6cfa518b9c2c72abde MacOSX10.11.sdk.tar.gz" | sha256sum -c mkdir -p inputs echo "Downloaded" mv MacOSX10.11.sdk.tar.gz inputs fi ## Determine the number of build threads THREADS=$(nproc || sysctl -n hw.ncpu) ./bin/gbuild -j${THREADS} -m3500 --commit bitcoin=${COMMIT} --url bitcoin="${PROJECT_ROOT}" "${PROJECT_ROOT}/contrib/gitian-descriptors/gitian-${OS_NAME}.yml" RESULT_DIR="${PROJECT_ROOT}/gitian-results/${OS_NAME}" mkdir -p "${RESULT_DIR}" mv var/build.log "${PROJECT_ROOT}/gitian-results/" mv result/*.yml "${RESULT_DIR}/" mv build/out/* "${RESULT_DIR}/" diff --git a/contrib/teamcity/ibd.sh b/contrib/teamcity/ibd.sh index 15c9ae64b..916a21f7a 100755 --- a/contrib/teamcity/ibd.sh +++ b/contrib/teamcity/ibd.sh @@ -1,76 +1,79 @@ #!/usr/bin/env bash export LC_ALL=C -set -euo pipefail +set -euxo pipefail ### # Initial Block Download script. # # Runs a bitcoind process until initial block download is complete. # Forwards the exit code from bitcoind onward. ### MYPID=$$ # Setup DATA_DIR="ibd" mkdir -p "${DATA_DIR}" DEBUG_LOG="${DATA_DIR}/debug.log" touch "${DEBUG_LOG}" chmod +x bitcoind # Launch bitcoind using this script's parameters ./bitcoind "-datadir=${DATA_DIR}" "$@" & BITCOIND_PID=$! cleanup() { # Cleanup background processes spawned by this script. pkill -P ${MYPID} tail || true } trap "cleanup" EXIT # Show some progress tail -f "${DEBUG_LOG}" | grep 'UpdateTip' | awk 'NR % 10000 == 0' & # Wait for IBD to finish and kill the daemon ( ( # Ignore the broken pipe when tail tries to write pipe closed by grep set +o pipefail tail -f "${DEBUG_LOG}" | grep -m 1 'progress=1.000000' ) echo "Initial block download complete." # TODO Add more checks to see if IBD completed as expected, # These checks will exit the subshell with a non-zero exit code. ) & IBD_PID=$! # When the IBD subshell finishes, kill bitcoind ( + # Disable verbosity to avoid bloating the output with sleep prints + set +x while [ -e /proc/${IBD_PID} ]; do sleep 0.1; done + set -x echo "Cleaning up bitcoin daemon (PID: ${BITCOIND_PID})." kill ${BITCOIND_PID} ) & # Wait for bitcoind to exit, whether it exited on its own or IBD finished wait ${BITCOIND_PID} BITCOIND_EXIT_CODE=$? if [ "${BITCOIND_EXIT_CODE}" -ne "0" ]; then echo "bitcoind exited unexpectedly with code: ${BITCOIND_EXIT_CODE}" exit ${BITCOIND_EXIT_CODE} fi # Get the exit code for the IBD subshell, which should have exited already wait ${IBD_PID} IBD_EXIT_CODE=$? # The IBD subshell should only exit with a non-zero code if one of the tests # failed. if [ "${IBD_EXIT_CODE}" -ne "0" ]; then echo "IBD tests failed with code: ${IBD_EXIT_CODE}" exit ${IBD_EXIT_CODE} fi