helm: Add job for linting helm charts

This job runs 'helm lint' on the user specified charts.

Change-Id: Ie6f39bab366b683e773add181de516c3ac913866
This commit is contained in:
Michael Kelly 2022-10-18 13:39:43 -07:00
parent 622baa65bf
commit b0cc01ceac
No known key found for this signature in database
GPG Key ID: 77F7FE93040ECF3E
10 changed files with 181 additions and 1 deletions

View File

@ -3,3 +3,4 @@ Helm Jobs
.. zuul:autojob:: apply-helm-charts
.. zuul:autojob:: chart-testing-lint
.. zuul:autojob:: helm-lint

View File

@ -5,3 +5,4 @@ Helm Roles
.. zuul:autorole:: ensure-chart-testing
.. zuul:autorole:: chart-testing
.. zuul:autorole:: helm-template
.. zuul:autorole:: helm-lint

View File

@ -0,0 +1,3 @@
- hosts: all
roles:
- role: ensure-helm

View File

@ -0,0 +1,10 @@
- hosts: all
tasks:
- name: Lint helm charts
include_role:
name: helm-lint
vars:
helm_chart: "{{ zj_item }}"
loop: "{{ helm_charts }}"
loop_control:
loop_var: 'zj_item'

View File

@ -0,0 +1,13 @@
Run Helm lint on a chart to verify correctness. It assumes that the Helm
executable is installed.
**Role Variables**
.. zuul:rolevar:: helm_chart
Directory of the Helm chart.
.. zuul:rolevar:: zuul_work_dir
:default: {{ zuul.project.src_dir }}
Directory in which to run helm.

View File

@ -0,0 +1 @@
zuul_work_dir: "{{ zuul.project.src_dir }}"

View File

@ -0,0 +1,4 @@
- name: Run lint
command: "helm lint {{ helm_chart }}"
args:
chdir: "{{ zuul_work_dir }}"

View File

@ -0,0 +1,9 @@
- hosts: all
roles:
- role: ensure-helm
tasks:
- name: Create helm chart
shell: |
helm create test-chart
args:
chdir: "{{ zuul.project.src_dir }}"

131
zuul-tests.d/helm-jobs.yaml Normal file
View File

@ -0,0 +1,131 @@
- job:
name: zuul-jobs-test-helm-lint
description: Test the helm-lint job
parent: helm-lint
tags: all-platforms
files:
- playbooks/helm-lint/.*
- roles/helm-lint/.*
- roles/ensure-helm/.*
pre-run: test-playbooks/helm-lint/create-helm-chart.yaml
vars:
helm_version: 3.10.1
helm_charts: [test-chart]
- job:
name: zuul-jobs-test-helm-lint-centos-7
description: Test the helm-lint job on centos-7
parent: zuul-jobs-test-helm-lint
tags: auto-generated
nodeset:
nodes:
- name: centos-7
label: centos-7
- job:
name: zuul-jobs-test-helm-lint-centos-8-stream
description: Test the helm-lint job on centos-8-stream
parent: zuul-jobs-test-helm-lint
tags: auto-generated
nodeset:
nodes:
- name: centos-8-stream
label: centos-8-stream
- job:
name: zuul-jobs-test-helm-lint-centos-9-stream
description: Test the helm-lint job on centos-9-stream
parent: zuul-jobs-test-helm-lint
tags: auto-generated
nodeset:
nodes:
- name: centos-9-stream
label: centos-9-stream
- job:
name: zuul-jobs-test-helm-lint-debian-bullseye
description: Test the helm-lint job on debian-bullseye
parent: zuul-jobs-test-helm-lint
tags: auto-generated
nodeset:
nodes:
- name: debian-bullseye
label: debian-bullseye
- job:
name: zuul-jobs-test-helm-lint-debian-buster
description: Test the helm-lint job on debian-buster
parent: zuul-jobs-test-helm-lint
tags: auto-generated
nodeset:
nodes:
- name: debian-buster
label: debian-buster
- job:
name: zuul-jobs-test-helm-lint-fedora-36
description: Test the helm-lint job on fedora-36
parent: zuul-jobs-test-helm-lint
tags: auto-generated
nodeset:
nodes:
- name: fedora-36
label: fedora-36
- job:
name: zuul-jobs-test-helm-lint-opensuse-15
description: Test the helm-lint job on opensuse-15
parent: zuul-jobs-test-helm-lint
tags: auto-generated
nodeset:
nodes:
- name: opensuse-15
label: opensuse-15
- job:
name: zuul-jobs-test-helm-lint-ubuntu-bionic
description: Test the helm-lint job on ubuntu-bionic
parent: zuul-jobs-test-helm-lint
tags: auto-generated
nodeset:
nodes:
- name: ubuntu-bionic
label: ubuntu-bionic
- job:
name: zuul-jobs-test-helm-lint-ubuntu-focal
description: Test the helm-lint job on ubuntu-focal
parent: zuul-jobs-test-helm-lint
tags: auto-generated
nodeset:
nodes:
- name: ubuntu-focal
label: ubuntu-focal
- job:
name: zuul-jobs-test-helm-lint-ubuntu-jammy
description: Test the helm-lint job on ubuntu-jammy
parent: zuul-jobs-test-helm-lint
tags: auto-generated
nodeset:
nodes:
- name: ubuntu-jammy
label: ubuntu-jammy
- project:
check:
jobs: &id001
- zuul-jobs-test-helm-lint-centos-7
- zuul-jobs-test-helm-lint-centos-8-stream
- zuul-jobs-test-helm-lint-centos-9-stream
- zuul-jobs-test-helm-lint-debian-bullseye
- zuul-jobs-test-helm-lint-debian-buster
- zuul-jobs-test-helm-lint-fedora-36
- zuul-jobs-test-helm-lint-opensuse-15
- zuul-jobs-test-helm-lint-ubuntu-bionic
- zuul-jobs-test-helm-lint-ubuntu-focal
- zuul-jobs-test-helm-lint-ubuntu-jammy
gate:
jobs: *id001
periodic-weekly:
jobs: *id001

View File

@ -12,3 +12,10 @@
pre-run: playbooks/helm/pre.yaml
run: playbooks/helm/run.yaml
post-run: playbooks/helm/post.yaml
- job:
name: helm-lint
description: |
Run helm lint on a Helm chart
pre-run: playbooks/helm-lint/pre.yaml
run: playbooks/helm-lint/run.yaml