2021-02-03 11:40:48 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
# Configure the test environment and run the tests.
|
|
|
|
|
|
|
|
set -o pipefail -eu
|
|
|
|
|
|
|
|
entry_point="$1"
|
2023-09-27 06:59:26 +00:00
|
|
|
entry_point_args="$2"
|
2021-02-03 11:40:48 +00:00
|
|
|
read -r -a coverage_branches <<< "$3" # space separated list of branches to run code coverage on for scheduled builds
|
|
|
|
|
|
|
|
export COMMIT_MESSAGE
|
|
|
|
export COMPLETE
|
|
|
|
export COVERAGE
|
|
|
|
export IS_PULL_REQUEST
|
|
|
|
|
|
|
|
if [ "${SYSTEM_PULLREQUEST_TARGETBRANCH:-}" ]; then
|
2023-08-02 10:04:20 +00:00
|
|
|
IS_PULL_REQUEST=true
|
|
|
|
COMMIT_MESSAGE=$(git log --format=%B -n 1 HEAD^2)
|
2021-02-03 11:40:48 +00:00
|
|
|
else
|
2023-09-27 06:59:26 +00:00
|
|
|
IS_PULL_REQUEST=false
|
2023-08-02 10:04:20 +00:00
|
|
|
COMMIT_MESSAGE=$(git log --format=%B -n 1 HEAD)
|
2021-02-03 11:40:48 +00:00
|
|
|
fi
|
|
|
|
|
2023-09-27 06:59:26 +00:00
|
|
|
COMPLETE=false
|
|
|
|
COVERAGE=false
|
2021-02-03 11:40:48 +00:00
|
|
|
|
|
|
|
if [ "${BUILD_REASON}" = "Schedule" ]; then
|
2023-09-27 06:59:26 +00:00
|
|
|
COMPLETE=true
|
2021-02-03 11:40:48 +00:00
|
|
|
|
2023-08-02 10:04:20 +00:00
|
|
|
if printf '%s\n' "${coverage_branches[@]}" | grep -q "^${BUILD_SOURCEBRANCHNAME}$"; then
|
2023-09-27 06:59:26 +00:00
|
|
|
COVERAGE=true
|
2023-08-02 10:04:20 +00:00
|
|
|
fi
|
2021-02-03 11:40:48 +00:00
|
|
|
fi
|
|
|
|
|
2023-09-27 06:59:26 +00:00
|
|
|
"${entry_point}" "${entry_point_args}" 2>&1 | "$(dirname "$0")/time-command.py"
|