Skip to content

Commit

Permalink
Add script to get a list of failing pants from travis (pantsbuild#5946)
Browse files Browse the repository at this point in the history
  • Loading branch information
illicitonion authored Jun 11, 2018
1 parent f6788e2 commit 8060155
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions build-support/bin/get_failing_travis_targets_for_pr.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/bash -e

if [[ $# != 1 ]]; then
echo >&2 "Usage: $0 pull-request-number"
exit 1
fi
pull=$1

mkdir -p logs/jobs

curl=(curl -s -S -H 'Travis-API-Version: 3')

"${curl[@]}" 'https://api.travis-ci.org/repo/pantsbuild%2Fpants/builds?event_type=pull_request&limit=100&sort_by=finished_at:desc' > logs/search
jobs="$(cat logs/search | jq "[ .builds[] | select(.pull_request_number == ${pull}) ][0] | .jobs[].id")"
targets=()
for job in ${jobs}; do
mkdir -p "logs/jobs/${job}"
"${curl[@]}" "https://api.travis-ci.org/job/${job}" >"logs/jobs/${job}/info"
state="$(cat logs/jobs/${job}/info | jq -r '.state')"
case "${state}" in
"passed")
continue
;;
"failed")
"${curl[@]}" "https://api.travis-ci.org/job/${job}/log.txt" > "logs/jobs/${job}/txt"
targets=("${targets[@]}" $(cat -v "logs/jobs/${job}/txt" | awk '$2 == "....." && $3 ~ /^FAILURE/ {print $1}'))
;;
*)
echo >&2 "Job ${job} state ${state}"
;;
esac
done

(for target in "${targets[@]}"; do
echo "${target}"
done | sort -u)

0 comments on commit 8060155

Please sign in to comment.