51ca172f5b08325aa4885f2d895d09207335d857
[releng/global-jjb.git] / shell / check-info-votes.sh
1 #!/bin/bash -l
2 # SPDX-License-Identifier: EPL-1.0
3 ##############################################################################
4 # Copyright (c) 2019 The Linux Foundation and others.
5 #
6 # All rights reserved. This program and the accompanying materials
7 # are made available under the terms of the Eclipse Public License v1.0
8 # which accompanies this distribution, and is available at
9 # http://www.eclipse.org/legal/epl-v10.html
10 ##############################################################################
11 echo "---> check-info-votes.sh"
12 set -u unset
13
14 ref=$(echo "$GERRIT_REFSPEC" | awk -F"/" '{ print $4 }')
15 pip="pip3"
16
17 # For OPNFV
18 if [[ $NODE_NAME =~ "lf-build" ]]; then
19     pip=pip
20 fi
21
22 if [ -d "/opt/pyenv" ]; then
23     echo "---> Setting up pyenv"
24     export PYENV_ROOT="/opt/pyenv"
25     export PATH="$PYENV_ROOT/bin:$PATH"
26     PYTHONPATH=$(pwd)
27     export PYTHONPATH
28     pyenv local 3.6.4
29     export PYENV_VERSION="3.6.4"
30 fi
31
32 $pip install --user niet
33 $pip install --user lftools
34 $pip install --user lftools[nexus]
35 $pip install --user jsonschema
36
37 echo "Checking votes:"
38 lftools infofile check-votes INFO.yaml "$GERRIT_URL" "$ref" > gerrit_comment.txt
39 exit_status="$?"
40
41 if [[ "$exit_status" -ne 0 ]]; then
42     echo "Vote not yet complete"
43     cat gerrit_comment.txt
44     exit "$exit_status"
45 else
46     echo "Vote completed submitting review"
47     ssh -p "$GERRIT_PORT" "$USER"@"$GERRIT_HOST" gerrit review "$GERRIT_PATCHSET_REVISION" --verified 1
48     sleep 5
49     ssh -p "$GERRIT_PORT" "$USER"@"$GERRIT_HOST" gerrit review "$GERRIT_PATCHSET_REVISION" --submit
50 fi