From 5d70c0ec8f4a53e9fc42db39c2ed895263e57e9f Mon Sep 17 00:00:00 2001 From: Tin Lam Date: Mon, 6 Nov 2017 18:26:49 -0600 Subject: [PATCH] Gate: Add linter gate and path options to OSH-Infra This patch set adds a zuul v3 trailing whitespace linter gate to the OSH-infra repository. It additionally updates the work_dir path to account for being launched as a dependant project in zuulv3. Change-Id: I680a5942f008a6246641bebca7d9880a7824f2ce --- .zuul.yaml | 15 ++++++++ .../build-images/tasks/kubeadm-aio.yaml | 35 +++++++++++-------- tools/gate/playbooks/zuul-linter.yaml | 20 +++++++++++ tools/gate/playbooks/zuul-pre.yaml | 10 +++--- tools/gate/playbooks/zuul-run.yaml | 8 ++--- 5 files changed, 65 insertions(+), 23 deletions(-) create mode 100644 tools/gate/playbooks/zuul-linter.yaml diff --git a/.zuul.yaml b/.zuul.yaml index e4b558d2d..47b11256e 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -16,6 +16,8 @@ name: openstack/openstack-helm-infra check: jobs: + - openstack-helm-infra-linter: + voting: true - openstack-helm-infra-ubuntu: voting: true - openstack-helm-infra-centos: @@ -24,8 +26,15 @@ voting: false gate: jobs: + - openstack-helm-infra-linter - openstack-helm-infra-ubuntu +- nodeset: + name: openstack-helm-single-node + nodes: + - name: primary + label: ubuntu-xenial + - nodeset: name: openstack-helm-ubuntu nodes: @@ -79,6 +88,12 @@ nodes: - node-1 - node-2 + +- job: + name: openstack-helm-infra-linter + run: tools/gate/playbooks/zuul-linter.yaml + nodeset: openstack-helm-single-node + - job: name: openstack-helm-infra-ubuntu pre-run: tools/gate/playbooks/zuul-pre.yaml diff --git a/tools/gate/playbooks/build-images/tasks/kubeadm-aio.yaml b/tools/gate/playbooks/build-images/tasks/kubeadm-aio.yaml index c7e4257af..b6b0f9439 100644 --- a/tools/gate/playbooks/build-images/tasks/kubeadm-aio.yaml +++ b/tools/gate/playbooks/build-images/tasks/kubeadm-aio.yaml @@ -12,17 +12,24 @@ # See the License for the specific language governing permissions and # limitations under the License. -- name: build the Kubeadm-AIO image - docker_image: - path: "{{ work_dir }}/" - name: "{{ images.kubernetes.kubeadm_aio }}" - dockerfile: "tools/images/kubeadm-aio/Dockerfile" - force: yes - pull: yes - state: present - rm: yes - buildargs: - KUBE_VERSION: "{{ version.kubernetes }}" - CNI_VERSION: "{{ version.cni }}" - HELM_VERSION: "{{ version.helm }}" - CHARTS: "calico,flannel,tiller,kube-dns" +- name: Kubeadm-AIO build + block: + #NOTE(portdirect): we do this to ensure we are feeding the docker build + # a clean path to work with. + - name: Kubeadm-AIO image build path + shell: cd "{{ work_dir }}"; pwd + register: kubeadm_aio_path + - name: build the Kubeadm-AIO image + docker_image: + path: "{{ kubeadm_aio_path.stdout }}/" + name: "{{ images.kubernetes.kubeadm_aio }}" + dockerfile: "tools/images/kubeadm-aio/Dockerfile" + force: yes + pull: yes + state: present + rm: yes + buildargs: + KUBE_VERSION: "{{ version.kubernetes }}" + CNI_VERSION: "{{ version.cni }}" + HELM_VERSION: "{{ version.helm }}" + CHARTS: "calico,flannel,tiller,kube-dns" diff --git a/tools/gate/playbooks/zuul-linter.yaml b/tools/gate/playbooks/zuul-linter.yaml new file mode 100644 index 000000000..ec0f7ea73 --- /dev/null +++ b/tools/gate/playbooks/zuul-linter.yaml @@ -0,0 +1,20 @@ +# Copyright 2017 The Openstack-Helm Authors. +# +# 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. + +- hosts: primary + tasks: + - name: Execute a Whitespace Linter check + command: find . -not -path "*/\.*" -not -path "*/doc/build/*" -not -name "*.tgz" -type f -exec egrep -l " +$" {} \; + register: result + failed_when: result.stdout != "" diff --git a/tools/gate/playbooks/zuul-pre.yaml b/tools/gate/playbooks/zuul-pre.yaml index 76c7b46cf..8c7b5ee9e 100644 --- a/tools/gate/playbooks/zuul-pre.yaml +++ b/tools/gate/playbooks/zuul-pre.yaml @@ -16,7 +16,7 @@ vars_files: - vars.yaml vars: - work_dir: "{{ zuul.project.src_dir }}" + work_dir: "{{ zuul.project.src_dir }}/{{ zuul_osh_infra_relative_path | default('') }}" gather_facts: False become: yes roles: @@ -28,7 +28,7 @@ vars_files: - vars.yaml vars: - work_dir: "{{ zuul.project.src_dir }}" + work_dir: "{{ zuul.project.src_dir }}/{{ zuul_osh_infra_relative_path | default('') }}" gather_facts: True roles: - build-helm-packages @@ -39,7 +39,7 @@ vars_files: - vars.yaml vars: - work_dir: "{{ zuul.project.src_dir }}" + work_dir: "{{ zuul.project.src_dir }}/{{ zuul_osh_infra_relative_path | default('') }}" gather_facts: True become: yes roles: @@ -57,7 +57,7 @@ vars_files: - vars.yaml vars: - work_dir: "{{ zuul.project.src_dir }}" + work_dir: "{{ zuul.project.src_dir }}/{{ zuul_osh_infra_relative_path | default('') }}" gather_facts: False become: yes roles: @@ -69,7 +69,7 @@ vars_files: - vars.yaml vars: - work_dir: "{{ zuul.project.src_dir }}" + work_dir: "{{ zuul.project.src_dir }}/{{ zuul_osh_infra_relative_path | default('') }}" gather_facts: True roles: - pull-images diff --git a/tools/gate/playbooks/zuul-run.yaml b/tools/gate/playbooks/zuul-run.yaml index 46abb99a2..d301fa03d 100644 --- a/tools/gate/playbooks/zuul-run.yaml +++ b/tools/gate/playbooks/zuul-run.yaml @@ -16,7 +16,7 @@ vars_files: - vars.yaml vars: - work_dir: "{{ zuul.project.src_dir }}" + work_dir: "{{ zuul.project.src_dir }}/{{ zuul_osh_infra_relative_path | default('') }}" roles: - clean-host tags: @@ -26,7 +26,7 @@ vars_files: - vars.yaml vars: - work_dir: "{{ zuul.project.src_dir }}" + work_dir: "{{ zuul.project.src_dir }}/{{ zuul_osh_infra_relative_path | default('') }}" roles: - deploy-kubeadm-aio-master tags: @@ -36,7 +36,7 @@ vars_files: - vars.yaml vars: - work_dir: "{{ zuul.project.src_dir }}" + work_dir: "{{ zuul.project.src_dir }}/{{ zuul_osh_infra_relative_path | default('') }}" roles: - deploy-kubeadm-aio-node tags: @@ -46,7 +46,7 @@ vars_files: - vars.yaml vars: - work_dir: "{{ zuul.project.src_dir }}" + work_dir: "{{ zuul.project.src_dir }}/{{ zuul_osh_infra_relative_path | default('') }}" roles: - deploy-helm-packages tags: