diff --git a/doc/source/helm-jobs.rst b/doc/source/helm-jobs.rst index 7214ab12a..9cfbad1ff 100644 --- a/doc/source/helm-jobs.rst +++ b/doc/source/helm-jobs.rst @@ -2,4 +2,5 @@ Helm Jobs ========= .. zuul:autojob:: apply-helm-charts -.. zuul:autojob:: chart-testing-lint \ No newline at end of file +.. zuul:autojob:: chart-testing-lint +.. zuul:autojob:: helm-lint diff --git a/doc/source/helm-roles.rst b/doc/source/helm-roles.rst index 0066faf7c..f87fb2444 100644 --- a/doc/source/helm-roles.rst +++ b/doc/source/helm-roles.rst @@ -5,3 +5,4 @@ Helm Roles .. zuul:autorole:: ensure-chart-testing .. zuul:autorole:: chart-testing .. zuul:autorole:: helm-template +.. zuul:autorole:: helm-lint diff --git a/playbooks/helm-lint/pre.yaml b/playbooks/helm-lint/pre.yaml new file mode 100644 index 000000000..764fb7f2d --- /dev/null +++ b/playbooks/helm-lint/pre.yaml @@ -0,0 +1,3 @@ +- hosts: all + roles: + - role: ensure-helm diff --git a/playbooks/helm-lint/run.yaml b/playbooks/helm-lint/run.yaml new file mode 100644 index 000000000..517568786 --- /dev/null +++ b/playbooks/helm-lint/run.yaml @@ -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' diff --git a/roles/helm-lint/README.rst b/roles/helm-lint/README.rst new file mode 100644 index 000000000..a668f9ae3 --- /dev/null +++ b/roles/helm-lint/README.rst @@ -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. diff --git a/roles/helm-lint/defaults/main.yaml b/roles/helm-lint/defaults/main.yaml new file mode 100644 index 000000000..9739eb171 --- /dev/null +++ b/roles/helm-lint/defaults/main.yaml @@ -0,0 +1 @@ +zuul_work_dir: "{{ zuul.project.src_dir }}" diff --git a/roles/helm-lint/tasks/main.yaml b/roles/helm-lint/tasks/main.yaml new file mode 100644 index 000000000..2e9484d3b --- /dev/null +++ b/roles/helm-lint/tasks/main.yaml @@ -0,0 +1,4 @@ +- name: Run lint + command: "helm lint {{ helm_chart }}" + args: + chdir: "{{ zuul_work_dir }}" diff --git a/test-playbooks/helm-lint/create-helm-chart.yaml b/test-playbooks/helm-lint/create-helm-chart.yaml new file mode 100644 index 000000000..5c98ec124 --- /dev/null +++ b/test-playbooks/helm-lint/create-helm-chart.yaml @@ -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 }}" diff --git a/zuul-tests.d/helm-jobs.yaml b/zuul-tests.d/helm-jobs.yaml new file mode 100644 index 000000000..53ee3709c --- /dev/null +++ b/zuul-tests.d/helm-jobs.yaml @@ -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 diff --git a/zuul.d/helm-jobs.yaml b/zuul.d/helm-jobs.yaml index c39e145c1..7bef89330 100644 --- a/zuul.d/helm-jobs.yaml +++ b/zuul.d/helm-jobs.yaml @@ -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