Add helm component: pre-commit hooks, test and publish templates, image

⚠️🤖 This MR has been automatically generated

  • It has been reviewed by the assignee

What does this MR do and why?

Adds the helm CI component, meant to replace ci-templates/templates/helm-tooling.yml and the helm-toolbox image in all the repositories hosting Helm charts. As much as possible is done in pre-commit.

Pre-commit hooks

Both run in the image built from this repository (language: docker_image), so consumers include the pre-commit component with docker: true:

  • helm-lint: helm dependency update + helm lint, one hook per chart — the checks run in the repository, not in a CI job.
  • helm-schema-convert: converts every values.schema.yaml to the values.schema.json next to it with yq (the generated file is excluded from pretty-format-json in consumer repositories). The component dogfoods them: its own pre-commit configuration builds the local image and runs both hooks on its fixtures.

CI templates

  • test: helm unittest with a JUnit report, --parallel by default. One include per chart; library charts are detected and handled; fails if the chart has no test suite.
  • publish: the only way to publish charts: automatic base channel on tags, manual devel publication on merge requests.
  • Both default to stage ordering. The test job runs whenever the component is included (decide in which pipelines it exists with the rules of the importing include — as this component does for its own tests); publish keeps its rules above.

Self-tests and release flow

The component tests its own templates on its fixtures (.gitlab/ci/tests/): changes-gated on merge request pipelines, always included on protected branch pipelines — where the release runs — and never on tag pipelines, which only build the image of the release. All the tests therefore pass before the release job runs in the deploy stage.

The release is made by the semantic-release component with its commit-back support: the release commit rewrites the hook image tag and carries [skip ci on branch], so only the tag pipeline runs, building the release image — the hook entry always references the image matching its rev.

Open questions

  • Should the helm-lint hook fail when the rendering of the chart hits fail or required calls? helm lint only logs them (even with --strict): a chart that cannot render with the linted values passes the hook. The catch looks feasible in sylva-helm-lint — not implemented here.
Details of the possible catch

helm lint logs the render failures to stderr as [INFO] Fail: <message> / [INFO] Missing required value: <message> (verified with helm 3.16) while exiting 0, even with --strict. sylva-helm-lint could capture the lint stderr and fail when those lines are present, with a negative self-test (a fixture chart calling fail). That would cover the values the chart is linted with only: renderings under other value combinations stay the job of the unittest suites.

Validation traces
  • Release flow validated end to end on a throwaway project: release commit on main with [skip ci on branch] (no branch pipeline), tag pipeline building the image and rewriting the hook entry.
  • Both self-tests run on the pipelines of this MR (the publish self-test publishes the fixture to the disposable devel channel).

Check the following "consumer MRs:

Edited by Jonathan GAYVALLET

Merge request reports

Loading
Loading