Changeset View
Standalone View
contrib/teamcity/build-configurations.sh
#!/usr/bin/env bash | #!/usr/bin/env bash | ||||
export LC_ALL=C | export LC_ALL=C | ||||
set -euxo pipefail | set -euxo pipefail | ||||
if [ -z "$ABC_BUILD_NAME" ]; then | if [ -z "$ABC_BUILD_NAME" ]; then | ||||
echo "Error: Environment variable ABC_BUILD_NAME must be set" | echo "Error: Environment variable ABC_BUILD_NAME must be set" | ||||
exit 1 | exit 1 | ||||
fi | fi | ||||
echo "Running build configuration '${ABC_BUILD_NAME}'..." | echo "Running build configuration '${ABC_BUILD_NAME}'..." | ||||
TOPLEVEL=$(git rev-parse --show-toplevel) | setup() { | ||||
cd "${TOPLEVEL}/contrib/teamcity" | if [[ -z "$1" ]]; then | ||||
echo "Error: missing argument. Usage: setup <project_root_directory>" | |||||
exit 1 | |||||
fi | |||||
export TOPLEVEL="$1" | |||||
export BUILD_DIR="${TOPLEVEL}/build" | |||||
mkdir -p "${BUILD_DIR}/output" | |||||
TEST_RUNNER_FLAGS="--tmpdirprefix=output" | |||||
cd "${BUILD_DIR}" | |||||
## Determine the number of build threads | |||||
jasonbcox: double comment ## | |||||
THREADS=$(nproc || sysctl -n hw.ncpu) | |||||
export THREADS | |||||
jasonbcoxUnsubmitted Not Done Inline ActionsThis can be collapsed into the line above it. jasonbcox: This can be collapsed into the line above it. | |||||
FabienAuthorUnsubmitted Done Inline ActionsDoing so will discard the return value of the command line in favor of the return value of export, and cause a linter error. Fabien: Doing so will discard the return value of the command line in favor of the return value of… | |||||
# 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" | |||||
} | |||||
# Facility to print out sanitizer log outputs to the build log console | |||||
print_sanitizers_log() { | |||||
for log in "${SAN_LOG_DIR}"/*.log.* | |||||
do | |||||
echo "*** Output of ${log} ***" | |||||
cat "${log}" | |||||
done | |||||
} | |||||
CI_SCRIPTS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" | |||||
setup "$(git rev-parse --show-toplevel)" | |||||
jasonbcoxUnsubmitted Not Done Inline ActionsIt's unnecessary to pass this value into the function only to export it again. it's probably best to define it at the top of the script. jasonbcox: It's unnecessary to pass this value into the function only to export it again. it's probably… | |||||
case "$ABC_BUILD_NAME" in | case "$ABC_BUILD_NAME" in | ||||
build-asan) | build-asan) | ||||
export CONFIGURE_FLAGS="--enable-debug --with-sanitizers=address --disable-ccache" | # Build with the address sanitizer, then run unit tests and functional test.s | ||||
jasonbcoxUnsubmitted Not Done Inline Actionstypo: test.s jasonbcox: typo: `test.s` | |||||
./build.sh | CONFIGURE_FLAGS="--enable-debug --with-sanitizers=address --disable-ccache" "${CI_SCRIPTS_DIR}"/build.sh | ||||
make -j "${THREADS}" check | |||||
./test/functional/test_runner.py -J=junit_results_asan.xml ${TEST_RUNNER_FLAGS} | |||||
;; | ;; | ||||
build-ubsan) | build-ubsan) | ||||
export CONFIGURE_FLAGS="--enable-debug --with-sanitizers=undefined --disable-ccache CC=clang CXX=clang++" | # Build with the undefined sanitizer, then run unit tests and functional tests. | ||||
./build.sh | CONFIGURE_FLAGS="--enable-debug --with-sanitizers=undefined --disable-ccache CC=clang CXX=clang++" "${CI_SCRIPTS_DIR}"/build.sh | ||||
make -j "${THREADS}" check | |||||
./test/functional/test_runner.py -J=junit_results_ubsan.xml ${TEST_RUNNER_FLAGS} | |||||
;; | ;; | ||||
build-default) | build-default) | ||||
./build.sh | # Build, run unit tests and functional tests (with extended cutoff if this is the master branch). | ||||
./build-secp256k1.sh | "${CI_SCRIPTS_DIR}"/build.sh | ||||
make -j "${THREADS}" check | |||||
BRANCH=$(git rev-parse --abbrev-ref HEAD) | |||||
if [[ "${BRANCH}" == "master" ]]; then | |||||
TEST_RUNNER_FLAGS="${TEST_RUNNER_FLAGS} --cutoff=600" | |||||
fi | |||||
./test/functional/test_runner.py -J=junit_results_default.xml ${TEST_RUNNER_FLAGS} | |||||
./test/functional/test_runner.py -J=junit_results_next_upgrade.xml --with-gravitonactivation ${TEST_RUNNER_FLAGS} | |||||
jasonbcoxUnsubmitted Not Done Inline ActionsFood for thought: This sort of improvement could be done in a separate diff and make the review easier. I won't block this diff on this change, but just keep in mind for the future. There are other small (mostly one-liner) changes that could have had the same fate. jasonbcox: Food for thought: This sort of improvement could be done in a separate diff and make the review… | |||||
FabienAuthorUnsubmitted Done Inline ActionsI'm not sure what improvement you're talking about, but using test_runner cannot really be separated from the global move as it requires the environment to be compliant with how the test is executed. Splitting the setup function would have break the build script, and the opposite is true as well. Fabien: I'm not sure what improvement you're talking about, but using `test_runner` cannot really be… | |||||
# Build secp256k1 and run the java tests. | |||||
setup "${TOPLEVEL}"/src/secp256k1 | |||||
CONFIGURE_FLAGS="--enable-jni --enable-experimental --enable-module-ecdh" "${CI_SCRIPTS_DIR}"/build.sh | |||||
make -j "${THREADS}" check-java | |||||
;; | ;; | ||||
build-without-wallet) | build-without-wallet) | ||||
export DISABLE_WALLET=1 | # Build without wallet and run the unit tests. | ||||
./build.sh | CONFIGURE_FLAGS="--disable-wallet" "${CI_SCRIPTS_DIR}"/build.sh | ||||
make -j "${THREADS}" check | |||||
;; | ;; | ||||
*) | *) | ||||
echo "Error: Invalid build name '${ABC_BUILD_NAME}'" | echo "Error: Invalid build name '${ABC_BUILD_NAME}'" | ||||
exit 2 | exit 2 | ||||
;; | ;; | ||||
esac | esac |
double comment ##