diff --git a/doc/source/helm-jobs.rst b/doc/source/helm-jobs.rst new file mode 100644 index 000000000..4c951afd2 --- /dev/null +++ b/doc/source/helm-jobs.rst @@ -0,0 +1,4 @@ +Helm Jobs +========= + +.. zuul:autojob:: chart-testing-lint diff --git a/doc/source/helm-roles.rst b/doc/source/helm-roles.rst new file mode 100644 index 000000000..d7d7a11ba --- /dev/null +++ b/doc/source/helm-roles.rst @@ -0,0 +1,5 @@ +Helm Roles +========== + +.. zuul:autorole:: ensure-helm +.. zuul:autorole:: ensure-chart-testing diff --git a/doc/source/jobs.rst b/doc/source/jobs.rst index a02137301..073ba5325 100644 --- a/doc/source/jobs.rst +++ b/doc/source/jobs.rst @@ -9,3 +9,4 @@ Jobs js-jobs docker-jobs go-jobs + helm-jobs diff --git a/doc/source/roles.rst b/doc/source/roles.rst index 6c8f9c096..5efe2388f 100644 --- a/doc/source/roles.rst +++ b/doc/source/roles.rst @@ -17,3 +17,4 @@ Roles puppet-roles python-roles translation-roles + helm-roles diff --git a/playbooks/chart-testing/pre.yaml b/playbooks/chart-testing/pre.yaml new file mode 100644 index 000000000..2a8a6b68d --- /dev/null +++ b/playbooks/chart-testing/pre.yaml @@ -0,0 +1,5 @@ +--- +- hosts: all + roles: + - ensure-helm + - ensure-chart-testing \ No newline at end of file diff --git a/playbooks/chart-testing/run.yaml b/playbooks/chart-testing/run.yaml new file mode 100644 index 000000000..30a85425e --- /dev/null +++ b/playbooks/chart-testing/run.yaml @@ -0,0 +1,10 @@ +--- +- hosts: all + tasks: + - name: Run linters + # NOTE(mnaser): We use --validate-maintainers=false because chart-testing + # relies on the existance of a remote URL which is /dev/null + # in Zuul and fails. + command: ct lint --validate-maintainers=false + args: + chdir: "{{ zuul.project.src_dir }}" diff --git a/roles/ensure-chart-testing/README.rst b/roles/ensure-chart-testing/README.rst new file mode 100644 index 000000000..60d0720b8 --- /dev/null +++ b/roles/ensure-chart-testing/README.rst @@ -0,0 +1,7 @@ +Ensure chart-testing is installed + +**Role Variables** + +.. zuul:rolevar:: chart_testing_version + + Version of chart-testing to install diff --git a/roles/ensure-chart-testing/defaults/main.yaml b/roles/ensure-chart-testing/defaults/main.yaml new file mode 100644 index 000000000..475c92b35 --- /dev/null +++ b/roles/ensure-chart-testing/defaults/main.yaml @@ -0,0 +1,2 @@ +--- +chart_testing_version: 2.4.0 \ No newline at end of file diff --git a/roles/ensure-chart-testing/tasks/main.yaml b/roles/ensure-chart-testing/tasks/main.yaml new file mode 100644 index 000000000..75a843c1b --- /dev/null +++ b/roles/ensure-chart-testing/tasks/main.yaml @@ -0,0 +1,29 @@ +--- +- name: Install Python dependencies + become: true + pip: + name: + - yamale==1.8.0 + - yamllint==1.13.0 + +- name: Install chart-testing + become: true + unarchive: + remote_src: true + src: "https://github.com/helm/chart-testing/releases/download/v{{ chart_testing_version }}/chart-testing_{{ chart_testing_version }}_linux_amd64.tar.gz" + dest: /usr/local/bin + +- name: Setup /etc/ct + become: true + file: + path: /etc/ct + state: directory + +- name: Install configuration files + become: true + get_url: + url: "https://raw.githubusercontent.com/helm/chart-testing/v{{ chart_testing_version }}/etc/{{ item }}" + dest: "/etc/ct/{{ item }}" + loop: + - chart_schema.yaml + - lintconf.yaml \ No newline at end of file diff --git a/roles/ensure-helm/README.rst b/roles/ensure-helm/README.rst new file mode 100644 index 000000000..cfb1889da --- /dev/null +++ b/roles/ensure-helm/README.rst @@ -0,0 +1,7 @@ +Ensure Helm is installed + +**Role Variables** + +.. zuul:rolevar:: helm_version + + Version of Helm to install diff --git a/roles/ensure-helm/defaults/main.yaml b/roles/ensure-helm/defaults/main.yaml new file mode 100644 index 000000000..e77eca783 --- /dev/null +++ b/roles/ensure-helm/defaults/main.yaml @@ -0,0 +1,2 @@ +--- +helm_version: 2.16.1 \ No newline at end of file diff --git a/roles/ensure-helm/tasks/main.yaml b/roles/ensure-helm/tasks/main.yaml new file mode 100644 index 000000000..b9c31a9e9 --- /dev/null +++ b/roles/ensure-helm/tasks/main.yaml @@ -0,0 +1,20 @@ +--- +- name: Download Helm + unarchive: + remote_src: true + src: "https://get.helm.sh/helm-v{{ helm_version }}-linux-amd64.tar.gz" + dest: /tmp + +- name: Install Helm + become: true + copy: + remote_src: true + src: /tmp/linux-amd64/helm + dest: /usr/local/bin/helm + mode: '0755' + +- name: Initialize Helm + shell: helm init --client-only + tags: + # NOTE(mnaser): The `helm` module does not support running init only. + - skip_ansible_lint \ No newline at end of file diff --git a/zuul.d/helm-jobs.yaml b/zuul.d/helm-jobs.yaml new file mode 100644 index 000000000..b146d6f45 --- /dev/null +++ b/zuul.d/helm-jobs.yaml @@ -0,0 +1,6 @@ +- job: + name: chart-testing-lint + description: | + Run chart-testing on Helm charts + pre-run: playbooks/chart-testing/pre.yaml + run: playbooks/chart-testing/run.yaml