-
Notifications
You must be signed in to change notification settings - Fork 6
/
vote
executable file
·26 lines (22 loc) · 979 Bytes
/
vote
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
#!/usr/bin/env bash
# Post a vote to review.openstack.org for the test in the current directory.
# The vote is based on ./event.json and ./test-result.txt
set -e
source ${CI?}/config
[ -f test-result.txt ] || (echo "No test-result to vote on" >&2; exit 1)
vote="0"
head -1 test-result.txt | grep -q "^PASSED" && vote="+1"
head -1 test-result.txt | grep -q "^FAILED" && vote="-1"
uuid=$(basename $(pwd))
date=$(date "+%F %T")
url=$(cat event.json | sed -z -e 's/.*"url": "//' -e 's/".*//')
commit=$(cat event.json | sed -z -e 's/.*"revision": "//' -e 's/".*//')
if [ "${CI_ENABLE_VOTING}" == "yes" ]; then
echo "${date} ${uuid} VOTE ${vote} ${url}" >> ${CI?}/log/activity.log
ssh -p 29418 review.openstack.org \
gerrit review --verified "${vote}" --message \'"$(cat test-result.txt)"\' \
${commit} && (echo ${vote} >> cast-votes.txt)
else
echo "${date} ${uuid} NOVOTE ${vote} ${url}" >> ${CI?}/log/activity.log
echo "skipped ${vote}" >> cast-votes.txt
fi