Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 23 additions & 14 deletions .github/workflows/chart-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,19 @@ jobs:
- name: Run chart unit tests
id: unittest
run: |
for dir in $(ls -d charts/*/); do
pushd $dir; helm dependencies update; popd
helm unittest $dir
# Process charts directory
for dir in charts/*/; do
[ -d "$dir" ] || continue
(cd "$dir" && helm dependencies update)
helm unittest "$dir"
done
# Run tests for charts in other-charts/ directory
for dir in other-charts/*/; do
[ -d "$dir" ] || continue
if [ -d "$dir/tests" ]; then
(cd "$dir" && helm dependencies update)
helm unittest "$dir"
fi
done
continue-on-error: true

Expand Down Expand Up @@ -164,16 +174,15 @@ jobs:
run: kubectl create namespace posit-test

- name: Create License File Secrets
env:
PWB_LICENSE: ${{ secrets.PWB_LICENSE_FILE }}
PCT_LICENSE: ${{ secrets.PCT_LICENSE_FILE }}
PPM_LICENSE: ${{ secrets.PPM_LICENSE_FILE }}
run: |
echo "${{ secrets.PWB_LICENSE_FILE }}" > pwb.lic
kubectl create secret generic pwb-license --from-file=pwb.lic --namespace posit-test
rm pwb.lic
echo "${{ secrets.PCT_LICENSE_FILE }}" > pct.lic
kubectl create secret generic pct-license --from-file=pct.lic --namespace posit-test
rm pct.lic
echo "${{ secrets.PPM_LICENSE_FILE }}" > ppm.lic
kubectl create secret generic ppm-license --from-file=ppm.lic --namespace posit-test
rm ppm.lic
# Use env vars and stdin to avoid secrets in temp files and command line args
printf '%s' "$PWB_LICENSE" | kubectl create secret generic pwb-license --from-file=pwb.lic=/dev/stdin --namespace posit-test
printf '%s' "$PCT_LICENSE" | kubectl create secret generic pct-license --from-file=pct.lic=/dev/stdin --namespace posit-test
printf '%s' "$PPM_LICENSE" | kubectl create secret generic ppm-license --from-file=ppm.lic=/dev/stdin --namespace posit-test

- name: Create Workbench Secrets to test existingSecrets
run: |
Expand All @@ -189,13 +198,13 @@ jobs:
- name: Run chart-testing (install changed)
id: ct-install
if: ${{ github.ref != 'refs/heads/main' && steps.list-changed.outputs.changed == 'true' }}
run: ct install --target-branch main --chart-dirs charts --chart-dirs other-charts --excluded-charts rstudio-library --namespace posit-test
run: ct install --target-branch main --chart-dirs charts --chart-dirs other-charts --excluded-charts rstudio-library,rstudio-library-test --namespace posit-test
continue-on-error: true

# no allow-failure until https://github.com/actions/toolkit/issues/399
- name: Run chart-testing (install all)
id: ct-install-all
run: ct install --target-branch main --all --chart-dirs charts --chart-dirs other-charts --excluded-charts rstudio-library --namespace posit-test
run: ct install --target-branch main --all --chart-dirs charts --chart-dirs other-charts --excluded-charts rstudio-library,rstudio-library-test --namespace posit-test
continue-on-error: true

- name: Notify Slack of chart install failure if on main
Expand Down
6 changes: 6 additions & 0 deletions other-charts/rstudio-library-test/Chart.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
dependencies:
- name: rstudio-library
repository: file://../../charts/rstudio-library
version: 0.1.35
digest: sha256:706c9e8c17f03c54f61ac9492f735082b6e771f3d87320f384821ffb4c197f51
generated: "2026-01-28T12:47:20.245416746-06:00"
11 changes: 11 additions & 0 deletions other-charts/rstudio-library-test/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: v2
name: rstudio-library-test
description: Test harness for rstudio-library templates
type: application
version: 0.1.0
appVersion: "0.1.0"

dependencies:
- name: rstudio-library
version: "0.1.35"
repository: "file://../../charts/rstudio-library"
91 changes: 91 additions & 0 deletions other-charts/rstudio-library-test/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@


# rstudio-library-test

![Version: 0.1.0](https://img.shields.io/badge/Version-0.1.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 0.1.0](https://img.shields.io/badge/AppVersion-0.1.0-informational?style=flat-square)

Test harness for rstudio-library templates

## Requirements

| Repository | Name | Version |
|------------|------|---------|
| file://../../charts/rstudio-library | rstudio-library | 0.1.35 |

## Values

| Key | Type | Default | Description |
|-----|------|---------|-------------|
| testChronicle.enabled | bool | `true` | |
| testChronicle.image.registry | string | `"ghcr.io"` | |
| testChronicle.image.repository | string | `"rstudio/chronicle-agent"` | |
| testChronicle.image.tag | string | `"1.0.0"` | |
| testChronicle.serverAddress | string | `"http://chronicle-server.default:8080"` | |
| testChronicle.serverNamespace | string | `""` | |
| testConfig.dcf.config.key1 | string | `"value1"` | |
| testConfig.dcf.config.nested.subkey | string | `"subvalue"` | |
| testConfig.dcf.filename | string | `"test.dcf"` | |
| testConfig.gcfg.config.section1.key1 | string | `"value1"` | |
| testConfig.gcfg.config.section1.key2 | string | `"value2"` | |
| testConfig.gcfg.config.section2.arrayKey[0] | string | `"item1"` | |
| testConfig.gcfg.config.section2.arrayKey[1] | string | `"item2"` | |
| testConfig.gcfg.filename | string | `"test.gcfg"` | |
| testConfig.ini.config.section1.key1 | string | `"value1"` | |
| testConfig.ini.config.section1.key2 | int | `123` | |
| testConfig.ini.filename | string | `"test.ini"` | |
| testConfig.json.config.arrayKey[0] | string | `"item1"` | |
| testConfig.json.config.arrayKey[1] | string | `"item2"` | |
| testConfig.json.config.boolKey | bool | `true` | |
| testConfig.json.config.numberKey | int | `42` | |
| testConfig.json.config.stringKey | string | `"stringValue"` | |
| testConfig.json.filename | string | `"test.json"` | |
| testConfig.txt.config.key1 | string | `"value1"` | |
| testConfig.txt.config.key2 | string | `"value2"` | |
| testConfig.txt.filename | string | `"test.txt"` | |
| testDebug.boolValue | bool | `true` | |
| testDebug.mapValue.key | string | `"value"` | |
| testDebug.sliceValue[0] | string | `"item1"` | |
| testDebug.sliceValue[1] | string | `"item2"` | |
| testDebug.stringValue | string | `"test string"` | |
| testIngress.path | string | `"/test"` | |
| testIngress.pathType | string | `"Prefix"` | |
| testIngress.serviceName | string | `"test-service"` | |
| testIngress.servicePort | int | `8080` | |
| testLauncherTemplates.content.key1 | string | `"value1"` | |
| testLauncherTemplates.content.key2 | string | `"value2"` | |
| testLauncherTemplates.content.nested.subkey | string | `"subvalue"` | |
| testLauncherTemplates.templateName | string | `"test-template"` | |
| testLicense.licenseFile | string | `"LICENSE CONTENT HERE\n"` | |
| testLicense.licenseKey | string | `"test-license-key"` | |
| testLicense.licenseServer | string | `"license.example.com"` | |
| testProfiles.advanced.data."launcher.kubernetes.profiles.conf".*.default-cpus | int | `1` | |
| testProfiles.advanced.data."launcher.kubernetes.profiles.conf".testuser.default-cpus | int | `4` | |
| testProfiles.advanced.filePath | string | `"/etc/rstudio/"` | |
| testProfiles.advanced.jobJsonDefaults | list | `[]` | |
| testProfiles.basicIni."launcher.kubernetes.profiles.conf".*.default-cpus | int | `1` | |
| testProfiles.basicIni."launcher.kubernetes.profiles.conf".*.default-mem-mb | int | `512` | |
| testProfiles.basicIni."launcher.kubernetes.profiles.conf".testuser.default-cpus | int | `2` | |
| testProfiles.collapseArray.simple[0] | string | `"one"` | |
| testProfiles.collapseArray.simple[1] | string | `"two"` | |
| testProfiles.collapseArray.simple[2] | string | `"three"` | |
| testProfiles.collapseArray.targetFile[0].file | string | `"/etc/config/pods.json"` | |
| testProfiles.collapseArray.targetFile[0].target | string | `"pods"` | |
| testProfiles.collapseArray.targetFile[1].file | string | `"/etc/config/services.json"` | |
| testProfiles.collapseArray.targetFile[1].target | string | `"services"` | |
| testProfiles.singleFile.*.job-name | string | `"default-job"` | |
| testProfiles.singleFile.testuser.job-name | string | `"user-job"` | |
| testRbac.annotations | object | `{}` | |
| testRbac.clusterRoleCreate | bool | `false` | |
| testRbac.labels | object | `{}` | |
| testRbac.namespace | string | `"test-namespace"` | |
| testRbac.removeNamespaceReferences | bool | `false` | |
| testRbac.serviceAccountCreate | bool | `true` | |
| testRbac.serviceAccountName | string | `"test-sa"` | |
| testRbac.targetNamespace | string | `"test-target"` | |
| testTplvalues.objectValue.name | string | `"{{ .Release.Name }}"` | |
| testTplvalues.objectValue.namespace | string | `"{{ .Release.Namespace }}"` | |
| testTplvalues.staticValue | string | `"static"` | |
| testTplvalues.templateValue | string | `"{{ .Release.Name }}-suffix"` | |

----------------------------------------------
Autogenerated from chart metadata using [helm-docs v1.13.1](https://github.com/norwoodj/helm-docs/releases/v1.13.1)
43 changes: 43 additions & 0 deletions other-charts/rstudio-library-test/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{{/*
Standard Helm chart helpers for the test harness.
*/}}

