From 0010308163a62fb231ebece5926b64d6b86c0901 Mon Sep 17 00:00:00 2001 From: Aric Gardner Date: Mon, 25 Mar 2019 16:35:34 -0400 Subject: [PATCH] INFO.yaml check vote for global-jjb 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 --- docs/jjb/lf-info-vote.rst | 25 +++++ docs/jjb/lf-macros.rst | 5 + jjb/lf-info-vote.yaml | 105 +++++++++++++++++++++ jjb/lf-macros.yaml | 7 ++ .../notes/lf-info-vote-74329a41dfea62be.yaml | 7 ++ shell/check-info-votes.sh | 49 ++++++++++ 6 files changed, 198 insertions(+) create mode 100644 docs/jjb/lf-info-vote.rst create mode 100644 jjb/lf-info-vote.yaml create mode 100644 releasenotes/notes/lf-info-vote-74329a41dfea62be.yaml create mode 100644 shell/check-info-votes.sh diff --git a/docs/jjb/lf-info-vote.rst b/docs/jjb/lf-info-vote.rst new file mode 100644 index 00000000..76c6d3de --- /dev/null +++ b/docs/jjb/lf-info-vote.rst @@ -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) diff --git a/docs/jjb/lf-macros.rst b/docs/jjb/lf-macros.rst index 94fcb1c5..d1efe476 100644 --- a/docs/jjb/lf-macros.rst +++ b/docs/jjb/lf-macros.rst @@ -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 index 00000000..012400f3 --- /dev/null +++ b/jjb/lf-info-vote.yaml @@ -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}' diff --git a/jjb/lf-macros.yaml b/jjb/lf-macros.yaml index 6b3faa85..58c5c506 100644 --- a/jjb/lf-macros.yaml +++ b/jjb/lf-macros.yaml @@ -255,6 +255,13 @@ - 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 index 00000000..e94e31d3 --- /dev/null +++ b/releasenotes/notes/lf-info-vote-74329a41dfea62be.yaml @@ -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 index 00000000..892dd899 --- /dev/null +++ b/shell/check-info-votes.sh @@ -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 -- 2.16.6