-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathtravis_mon
executable file
·101 lines (85 loc) · 3.06 KB
/
travis_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
#!/bin/bash
# SPDX-Identifier: gpl-2.0-or-later
# Copyright (C) 2019, Red Hat, Inc.
#
# Monitors a travis 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 "${HOME}/.travis-rc" ] && source "${HOME}/.travis-rc"
[ -f "${HOME}/.pwmon-rc" ] && source "${HOME}/.pwmon-rc"
source $(dirname $0)/travis_lib.sh
source $(dirname $0)/series_db_lib.sh
if [ "$1" != "" ]; then
pw_instance="$1"
shift
fi
if [ "$1" != "" ]; then
travis_credential="$1"
shift
fi
pw_project=""
if [ "$1" != "" ]; then
pw_project="$1"
shift
fi
travis_api_server="api.travis-ci.com"
function submit_result() {
echo "pw|$2|build|$4|sha|$6|$1|$7|$8|$9"
}
function process_build() {
local pw_instance="$1"
local pw_project="$2"
local series_id="$3"
local series_url="$4"
local series_sha="$5"
local build_state="$6"
local build_url="$7"
local subj="$8"
local travis_repo="$9"
echo "build state [$build_state]"
if [ "$build_state" == "created" ]; then
return
fi
if [ "$build_state" == "canceled" ]; then
return
fi
if [ "$build_state" == "failed" -o "$build_state" == "passed" -o "$build_state" == "errored" ]; then
echo "submit..."
submit_result "$build_state" "$pw_instance" "$pw_project" "$series_id" \
"$series_url" "$series_sha" "$build_url" "$subj" "$travis_repo"
series_clear_branch "$pw_instance" "$series_id"
return
fi
}
for branch in $(series_get_active_branches "$pw_instance"); do
series_id=$(echo $branch | cut -d\| -f1)
project=$(echo $branch | cut -d\| -f2)
series_url=$(echo $branch | cut -d\| -f3)
travis_repo=$(echo $branch | cut -d\| -f4)
branchname=$(echo $branch | cut -d\| -f5)
if [ "X$pw_project" != "X" -a "X$pw_project" != "X$project" ]; then
continue
fi
travis_builds_for_branch "$travis_api_server" "$travis_credential" "$travis_repo" \
"$branchname" | \
while IFS=\| read -r build_shasum build_state start_time end_time build_url subj; do
# try to go by series first
echo Checking series $series_id
build_url=$(echo $build_url | sed 's@/build/@https://travis-ci.com/ovsrobot/dpdk/builds/@')
process_build "$pw_instance" "$project" "$series_id" "$series_url" \
"$build_shasum" "$build_state" "$build_url" "$subj" "$travis_repo"
done
done