{{/*
Expand the name of the chart.
*/}}
{{- define "rstudio-library-test.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Create a default fully qualified app name.
*/}}
{{- define "rstudio-library-test.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "rstudio-library-test.labels" -}}
helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
{{ include "rstudio-library-test.selectorLabels" . }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "rstudio-library-test.selectorLabels" -}}
app.kubernetes.io/name: {{ include "rstudio-library-test.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{{/*
Test templates for rstudio-library chronicle-agent helpers.
Note: These templates use `lookup` which requires cluster access.
Tests with kubernetesProvider mock can only test static paths.
*/}}

{{- if .Values.testChronicle }}
{{- if .Values.testChronicle.enabled }}
---
apiVersion: v1
kind: ConfigMap
metadata:
name: test-chronicle-agent
labels:
{{- include "rstudio-library-test.labels" . | nindent 4 }}
data:
{{- /* Test image template - only when tag is specified to avoid lookup */}}
{{- if .Values.testChronicle.image.tag }}
image: {{ include "rstudio-library.chronicle-agent.image" (dict "chronicleAgent" .Values.testChronicle "Release" .Release) | quote }}
{{- end }}
{{- /* Test serverAddress template - only when serverAddress is specified to avoid lookup */}}
{{- if .Values.testChronicle.serverAddress }}
serverAddress: {{ include "rstudio-library.chronicle-agent.serverAddress" (dict "chronicleAgent" .Values.testChronicle "Release" .Release) | quote }}
{{- end }}
{{- end }}
{{- end }}
67 changes: 67 additions & 0 deletions other-charts/rstudio-library-test/templates/test-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
{{/*
Test templates for rstudio-library config formatters.
Each ConfigMap exercises a different config format template.
*/}}

{{- if .Values.testConfig }}
{{- if .Values.testConfig.gcfg }}
---
apiVersion: v1
kind: ConfigMap
metadata:
name: test-config-gcfg
labels:
{{- include "rstudio-library-test.labels" . | nindent 4 }}
data:
{{ .Values.testConfig.gcfg.filename }}: |
{{- include "rstudio-library.config.gcfg" .Values.testConfig.gcfg.config | nindent 4 }}
{{- end }}

{{- if .Values.testConfig.ini }}
---
apiVersion: v1
kind: ConfigMap
metadata:
name: test-config-ini
labels:
{{- include "rstudio-library-test.labels" . | nindent 4 }}
data:
{{- include "rstudio-library.config.ini" (dict .Values.testConfig.ini.filename .Values.testConfig.ini.config) | nindent 2 }}
{{- end }}

{{- if .Values.testConfig.dcf }}
---
apiVersion: v1
kind: ConfigMap
metadata:
name: test-config-dcf
labels:
{{- include "rstudio-library-test.labels" . | nindent 4 }}
data:
{{- include "rstudio-library.config.dcf" (dict .Values.testConfig.dcf.filename .Values.testConfig.dcf.config) | nindent 2 }}
{{- end }}

{{- if .Values.testConfig.json }}
---
apiVersion: v1
kind: ConfigMap
metadata:
name: test-config-json
labels:
{{- include "rstudio-library-test.labels" . | nindent 4 }}
data:
{{- include "rstudio-library.config.json" (dict .Values.testConfig.json.filename .Values.testConfig.json.config) | nindent 2 }}
{{- end }}

{{- if .Values.testConfig.txt }}
---
apiVersion: v1
kind: ConfigMap
metadata:
name: test-config-txt
labels:
{{- include "rstudio-library-test.labels" . | nindent 4 }}
data:
{{- include "rstudio-library.config.txt" (dict "data" (dict .Values.testConfig.txt.filename .Values.testConfig.txt.config)) | nindent 2 }}
{{- end }}
{{- end }}
40 changes: 40 additions & 0 deletions other-charts/rstudio-library-test/templates/test-debug.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{{/*
Test templates for rstudio-library debug helpers.
The type-check template either succeeds silently or fails with an error.
We test this by passing various types and checking for success/failure.
*/}}

{{- if .Values.testDebug }}

{{- /* Test passing type checks - these should succeed silently */}}
{{- if .Values.testDebug.mapValue }}
{{- include "rstudio-library.debug.type-check" (dict "name" "testMap" "object" .Values.testDebug.mapValue "expected" "map" "description" "test map value") }}
{{- end }}

{{- if .Values.testDebug.sliceValue }}
{{- include "rstudio-library.debug.type-check" (dict "name" "testSlice" "object" .Values.testDebug.sliceValue "expected" "slice" "description" "test slice value") }}
{{- end }}

{{- if .Values.testDebug.stringValue }}
{{- include "rstudio-library.debug.type-check" (dict "name" "testString" "object" .Values.testDebug.stringValue "expected" "string" "description" "test string value") }}
{{- end }}

{{- if .Values.testDebug.boolValue }}
{{- include "rstudio-library.debug.type-check" (dict "name" "testBool" "object" .Values.testDebug.boolValue "expected" "bool" "description" "test bool value") }}
{{- end }}

{{- /* Test failing type check - this should fail */}}
{{- if .Values.testDebug.failingCheck }}
{{- include "rstudio-library.debug.type-check" (dict "name" .Values.testDebug.failingCheck.name "object" .Values.testDebug.failingCheck.object "expected" .Values.testDebug.failingCheck.expected "description" .Values.testDebug.failingCheck.description) }}
{{- end }}

---
apiVersion: v1
kind: ConfigMap
metadata:
name: test-debug-success
labels:
{{- include "rstudio-library-test.labels" . | nindent 4 }}
data:
status: "type-checks-passed"
{{- end }}
Loading
Loading