-
Notifications
You must be signed in to change notification settings - Fork 6
/
obs_mon
executable file
·115 lines (97 loc) · 3.62 KB
/
obs_mon
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#!/bin/bash
# SPDX-Identifier: gpl-2.0-or-later
# Copyright (C) 2021, Red Hat, Inc.
#
# Monitors a openSUSE Build Service build history for builds in a series.
# Records the builds in the series database (and emits them on the
# stdout line for processing)
#
# Licensed under the terms of the GNU General Public License as published
# by the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version. You may obtain a copy of the
# license at
#
# https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
[ -f "$(dirname $0)/series_db_lib.sh" ] && source "$(dirname $0)/series_db_lib.sh"
[ -f "${HOME}/.obs_ci_mon_rc" ] && source "${HOME}/.obs_ci_mon_rc"
if [ "X" = "X$pw_instance" ]; then
pw_instance="$1"
shift
fi
if [ "X" = "X$obs_token" ]; then
obs_token="$1"
shift
fi
if [ "X" = "X$pw_project" -a "X$1" != "X" ]; then
pw_project="$1"
shift
fi
if [ "X" = "X$pw_instance" -o "X" = "X$obs_token" ]; then
echo "pw_instance or obs_token were not set." 1>&2
echo -n "These can be passed as an argument or set in " 1>&2
echo "${HOME}/.obs_ci_mon_rc. Exiting" 1>&2
exit 1
fi
OSCBIN=osc
ci_instance=obs_sync
res_file=/tmp/obs_build_results.xml
make_result_for_series () {
series_id="$1"
patch_id="$2"
patch_url="$3"
patch_name="$4"
sha="$5"
repo_name="$6"
result=err
if echo "$series_results" | grep -iq building || \
echo "$series_results" | grep -iq scheduled; then
echo -n "patch_id=$patch_id belonging to series_id=$series_id not" 1>&2
echo -e " completed. Skipping\n" 1>&2
echo "$series_results" 1>&2
return 1
fi
echo "Build for series $series_id finished." 1>&2
# Check if successful, overwrite success if failure
if echo "$series_results" | grep -iq succeeded; then
result=success
fi
if echo "$series_results" | grep -iq failed; then
result=failure
fi
if [ "$result" == "err" ]; then
echo "Error parsing result from series_results below:" 1>&2
echo "$series_results" 1>&2
return 2
fi
set_synced_patch "$patch_id" "$pw_instance" "$ci_instance"
echo "pw|$pw_instance|build|$series_id|SHA|$sha|$result|$build_url|$patch_name|$repo_name|OBS"
}
prev_series=""
get_unsynced_series "$pw_instance" "$ci_instance" | \
while IFS="|" read -r series_id patch_id patch_url patch_name sha patchwork_instance patchwork_project repo_name obs_sync; do
if [ "X$pw_project" != "X" -a "X$pw_project" != "X$patchwork_project" ]; then
continue
fi
if [ "X$series_id" != "X$prev_series" ]; then
prev_series="$series_id"
path="//status[@package=\"series_$series_id\"]/@code"
$OSCBIN -c ~/.dpdkoscconf api -X GET /build/$repo_name/_result > $res_file
build_url="https://build.opensuse.org/repo_name/show/$repo_name"
# Get OBS runs
series_results="$(xmllint --xpath "$path" $res_file)"
if [ $? -ne 0 ]; then
echo -n "Error parsing api response. " 1>&2
echo "Perhaps series=$series_id is not in the api result below:" 1>&2
cat $res_file 1>&2
echo "End of api response. Skipping series $series_id"
continue
fi
fi
make_result_for_series "$series_id" "$patch_id" "$patch_url" "$patch_name" "$sha" "$repo_name"
done