-
Notifications
You must be signed in to change notification settings - Fork 12
chore: Add initial base chart tests #493
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 6 commits
2c219f6
ee503ed
9e3c1b2
060af6c
97215cf
29fdc29
2d43028
0ad46f3
467531b
b14497e
a1e04d1
9195243
4b5dab8
9d4d47e
8a7e402
64b5d8a
14dd8f3
77575c1
8c2346d
3247f39
6fbb33a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,111 @@ | ||
| name: Test operator-wandb Chart | ||
|
|
||
| on: | ||
| pull_request: | ||
| paths: | ||
| - charts/operator-wandb/** | ||
| - test-configs/wandb-base/** | ||
|
|
||
| jobs: | ||
| snapshots: | ||
| name: Snapshot testing | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
| - name: Set up Helm | ||
| uses: azure/[email protected] | ||
| with: | ||
| version: v3.17.0 | ||
| - name: Helm snapshot build and test | ||
| run: | | ||
| pushd ./charts/operator-wandb/ | ||
| helm repo add bitnami https://charts.bitnami.com/bitnami | ||
| helm repo add stakater https://stakater.github.io/stakater-charts | ||
| helm repo add prometheus https://prometheus-community.github.io/helm-charts | ||
| popd | ||
coderabbitai[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| helm plugin install https://github.com/origranot/helm-cascade | ||
| helm plugin install https://github.com/jlandowner/helm-chartsnap | ||
| ./snapshots.sh build | ||
| ./snapshots.sh run | ||
| # currently this action always tries to install helm, so dont use it for now | ||
| - name: Chart Snapshots | ||
| if: ${{ !always() }} | ||
| uses: jlandowner/helm-chartsnap-action@v1 | ||
| id: chartsnap | ||
coderabbitai[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| with: | ||
| chart: charts/wandb-base/ | ||
| values: test-configs/wandb-base/ | ||
|
|
||
| test: | ||
| name: Test Chart | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| k8s-version: ["v1.32.2", "v1.31.6", "v1.30.10"] | ||
| configuration: | ||
| [ | ||
| env-values-example | ||
| env-precedence-container | ||
| env-precedence-sizing | ||
| env-precedence-chart-env | ||
| env-precedence-chart-legacy | ||
| env-precedence-global-env | ||
| env-precedence-global-legacy | ||
| ] | ||
coderabbitai[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| runs-on: ubuntu-latest | ||
| environment: Helm Charts | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v3 | ||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| - name: Set up Helm | ||
| uses: azure/[email protected] | ||
| with: | ||
| version: v3.17.0 | ||
|
|
||
| - name: Set up Python | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: "3.10" | ||
|
|
||
| - name: Set up chart-testing | ||
| uses: helm/[email protected] | ||
| with: | ||
| version: v3.12.0 | ||
|
|
||
| - name: Run chart-testing (list-changed) | ||
| id: list-changed | ||
| run: | | ||
| changed=$(ct list-changed --config ct.yaml) | ||
| if [[ -n "$changed" ]]; then | ||
| echo "::set-output name=changed::true" | ||
| fi | ||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| - name: Create kind cluster | ||
| uses: helm/[email protected] | ||
| with: | ||
| version: v0.27.0 | ||
| cluster_name: chart-testing-${{ matrix.k8s-version }}-${{ matrix.configuration }} | ||
| node_image: kindest/node:${{ matrix.k8s-version }} | ||
| if: env.ACT || steps.list-changed.outputs.changed == 'true' | ||
|
|
||
| - name: Apply user defined secrets | ||
| run: | | ||
| if [[ -d test-configs/additional-resources/${{matrix.configuration}} ]]; then | ||
| kubectl --context kind-chart-testing-${{ matrix.k8s-version }}-${{ matrix.configuration }} apply -f test-configs/additional-resources/${{matrix.configuration}} | ||
| else | ||
| echo "No additional resources to be applied for ${{matrix.configuration}}" | ||
| fi | ||
| if: env.ACT || steps.list-changed.outputs.changed == 'true' | ||
|
|
||
| - name: Run chart-testing (install) | ||
| if: env.ACT || steps.list-changed.outputs.changed == 'true' | ||
| run: | | ||
| ct install --namespace default \ | ||
| --charts ./charts/wandb-base \ | ||
| --config ct.yaml \ | ||
| --helm-extra-args '--kube-context kind-chart-testing-${{ matrix.k8s-version }}-${{ matrix.configuration }} --timeout 600s' \ | ||
| --helm-extra-set-args '--values test-configs/wandb-base/${{ matrix.configuration }}.yaml' | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,51 @@ | ||||||
| {{- if and .Values.test.enabled (eq .Values.kind "Job") }} | ||||||
| {{- range $jobName, $job := .Values.jobs }} | ||||||
| {{- $job := mergeOverwrite (dict "enabled" true) $job}} | ||||||
| {{- if $job.enabled }} | ||||||
| --- | ||||||
| apiVersion: v1 | ||||||
| kind: Pod | ||||||
| metadata: | ||||||
| name: "{{ include "wandb-base.fullname" $ }}-test-job-{{ $jobName }}" | ||||||
coderabbitai[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
| labels: | ||||||
| {{- include "wandb-base.labels" $ | nindent 4 }} | ||||||
| annotations: | ||||||
| "helm.sh/hook": test | ||||||
| "helm.sh/hook-weight": "1" | ||||||
| spec: | ||||||
| containers: | ||||||
| - name: job-test | ||||||
| image: bitnami/kubectl:latest | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Avoid floating tag for kubectl image; pin or parameterize.
Apply (example pin; adjust as needed): - image: bitnami/kubectl:latest
+ image: bitnami/kubectl:1.31.6Or parameterize: - image: bitnami/kubectl:latest
+ image: {{ default "bitnami/kubectl:1.31.6" .Values.test.kubectlImage }}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||
| command: ['/bin/sh'] | ||||||
| args: | ||||||
| - -c | ||||||
| - | | ||||||
| set -e | ||||||
| echo "Testing job: {{ printf "%s-%s" $.Release.Name $jobName }}" | ||||||
| # Wait for the job to exist | ||||||
| echo "Waiting for job to be created..." | ||||||
| kubectl wait --for=condition=Ready job/{{ printf "%s-%s" $.Release.Name $jobName }} --timeout=300s || true | ||||||
| # Wait for the job to complete successfully | ||||||
| echo "Waiting for job to complete successfully..." | ||||||
| kubectl wait --for=condition=complete job/{{ printf "%s-%s" $.Release.Name $jobName }} --timeout=600s | ||||||
coderabbitai[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
| # Verify the job completed successfully (not failed) | ||||||
| echo "Verifying job completed successfully..." | ||||||
| JOB_STATUS=$(kubectl get job {{ printf "%s-%s" $.Release.Name $jobName }} -o jsonpath='{.status.conditions[?(@.type=="Complete")].status}') | ||||||
| if [ "$JOB_STATUS" != "True" ]; then | ||||||
| echo "Job did not complete successfully. Current status:" | ||||||
| kubectl describe job {{ printf "%s-%s" $.Release.Name $jobName }} | ||||||
| exit 1 | ||||||
| fi | ||||||
| echo "Job {{ printf "%s-%s" $.Release.Name $jobName }} completed successfully!" | ||||||
| # Optional: Show job logs for debugging | ||||||
| echo "Job logs:" | ||||||
| kubectl logs job/{{ printf "%s-%s" $.Release.Name $jobName }} --tail=50 || echo "No logs available" | ||||||
| restartPolicy: Never | ||||||
| {{- end }} | ||||||
| {{- end }} | ||||||
| {{- end }} | ||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| apiVersion: v1 | ||
| kind: ConfigMap | ||
| metadata: | ||
| name: my-configmap | ||
| data: | ||
| configmap-key: "test" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| apiVersion: v1 | ||
| kind: Secret | ||
| metadata: | ||
| name: my-secret | ||
| stringData: | ||
| secret-key: "test" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| dynamicFields: | ||
| - jsonPath: | ||
| - /metadata/labels/helm.sh~1chart | ||
| value: '###CHART_VERSION###' |
Uh oh!
There was an error while loading. Please reload this page.