INFO.yaml check vote for global-jjb 35/15035/12
authorAric Gardner <agardner@linuxfoundation.org>
Mon, 25 Mar 2019 20:35:34 +0000 (16:35 -0400)
committerAric Gardner <agardner@linuxfoundation.org>
Wed, 3 Apr 2019 16:01:29 +0000 (12:01 -0400)
Global job per gerrit, that triggers on changes
to INFO.yaml file

And auto merged if a majority of committers
have voted.

This will create a review in the internal gerrit

If a tsc vote is required, RE must manually confirm
that this has happened.

We will need to give
Non-Interactive Users merge
or perhaps specifically only the jenkins
user.

Job will only trigger when a user votes +2
cludgy but it works.

Example of Job configuration:

- project:
    name: info-vote
    build-node: centos7-builder-2c-1g
    jobs:
      - 'info-vote-verify'

Change-Id: Ib386bd2ea51be113ca59610bd3281b9ad6923bce
Signed-off-by: Aric Gardner <agardner@linuxfoundation.org>
docs/jjb/lf-info-vote.rst [new file with mode: 0644]
docs/jjb/lf-macros.rst
jjb/lf-info-vote.yaml [new file with mode: 0644]
jjb/lf-macros.yaml
releasenotes/notes/lf-info-vote-74329a41dfea62be.yaml [new file with mode: 0644]
shell/check-info-votes.sh [new file with mode: 0644]

diff --git a/docs/jjb/lf-info-vote.rst b/docs/jjb/lf-info-vote.rst
new file mode 100644 (file)
index 0000000..76c6d3d
--- /dev/null
@@ -0,0 +1,25 @@
+.. _lf-global-jjb-info-vote:
+
+#############
+INFO VOTE JOB
+#############
+
+Job counts the votes from the committers against a change
+to the INFO.yaml file
+
+If needed, will also check for a majority of tsc voters
+(not yet implemented)
+
+Auto-merges the change on a majority vote.
+
+
+info-vote
+---------
+
+:Comment Trigger: recheck|reverify|Vote
+
+:Required parameters:
+
+    :build-node: The node to run build on.
+    :jenkins-ssh-credential: Credential to use for SSH. (Generally set
+        in defaults.yaml)
index 94fcb1c..d1efe47 100644 (file)
@@ -234,6 +234,11 @@ lf-rtd-verify
 
 ReadTheDocs verify script.
 
+check-info-votes
+----------------
+
+Calls shell script to validate votes on a change to an INFO.yaml
+
 lf-sigul-sign-dir
 -----------------
 
diff --git a/jjb/lf-info-vote.yaml b/jjb/lf-info-vote.yaml
new file mode 100644 (file)
index 0000000..012400f
--- /dev/null
@@ -0,0 +1,105 @@
+---
+####################
+# COMMON FUNCTIONS #
+####################
+
+- lf_info_vote_common: &lf_info_vote_common
+    name: lf-info-vote-common
+
+    gerrit_trigger_file_paths:
+      - compare-type: REG_EXP
+        pattern: 'INFO.yaml'
+
+    #####################
+    # Job Configuration #
+    #####################
+
+    project-type: freestyle
+    node: '{build-node}'
+
+    properties:
+      - lf-infra-properties:
+          build-days-to-keep: 7
+
+    parameters:
+      - lf-infra-parameters:
+          project: $GERRIT_PROJECT
+          branch: 'master'
+          refspec: 'refs/heads/{branch}'
+          stream: 'master'
+
+    wrappers:
+      - lf-infra-wrappers:
+          build-timeout: '{build-timeout}'
+          jenkins-ssh-credential: '{jenkins-ssh-credential}'
+
+    publishers:
+      - lf-infra-publish
+
+
+- lf_info_vote_verify: &lf_info_vote_verify
+    name: lf-info-vote-verify
+
+    branch: master
+    stream: master
+    build-days-to-keep: 7
+    build-timeout: 15
+    disable-job: false
+    git-url: '$GIT_URL/$PROJECT'
+    submodule-timeout: 10
+    submodule-recursive: true
+    gerrit-skip-vote: false
+
+    gerrit_verify_triggers:
+      - comment-added-contains-event:
+          comment-contains-value: '^Patch Set[ ]+[0-9]+:([ ]+|[\n]+)(vote)$'
+      - comment-added:
+          approval-category: 'CRVW'
+          approval-value: '+2'
+      - comment-added:
+          approval-category: 'Code-Review'
+          approval-value: '+2'
+
+    #####################
+    # Job Configuration #
+    #####################
+
+    disabled: '{disable-job}'
+
+    builders:
+      - check-info-votes:
+          jenkins-ssh-credential: '{jenkins-ssh-credential}'
+
+- job-template:
+    name: 'info-vote'
+    id: info-vote-verify
+    <<: *lf_info_vote_common
+    # yamllint disable-line rule:key-duplicates
+    <<: *lf_info_vote_verify
+
+    scm:
+      - lf-infra-gerrit-scm:
+          branch: '$GERRIT_BRANCH'
+          jenkins-ssh-credential: '{jenkins-ssh-credential}'
+          git-url: '{git-url}'
+          refspec: '$GERRIT_REFSPEC'
+          submodule-recursive: '{submodule-recursive}'
+          submodule-timeout: '{submodule-timeout}'
+          choosing-strategy: gerrit
+
+    triggers:
+      - gerrit:
+          server-name: '{gerrit-server-name}'
+          trigger-on: '{obj:gerrit_verify_triggers}'
+          projects:
+            - project-compare-type: 'REG_EXP'
+              project-pattern: '**'
+              branches:
+                - branch-compare-type: 'ANT'
+                  branch-pattern: '**/master'
+              file-paths: '{obj:gerrit_trigger_file_paths}'
+          skip-vote:
+            successful: '{gerrit-skip-vote}'
+            failed: '{gerrit-skip-vote}'
+            unstable: '{gerrit-skip-vote}'
+            notbuilt: '{gerrit-skip-vote}'
index 6b3faa8..58c5c50 100644 (file)
       - shell: !include-raw-escape: ../shell/tox-install.sh
       - shell: !include-raw-escape: ../shell/rtd-verify.sh
 
