Skip to content

ci: add helm chart-testing and unittest workflow#2427

Open
giuliocalzo wants to merge 1 commit intoNVIDIA:mainfrom
giuliocalzo:ci/helm-chart-testing
Open

ci: add helm chart-testing and unittest workflow#2427
giuliocalzo wants to merge 1 commit intoNVIDIA:mainfrom
giuliocalzo:ci/helm-chart-testing

Conversation

@giuliocalzo
Copy link
Copy Markdown

Overview

Add a helm GitHub Actions workflow that runs ct lint and helm-unittest against the gpu-operator chart on PRs that touch deployments/, plus a unit-test suite (with snapshots) covering the chart's core templates.

Why helm unittest?

The gpu-operator chart is the primary install surface for the operator and ships a large set of templates whose behavior depends heavily on values.yaml, conditional logic, and platform-specific branches (OpenShift, MIG, NRI/CDI, etc.). Today, regressions in those templates can only be caught by spinning up a cluster, which is slow and not part of every PR.

helm-unittest makes it cheap to lock that behavior down in CI:

  • Fast, hermetic feedback. Runs helm template in-process under a few hundred milliseconds, with no cluster, no network, no real Kubernetes API. Suitable for every PR.
  • Catches templating regressions early. Snapshot tests on rendered manifests fail loudly on unintended diffs (e.g. accidental image bumps, removed args, changed RBAC verbs, broken priorityClassName handling).
  • Documents values.yaml contracts. Each set: block is an executable example of a supported configuration (develMode, imagePullSecrets, custom DCGM/MIG/device-plugin configs, NRI + CDI validation, etc.), so the expected behavior of values is visible in the repo.
  • Validates failure paths too. failedTemplate assertions confirm that input validations (e.g. "the NRI Plugin cannot be enabled when CDI is disabled") actually fire, which ct lint alone does not exercise.
  • Cheap to maintain. Snapshots regenerate with helm unittest -u, so intentional template changes are an explicit, reviewable diff in the PR.

What's included

  • New workflow .github/workflows/helm.yaml with two jobs:
    • linthelm/chart-testing-action (ct lint) against the chart.
    • unittest — installs helm-unittest and runs helm unittest deployments/gpu-operator.
    • Triggered only on PRs that change deployments/gpu-operator/**.
  • New helm-unittest suites under deployments/gpu-operator/tests/ covering: operator deployment, ClusterPolicy, ClusterRole/Binding, Role/Binding, ServiceAccount, NodeFeatureRules, NvidiaDriver, MIG/DCGM/device-plugin custom configs, cleanup and upgrade CRD hooks, OpenShift readonly-fs SCC, extra objects, and input validations. Snapshots are committed under __snapshot__/.

Testing

  • helm unittest deployments/gpu-operator passes locally — 17 suites, 62 tests, 24 snapshots.
  • CI helm / lint and helm / unittest jobs are expected to be green on this PR.

Adds a `helm` GitHub Actions workflow that runs `ct lint` and
`helm-unittest` against the gpu-operator chart on PRs that touch
`deployments/`, plus a unit-test suite (with snapshots) covering the
chart's core templates so chart regressions are caught in CI.

Workflow:
- `lint` job runs `ct lint` (with `--validate-maintainers=false` since
  the chart doesn't declare maintainers) using `CHART_DIR=deployments`.
- `unittest` job installs `helm-unittest v1.0.3` and runs
  `helm unittest deployments/gpu-operator`.
- Triggers only on PRs that change `deployments/gpu-operator/**`.

Tests cover: operator deployment, ClusterPolicy, RBAC, NodeFeatureRules,
NvidiaDriver, MIG/DCGM/device-plugin custom configs, cleanup and upgrade
CRD hooks, OpenShift readonly-fs SCC, extra objects, and input
validations. Snapshots are committed under `__snapshot__/`.

Also:
- Fix yamllint comment-spacing in `values.yaml` so `ct lint` passes.
- Add `tests/` to `.helmignore` so unittest fixtures and snapshots are
  excluded from the packaged chart.

Signed-off-by: Giulio Calzolari <gcalzolari@nvidia.com>
@giuliocalzo giuliocalzo force-pushed the ci/helm-chart-testing branch from a626e1a to 3e8fa1c Compare May 5, 2026 17:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant