Skip to content

Commit c8e4cbd

Browse files
committed
ci: add helm chart-testing and unittest workflow
Adds a GitHub Actions workflow that runs `ct lint` and `helm-unittest` against the gpu-operator chart on PRs that touch `deployments/`, plus a suite of helm-unittest specs (and snapshots) covering the core templates (operator, clusterpolicy, RBAC, validations, custom configs, etc.) so chart regressions are caught in CI. Signed-off-by: Giulio Calzolari <gcalzolari@nvidia.com>
1 parent 55b277c commit c8e4cbd

34 files changed

Lines changed: 2197 additions & 0 deletions

.github/workflows/helm.yaml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
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+
--chart-dirs ${{ env.CHART_DIR }}
37+
38+
unittest:
39+
runs-on: ubuntu-latest
40+
steps:
41+
- name: Checkout repository
42+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
43+
44+
- name: Set up Helm
45+
uses: azure/setup-helm@dda3372f752e03dde6b3237bc9431cdc2f7a02a2 # v5
46+
47+
- name: Install helm-unittest plugin
48+
run: |
49+
echo "Installing helm-unittest plugin..."
50+
helm plugin install https://github.com/helm-unittest/helm-unittest.git --verify=false --version v1.0.3 # 6f82a998e0b5461762ca959f87f5dd344af5e4eb
51+
52+
- name: Run helm unittest
53+
run: helm unittest deployments/${{ env.CHART_NAME }}
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)