From: Bartek Grzybowski Date: Fri, 7 Feb 2020 14:10:03 +0000 (+0100) Subject: Setup Vagrantfiles validation in integration repo X-Git-Url: https://gerrit.onap.org/r/gitweb?a=commitdiff_plain;h=2dd0554f31f749e53e4eabab8a421721448e45a7;p=ci-management.git Setup Vagrantfiles validation in integration repo Relevant job template definition is added, verification script, builder definition to setup CI minion and integration-verify-vagrantfile job definition. Change-Id: I8b0385cb5aa6cef40f6566bec49f4e332be6f9f0 Signed-off-by: Bartek Grzybowski Issue-ID: INT-1434 --- diff --git a/jjb/integration/integration-macros.yaml b/jjb/integration/integration-macros.yaml index 23eaae6eb..677e7e0bd 100644 --- a/jjb/integration/integration-macros.yaml +++ b/jjb/integration/integration-macros.yaml @@ -53,6 +53,19 @@ builders: - shell: "${WORKSPACE}/autorelease/scripts/set-version.sh" +- builder: + name: integration-install-vagrant + builders: + - shell: | + #!/bin/bash + set -ex # Fail build if any setup step fails + add-apt-repository --yes ppa:tiagohillebrandt/vagrant + apt update + apt --yes install libxslt-dev libxml2-dev libvirt-dev zlib1g-dev ruby-dev vagrant + vagrant plugin install vagrant-libvirt + vagrant plugin install vagrant-disksize + mkdir -p ~/.ssh + - publisher: name: integration-robot publishers: diff --git a/jjb/integration/integration-templates.yaml b/jjb/integration/integration-templates.yaml new file mode 100644 index 000000000..5d07b31e3 --- /dev/null +++ b/jjb/integration/integration-templates.yaml @@ -0,0 +1,45 @@ +--- +- job-template: + # Job template for verifying Vagrantfiles + # + # The purpose of this job template is to run: + # vagrant validate + + name: '{project-name}-{stream}-verify-vagrantfile' + project-type: freestyle + description: 'Job intended for validating vagrantfiles' + node: 'ubuntu1604-builder-2c-1g.cfg' + + parameters: + - lf-infra-parameters: + project: '{project}' + stream: '{stream}' + branch: '{branch}' + + properties: + - infra-properties: + build-days-to-keep: '{build-days-to-keep}' + + scm: + - gerrit-trigger-scm: + refspec: '$GERRIT_REFSPEC' + choosing-strategy: 'gerrit' + submodule-recursive: '{submodule-recursive}' + + wrappers: + - infra-wrappers: + build-timeout: '{build-timeout}' + + triggers: + - gerrit-trigger-patch-submitted: + server: '{server-name}' + project: '{project}' + branch: '{branch}' + files: '**/Vagrantfile' + + builders: + - integration-install-vagrant + - shell: !include-raw-escape: 'vagrantfile-verify.sh' + + publishers: + - lf-infra-publish diff --git a/jjb/integration/integration.yaml b/jjb/integration/integration.yaml index 2bb525c82..31bda6ebd 100644 --- a/jjb/integration/integration.yaml +++ b/jjb/integration/integration.yaml @@ -31,3 +31,15 @@ pattern: 'test/vcpe/**' jobs: - '{project-name}-{stream}-{subproject}-verify-python' + +- project: + name: integration-verify-vagrantfile + project-name: 'integration' + project: 'integration' + + stream: + - 'master': + branch: 'master' + + jobs: + - '{project-name}-{stream}-verify-vagrantfile' diff --git a/jjb/integration/vagrantfile-verify.sh b/jjb/integration/vagrantfile-verify.sh new file mode 100644 index 000000000..6af0a9d03 --- /dev/null +++ b/jjb/integration/vagrantfile-verify.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +# Copyright 2020 Samsung Electronics Co., Ltd. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# 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. + +echo "---> vagrantfile-verify.sh" + +set -e + +declare -a CHANGED_VAGRANTFILES +CMD='vagrant validate' + +CHANGED_VAGRANTFILES=(`git diff HEAD^ HEAD --name-only "*Vagrantfile"`) + +for v_dir in ${CHANGED_VAGRANTFILES[@]}; +do + echo "---> Validating ./$v_dir" + pushd $(dirname $v_dir) + eval "$CMD" + popd +done