+- builder:
+    name: check-info-votes
+    builders:
+      - inject:
+          properties-content: JENKINS_SSH_CREDENTIAL={jenkins-ssh-credential}
+      - shell: !include-raw-escape: ../shell/check-info-votes.sh
+
 - builder:
     name: lf-sigul-sign-dir
     # Requires that Jenkins be configured with SIGUL_BRIDGE_IP as a global
diff --git a/releasenotes/notes/lf-info-vote-74329a41dfea62be.yaml b/releasenotes/notes/lf-info-vote-74329a41dfea62be.yaml
new file mode 100644 (file)
index 0000000..e94e31d
--- /dev/null
@@ -0,0 +1,7 @@
+---
+features:
+  - |
+    New ``info-vote-verify`` macro
+    Will count votes against an INFO.yaml change and sumbit
+    automatically if a majority of committers and tsc mebers
+    vote +1 or +2 on the change.
diff --git a/shell/check-info-votes.sh b/shell/check-info-votes.sh
new file mode 100644 (file)
index 0000000..892dd89
--- /dev/null
@@ -0,0 +1,49 @@
+#!/bin/bash -l
+# SPDX-License-Identifier: EPL-1.0
+##############################################################################
+# Copyright (c) 2019 The Linux Foundation and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+##############################################################################
+echo "---> check-info-votes.sh"
+set -xe -o pipefail
+
+ref=$(echo "$GERRIT_REFSPEC" | awk -F"/" '{ print $4 }')
+pip="pip3"
+
+# For OPNFV
+if [[ $NODE_NAME =~ "lf-build" ]]; then
+  pip=pip
+fi
+
+if [ -d "/opt/pyenv" ]; then
+  echo "---> Setting up pyenv"
+  export PYENV_ROOT="/opt/pyenv"
+  export PATH="$PYENV_ROOT/bin:$PATH"
+  PYTHONPATH=$(pwd)
+  export PYTHONPATH
+  pyenv local 3.6.4
+  export PYENV_VERSION="3.6.4"
+fi
+
+$pip install --user niet
+$pip install --user lftools
+$pip install --user lftools[nexus]
+$pip install --user jsonschema
+
+change="$(echo "$GERRIT_CHANGE_URL" | awk -F"/" '{print $NF}')"
+echo "Checking votes:"
+lftools infofile check-votes INFO.yaml "$GERRIT_URL" "$ref" > gerrit_comment.txt
+exit_status="$?"
+
+if [[ "$exit_status" -ne 0 ]]; then
+  echo "Vote not yet complete"
+  cat gerrit_comment.txt
+  exit "$exit_status"
+else
+  echo "Vote completed submitting review"
+  ssh -p "$GERRIT_PORT" "$JENKINS_SSH_CREDENTIAL"@"$GERRIT_HOST" gerrit review "$change" --submit
+fi