Skip to content

Commit 3e8fa1c

Browse files
committed
ci: add helm chart-testing and unittest workflow
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>
1 parent 55b277c commit 3e8fa1c

36 files changed

Lines changed: 2203 additions & 3 deletions

.github/workflows/helm.yaml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
---
2+
name: helm
3+
4+
on:
5+
pull_request:
6+
branches: [main]
7+
paths:
8+
- 'deployments/gpu-operator/**'
9+
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.ref }}
12+
cancel-in-progress: true
13+
14+
permissions:
15+
contents: read
16+
17+
env:
18+
CHART_NAME: gpu-operator
19+
CHART_DIR: deployments
20+
21+
jobs:
22+
lint:
23+
runs-on: ubuntu-latest
24+
steps:
25+
- name: Checkout repository
26+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
27+
28+
- name: Set up chart-testing
29+
uses: helm/chart-testing-action@6ec842c01de15ebb84c8627d2744a0c2f2755c9f # v2.8.0
30+
31+
- name: Run chart-testing (lint)
32+
run: |
33+
ct lint \
34+
--target-branch ${{ github.event.repository.default_branch }} \
35+
--all \
36+
--validate-maintainers=false \
37+
--chart-dirs ${{ env.CHART_DIR }}
38+
39+
unittest:
40+
runs-on: ubuntu-latest
41+
steps:
42+
- name: Checkout repository
43+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
44+
45+
- name: Set up Helm
46+
uses: azure/setup-helm@dda3372f752e03dde6b3237bc9431cdc2f7a02a2 # v5
47+
48+
- name: Install helm-unittest plugin
49+
run: |
50+
echo "Installing helm-unittest plugin..."
51+
helm plugin install https://github.com/helm-unittest/helm-unittest.git --verify=false --version v1.0.3 # 6f82a998e0b5461762ca959f87f5dd344af5e4eb
52+
53+
- name: Run helm unittest
54+
run: helm unittest ${{ env.CHART_DIR }}/${{ env.CHART_NAME }}

deployments/gpu-operator/.helmignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,5 @@
2020
.idea/
2121
*.tmproj
2222
.vscode/
23+
# helm unittest
24+
tests/
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
should match snapshot:
2+
1: |
3+
apiVersion: batch/v1
4+
kind: Job
5+
metadata:
6+
annotations:
7+
helm.sh/hook: pre-delete
8+
helm.sh/hook-delete-policy: hook-succeeded,before-hook-creation
9+
helm.sh/hook-weight: "1"
10+
labels:
11+
app.kubernetes.io/component: gpu-operator
12+
app.kubernetes.io/instance: gpu-operator
13+
app.kubernetes.io/managed-by: Helm
14+
app.kubernetes.io/name: gpu-operator
15+
app.kubernetes.io/version: v25.0.0
16+
helm.sh/chart: gpu-operator-v1.0.0-devel
17+
name: gpu-operator-cleanup-crd
18+
namespace: gpu-operator
19+
spec:
20+
template:
21+
metadata:
22+
labels:
23+
app.kubernetes.io/component: gpu-operator
24+
app.kubernetes.io/instance: gpu-operator
25+
app.kubernetes.io/managed-by: Helm
26+
app.kubernetes.io/name: gpu-operator
27+
app.kubernetes.io/version: v25.0.0
28+
helm.sh/chart: gpu-operator-v1.0.0-devel
29+
name: gpu-operator-cleanup-crd
30+
spec:
31+
containers:
32+
- args:
33+
- delete
34+
- --filepath=/opt/gpu-operator/nvidia.com_clusterpolicies.yaml
35+
- --filepath=/opt/gpu-operator/nvidia.com_nvidiadrivers.yaml
36+
- --filepath=/opt/gpu-operator/nfd-api-crds.yaml
37+
command:
38+
- /usr/bin/manage-crds
39+
image: nvcr.io/nvidia/gpu-operator:v25.0.0
40+
imagePullPolicy: IfNotPresent
41+
name: cleanup-crd
42+
restartPolicy: OnFailure
43+
serviceAccountName: gpu-operator
44+
tolerations:
45+
- effect: NoSchedule
46+
key: node-role.kubernetes.io/control-plane
47+
operator: Equal
48+
value: ""

0 commit comments

Comments
 (0)