diff --git a/doc/source/helm-roles.rst b/doc/source/helm-roles.rst index d7d7a11ba..107681c93 100644 --- a/doc/source/helm-roles.rst +++ b/doc/source/helm-roles.rst @@ -3,3 +3,4 @@ Helm Roles .. zuul:autorole:: ensure-helm .. zuul:autorole:: ensure-chart-testing +.. zuul:autorole:: chart-testing diff --git a/playbooks/chart-testing/run.yaml b/playbooks/chart-testing/run.yaml index 30a85425e..a544a2726 100644 --- a/playbooks/chart-testing/run.yaml +++ b/playbooks/chart-testing/run.yaml @@ -1,10 +1,4 @@ --- - 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 }}" + roles: + - chart-testing diff --git a/roles/chart-testing/README.rst b/roles/chart-testing/README.rst new file mode 100644 index 000000000..087776bc0 --- /dev/null +++ b/roles/chart-testing/README.rst @@ -0,0 +1,19 @@ +Run chart-testing (for helm charts) + +**Role Variables** + +.. zuul:rolevar:: zuul_work_dir + :default: {{ zuul.project.src_dir }} + + The location of the main working directory of the job. + +.. zuul:rolevar:: chart_testing_options + :default: --validate-maintainers=false --check-version-increment=false + + Arguments passed to chart testing. + + The defaults are suitable for a Zuul environment because + `validate-maintainers` requires a valid git remote (which is not + present in Zuul) and `check-version-increment` requires each commit + to have a new version; Zuul users are expected to set the version + when tagging/publishing a release. diff --git a/roles/chart-testing/defaults/main.yaml b/roles/chart-testing/defaults/main.yaml new file mode 100644 index 000000000..ae1ea85c7 --- /dev/null +++ b/roles/chart-testing/defaults/main.yaml @@ -0,0 +1,2 @@ +zuul_work_dir: "{{ zuul.project.src_dir }}" +chart_testing_options: --validate-maintainers=false --check-version-increment=false diff --git a/roles/chart-testing/tasks/main.yaml b/roles/chart-testing/tasks/main.yaml new file mode 100644 index 000000000..df33d3cda --- /dev/null +++ b/roles/chart-testing/tasks/main.yaml @@ -0,0 +1,4 @@ +- name: Run chart-testing + command: "ct lint {{ chart_testing_options }}" + args: + chdir: "{{ zuul_work_dir }}"