forked from TextureGroup/Texture
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_tests_update_status.sh
executable file
·44 lines (34 loc) · 1.16 KB
/
run_tests_update_status.sh
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
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env bash
set -eo pipefail
UPDATE_STATUS_PATH=$1
BUILDKITE_PULL_REQUEST=$2
BUILDKITE_BUILD_URL=$3
function updateStatus() {
if [ "${BUILDKITE_PULL_REQUEST}" != "false" ] ; then
${UPDATE_STATUS_PATH} "TextureGroup" "Texture" ${BUILDKITE_PULL_REQUEST} "$1" ${BUILDKITE_BUILD_URL} "$2" "CI/Pinterest" "$3"
fi
}
if [[ -z "${UPDATE_STATUS_PATH}" || -z "${BUILDKITE_PULL_REQUEST}" || -z "${BUILDKITE_BUILD_URL}" ]] ; then
echo "Update status path (${UPDATE_STATUS_PATH}), pull request (${BUILDKITE_BUILD_URL}) or build url (${BUILDKITE_PULL_REQUEST}) unset."
trap - EXIT
exit 255
fi
trapped="false"
function trap_handler() {
if [[ "$trapped" = "false" ]]; then
updateStatus "failure" "Tests failed…" `pwd`/log.txt
echo "Tests failed, updated status to failure"
rm `pwd`/log.txt
fi
trapped="true"
}
trap trap_handler INT TERM EXIT
updateStatus "pending" "Starting build…"
echo "--- Running Danger"
bundle exec danger --verbose 2>&1|tee `pwd`/log.txt
./build.sh all 2>&1|tee `pwd`/log.txt
rm `pwd`/log.txt
updateStatus "success" "Tests passed"
echo "All tests succeeded, updated status to success"
trap - EXIT
exit 0