-
Notifications
You must be signed in to change notification settings - Fork 22
/
openqa-label-known-issues-and-investigate-hook
executable file
·53 lines (44 loc) · 1.49 KB
/
openqa-label-known-issues-and-investigate-hook
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
45
46
47
48
49
50
51
52
53
#!/bin/bash
set -eo pipefail
# "hook script" intended to be called by openQA instances taking a job ID as
# parameter and forwarding a complete job URL to "openqa-label-known-issues"
# on stdin and all left unknowns to "openqa-investigate"
dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
PATH=$dir:$PATH
# shellcheck source=/dev/null
source "$dir"/_common
host="${host:-"openqa.opensuse.org"}"
scheme="${scheme:-"https"}"
host_url="$scheme://$host"
investigate-and-bisect() {
local rc=0 test
read -r test || rc=$?
[[ -n "$test" ]] || return 0
rc=0
openqa-investigate "$test" || rc=$?
[[ "$rc" -eq 142 ]] && return "$rc"
openqa-trigger-bisect-jobs --url "$test" || rc=$?
return "$rc"
}
label() {
local url=$1
openqa-label-known-issues "$url" | sed -n 's/\[\([^]]*\)\].*Unknown test issue, to be reviewed.*/\1/p'
}
hook() {
local id="${1:?"Need 'job_id'"}"
local url=$host_url/tests/$id
local rc=0
job_data=$(openqa-api-get "jobs/$id") || rc=$?
# shellcheck disable=SC2154
[[ $job_data =~ $not_found_regex ]] && warn "Ignoring non-existent job $id" && return
[[ $rc != 0 ]] && return $rc
state="$(echo "$job_data" | runjq -r '.job.state')" || return $?
result="$(echo "$job_data" | runjq -r '.job.result')" || return $?
[[ "$state" != "done" ]] && return
if [[ "$result" != passed ]]; then
label "$url" | investigate-and-bisect
else
echo "$url" | investigate-and-bisect
fi
}
caller 0 > /dev/null || hook "$@"