Setup Vagrantfiles validation in integration repo 82/101382/2
authorBartek Grzybowski <b.grzybowski@partner.samsung.com>
Fri, 7 Feb 2020 14:10:03 +0000 (15:10 +0100)
committerBartek Grzybowski <b.grzybowski@partner.samsung.com>
Fri, 7 Feb 2020 14:27:50 +0000 (15:27 +0100)
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 <b.grzybowski@partner.samsung.com>
Issue-ID: INT-1434

jjb/integration/integration-macros.yaml
jjb/integration/integration-templates.yaml [new file with mode: 0644]
jjb/integration/integration.yaml
jjb/integration/vagrantfile-verify.sh [new file with mode: 0644]

index 23eaae6..677e7e0 100644 (file)
     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 (file)
index 0000000..5d07b31
--- /dev/null
@@ -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
index 2bb525c..31bda6e 100644 (file)
           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 (file)
index 0000000..6af0a9d
--- /dev/null
@@ -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