summaryrefslogtreecommitdiffstats
path: root/ansible_collections/community/postgresql/.azure-pipelines/scripts/run-tests.sh
blob: a947fdf013c094d1fab17bf5d424afd03db120e1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env bash
# Configure the test environment and run the tests.

set -o pipefail -eu

entry_point="$1"
test="$2"
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
    IS_PULL_REQUEST=true
    COMMIT_MESSAGE=$(git log --format=%B -n 1 HEAD^2)
else
    IS_PULL_REQUEST=
    COMMIT_MESSAGE=$(git log --format=%B -n 1 HEAD)
fi

COMPLETE=
COVERAGE=

if [ "${BUILD_REASON}" = "Schedule" ]; then
    COMPLETE=yes

    if printf '%s\n' "${coverage_branches[@]}" | grep -q "^${BUILD_SOURCEBRANCHNAME}$"; then
        COVERAGE=yes
    fi
fi

"${entry_point}" "${test}" 2>&1 | "$(dirname "$0")/time-command.py"