From a78f299cf17e835123f0befe03c0b6b929186446 Mon Sep 17 00:00:00 2001 From: Michael Sprauer Date: Sun, 5 Nov 2023 16:14:07 +0100 Subject: [PATCH 1/9] helm unittests Signed-off-by: Michael Sprauer --- .github/workflows/lint-test.yaml | 7 + .../__snapshot__/defaults_test.yaml.snap | 145 ++++++++++++++++++ charts/nextcloud/tests/defaults_test.yaml | 13 ++ 3 files changed, 165 insertions(+) create mode 100644 charts/nextcloud/tests/__snapshot__/defaults_test.yaml.snap create mode 100644 charts/nextcloud/tests/defaults_test.yaml diff --git a/.github/workflows/lint-test.yaml b/.github/workflows/lint-test.yaml index c93c18f3..b8d3e2dc 100644 --- a/.github/workflows/lint-test.yaml +++ b/.github/workflows/lint-test.yaml @@ -43,6 +43,13 @@ jobs: if: steps.list-changed.outputs.changed == 'true' run: ct lint --target-branch ${{ github.event.repository.default_branch }} + - name: Run helm unittest + id: unittest + if: steps.list-changed.outputs.changed == 'true' + run: | + helm plugin install https://github.com/helm-unittest/helm-unittest.git + helm unittest charts/nextcloud + - name: Create kind cluster uses: helm/kind-action@v1.8.0 if: steps.list-changed.outputs.changed == 'true' diff --git a/charts/nextcloud/tests/__snapshot__/defaults_test.yaml.snap b/charts/nextcloud/tests/__snapshot__/defaults_test.yaml.snap new file mode 100644 index 00000000..7ce24825 --- /dev/null +++ b/charts/nextcloud/tests/__snapshot__/defaults_test.yaml.snap @@ -0,0 +1,145 @@ +defaults: + 1: | + apiVersion: apps/v1 + kind: Deployment + metadata: + labels: + app.kubernetes.io/component: app + app.kubernetes.io/instance: RELEASE-NAME + app.kubernetes.io/managed-by: Helm + app.kubernetes.io/name: nextcloud + helm.sh/chart: nextcloud-1.0.0 + name: RELEASE-NAME-nextcloud + spec: + replicas: 1 + selector: + matchLabels: + app.kubernetes.io/component: app + app.kubernetes.io/instance: RELEASE-NAME + app.kubernetes.io/name: nextcloud + strategy: + type: Recreate + template: + metadata: + annotations: + nextcloud-config-hash: a5aae02b1b8278a9c8a2dc143e82d3737fc295f62c34afd617207f37d1b2b438 + php-config-hash: 44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a + labels: + app.kubernetes.io/component: app + app.kubernetes.io/instance: RELEASE-NAME + app.kubernetes.io/name: nextcloud + spec: + containers: + - env: + - name: SQLITE_DATABASE + value: nextcloud + - name: NEXTCLOUD_ADMIN_USER + valueFrom: + secretKeyRef: + key: nextcloud-username + name: RELEASE-NAME-nextcloud + - name: NEXTCLOUD_ADMIN_PASSWORD + valueFrom: + secretKeyRef: + key: nextcloud-password + name: RELEASE-NAME-nextcloud + - name: NEXTCLOUD_TRUSTED_DOMAINS + value: nextcloud.kube.home + - name: NEXTCLOUD_DATA_DIR + value: /var/www/html/data + image: nextcloud:27.1.3-apache + imagePullPolicy: IfNotPresent + livenessProbe: + failureThreshold: 3 + httpGet: + httpHeaders: + - name: Host + value: nextcloud.kube.home + path: /status.php + port: 80 + initialDelaySeconds: 10 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 5 + name: nextcloud + ports: + - containerPort: 80 + name: http + protocol: TCP + readinessProbe: + failureThreshold: 3 + httpGet: + httpHeaders: + - name: Host + value: nextcloud.kube.home + path: /status.php + port: 80 + initialDelaySeconds: 10 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 5 + resources: {} + volumeMounts: + - mountPath: /var/www/ + name: nextcloud-main + subPath: root + - mountPath: /var/www/html + name: nextcloud-main + subPath: html + - mountPath: /var/www/html/data + name: nextcloud-main + subPath: data + - mountPath: /var/www/html/config + name: nextcloud-main + subPath: config + - mountPath: /var/www/html/custom_apps + name: nextcloud-main + subPath: custom_apps + - mountPath: /var/www/tmp + name: nextcloud-main + subPath: tmp + - mountPath: /var/www/html/themes + name: nextcloud-main + subPath: themes + securityContext: + fsGroup: 33 + volumes: + - emptyDir: {} + name: nextcloud-main + 2: | + apiVersion: v1 + data: + nextcloud-password: Y2hhbmdlbWU= + nextcloud-token: YWJjZA== + nextcloud-username: YWRtaW4= + kind: Secret + metadata: + labels: + app.kubernetes.io/instance: RELEASE-NAME + app.kubernetes.io/managed-by: Helm + app.kubernetes.io/name: nextcloud + helm.sh/chart: nextcloud-1.0.0 + name: RELEASE-NAME-nextcloud + type: Opaque + 3: | + apiVersion: v1 + kind: Service + metadata: + labels: + app.kubernetes.io/component: app + app.kubernetes.io/instance: RELEASE-NAME + app.kubernetes.io/managed-by: Helm + app.kubernetes.io/name: nextcloud + helm.sh/chart: nextcloud-1.0.0 + name: RELEASE-NAME-nextcloud + spec: + ports: + - name: http + port: 8080 + protocol: TCP + targetPort: 80 + selector: + app.kubernetes.io/component: app + app.kubernetes.io/instance: RELEASE-NAME + app.kubernetes.io/name: nextcloud + type: ClusterIP diff --git a/charts/nextcloud/tests/defaults_test.yaml b/charts/nextcloud/tests/defaults_test.yaml new file mode 100644 index 00000000..744d33a5 --- /dev/null +++ b/charts/nextcloud/tests/defaults_test.yaml @@ -0,0 +1,13 @@ +suite: test my defaults +templates: + - deployment.yaml + - secrets.yaml + - service.yaml +chart: + version: 1.0.0 +tests: + - it: defaults + set: + metrics.token: "abcd" + asserts: + - matchSnapshot: { } \ No newline at end of file From 2c871d9bdfbddc748cee7a0aa575fbc32a04b0f2 Mon Sep 17 00:00:00 2001 From: Michael Sprauer Date: Sun, 5 Nov 2023 16:20:19 +0100 Subject: [PATCH 2/9] avoid changes in the unittests due to updates in the appVersion Signed-off-by: Michael Sprauer --- charts/nextcloud/tests/__snapshot__/defaults_test.yaml.snap | 2 +- charts/nextcloud/tests/defaults_test.yaml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/charts/nextcloud/tests/__snapshot__/defaults_test.yaml.snap b/charts/nextcloud/tests/__snapshot__/defaults_test.yaml.snap index 7ce24825..7f9df156 100644 --- a/charts/nextcloud/tests/__snapshot__/defaults_test.yaml.snap +++ b/charts/nextcloud/tests/__snapshot__/defaults_test.yaml.snap @@ -47,7 +47,7 @@ defaults: value: nextcloud.kube.home - name: NEXTCLOUD_DATA_DIR value: /var/www/html/data - image: nextcloud:27.1.3-apache + image: nextcloud:1.2.3-apache imagePullPolicy: IfNotPresent livenessProbe: failureThreshold: 3 diff --git a/charts/nextcloud/tests/defaults_test.yaml b/charts/nextcloud/tests/defaults_test.yaml index 744d33a5..c064afdd 100644 --- a/charts/nextcloud/tests/defaults_test.yaml +++ b/charts/nextcloud/tests/defaults_test.yaml @@ -5,6 +5,7 @@ templates: - service.yaml chart: version: 1.0.0 + appVersion: 1.2.3 tests: - it: defaults set: From f649eade6bacd10452a997a78de10a1355ec1de1 Mon Sep 17 00:00:00 2001 From: JesseBot Date: Wed, 29 May 2024 18:03:37 +0200 Subject: [PATCH 3/9] Update defaults_test.yaml.snap generated via `helm unittest -u nextcloud` from `charts` dir Signed-off-by: JesseBot --- charts/nextcloud/tests/__snapshot__/defaults_test.yaml.snap | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/nextcloud/tests/__snapshot__/defaults_test.yaml.snap b/charts/nextcloud/tests/__snapshot__/defaults_test.yaml.snap index 7f9df156..9c03a5f9 100644 --- a/charts/nextcloud/tests/__snapshot__/defaults_test.yaml.snap +++ b/charts/nextcloud/tests/__snapshot__/defaults_test.yaml.snap @@ -22,6 +22,7 @@ defaults: template: metadata: annotations: + hooks-hash: 9525c2748a6c7cd0e28ec740623d0b3fa5a75c83b51ccfd136bc89c76737b204 nextcloud-config-hash: a5aae02b1b8278a9c8a2dc143e82d3737fc295f62c34afd617207f37d1b2b438 php-config-hash: 44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a labels: @@ -110,7 +111,6 @@ defaults: apiVersion: v1 data: nextcloud-password: Y2hhbmdlbWU= - nextcloud-token: YWJjZA== nextcloud-username: YWRtaW4= kind: Secret metadata: From 11ba09e3d12b4500b9cba60261536ca382af225f Mon Sep 17 00:00:00 2001 From: JesseBot Date: Wed, 29 May 2024 18:05:50 +0200 Subject: [PATCH 4/9] Update lint-test.yaml - fix on parameter; add tests directory to changes filter Signed-off-by: JesseBot --- .github/workflows/lint-test.yaml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/lint-test.yaml b/.github/workflows/lint-test.yaml index d9f1f467..412d688f 100644 --- a/.github/workflows/lint-test.yaml +++ b/.github/workflows/lint-test.yaml @@ -1,8 +1,6 @@ name: Lint and Test Charts -on: - pull_request: - paths: +on: [pull_request] jobs: changes: runs-on: ubuntu-latest-low @@ -20,6 +18,7 @@ jobs: - 'charts/nextcloud/Chart.yaml' - 'charts/nextcloud/values.yaml' - 'charts/nextcloud/templates/**' + - 'charts/nextcloud/tests/**' lint-test: runs-on: ubuntu-22.04 From ffaa7c5f90559bd5e3aede2037ba2f68e9ce38c4 Mon Sep 17 00:00:00 2001 From: michaelsp Date: Mon, 6 Jan 2025 13:43:48 +0100 Subject: [PATCH 5/9] chore(doc): add hint on unittesting in CONTRIBUTING.md Signed-off-by: Michael Sprauer --- CONTRIBUTING.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 11c64ff2..9c0a27c3 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -4,7 +4,7 @@ Thanks for considering a contribution to this Nextcloud repository run by the co # Pull Requests -Before submitting a feature or fix PR, please make sure your changes are targetted to one feature or fix, and all your commits are signed off. (Learn more the DCO [here](https://probot.github.io/apps/dco)) +Before submitting a feature or fix PR, please make sure your changes are targeted to one feature or fix, and all your commits are signed off. (Learn more the DCO [here](https://probot.github.io/apps/dco)) If you're making a change to the chart templates or `values.yaml`, please also do the following: @@ -13,7 +13,8 @@ If you're making a change to the chart templates or `values.yaml`, please also d - If you're making a change to a non-default value, please also test that value change locally. You can pass in a custom values file to `helm template` with `--values mycustomvalues.yaml` 3. Test installing the chart. A great tool for this is [`ct`](https://github.com/helm/chart-testing/tree/main) using [`ct install`](https://github.com/helm/chart-testing/blob/main/doc/ct_install.md) on a test cluster like [kind](https://kind.sigs.k8s.io/) 4. Make sure new or changed values are updated in the [values.yaml](./charts/nextcloud/values.yaml) and the [README.md](./charts/nextcloud/README.md) -5. Bump the `version` in the [Chart.yaml](./charts/nextcloud/Chart.yaml) according to [Semantic Versioning](https://semver.org) which uses the format `major.minor.patch`. +5. Run the [helm unittests](https://github.com/helm-unittest/helm-unittest): `helm unittest charts/nextcloud` and if necessary update the tests in the snapshot files in the `tests` directory or run `helm unittest charts/nextcloud --update-snapshots`. For bigger features a new test should be added. +6. Bump the `version` in the [Chart.yaml](./charts/nextcloud/Chart.yaml) according to [Semantic Versioning](https://semver.org) which uses the format `major.minor.patch`. Then, please make sure you follow the [pull request template](.github/pull_request_template.md), so we can more quickly review. In order to move your PR forward faster (for instance, bumping the helm chart version for you), please also check the "Allow edits and access to secrets by maintainers" box next to the "Create pull request" button: From 59d5922df5eb0e25a9a35a62e0ef59a0ab8b0d0d Mon Sep 17 00:00:00 2001 From: Michael Sprauer Date: Mon, 6 Jan 2025 13:44:25 +0100 Subject: [PATCH 6/9] chore(version): bump helm chart version Signed-off-by: Michael Sprauer --- charts/nextcloud/Chart.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/nextcloud/Chart.yaml b/charts/nextcloud/Chart.yaml index 3572be6c..a1d733ba 100644 --- a/charts/nextcloud/Chart.yaml +++ b/charts/nextcloud/Chart.yaml @@ -1,6 +1,6 @@ apiVersion: v2 name: nextcloud -version: 6.5.2 +version: 6.5.3 appVersion: 30.0.4 description: A file sharing server that puts the control and security of your own data back into your hands. keywords: From 996ed9bf062fc40343b101c3d8ae507532193fb0 Mon Sep 17 00:00:00 2001 From: Michael Sprauer Date: Mon, 6 Jan 2025 13:50:25 +0100 Subject: [PATCH 7/9] fix(test): update nextcloud-config-hash Signed-off-by: Michael Sprauer --- charts/nextcloud/tests/__snapshot__/defaults_test.yaml.snap | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/nextcloud/tests/__snapshot__/defaults_test.yaml.snap b/charts/nextcloud/tests/__snapshot__/defaults_test.yaml.snap index 9c03a5f9..8576c2bf 100644 --- a/charts/nextcloud/tests/__snapshot__/defaults_test.yaml.snap +++ b/charts/nextcloud/tests/__snapshot__/defaults_test.yaml.snap @@ -23,7 +23,7 @@ defaults: metadata: annotations: hooks-hash: 9525c2748a6c7cd0e28ec740623d0b3fa5a75c83b51ccfd136bc89c76737b204 - nextcloud-config-hash: a5aae02b1b8278a9c8a2dc143e82d3737fc295f62c34afd617207f37d1b2b438 + nextcloud-config-hash: 8266a725d5474acb6adbf9f0609a3494dc3340a3ac306db90eac9ddb1b851960 php-config-hash: 44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a labels: app.kubernetes.io/component: app From 8bdd88eb5b49c0c2bed6aebc3008388e492dd812 Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 24 Nov 2025 08:24:49 +0000 Subject: [PATCH 8/9] Update Chart.yaml Signed-off-by: Michael --- charts/nextcloud/Chart.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/nextcloud/Chart.yaml b/charts/nextcloud/Chart.yaml index 15310e1b..d0b97f6d 100644 --- a/charts/nextcloud/Chart.yaml +++ b/charts/nextcloud/Chart.yaml @@ -1,6 +1,6 @@ apiVersion: v2 name: nextcloud -version: 8.5.10 +version: 8.5.11 # renovate: image=docker.io/library/nextcloud appVersion: 32.0.2 description: A file sharing server that puts the control and security of your own data back into your hands. From 630b1d1571995f019e6991979628ac33a18a0ede Mon Sep 17 00:00:00 2001 From: Michael Sprauer Date: Mon, 24 Nov 2025 09:36:50 +0100 Subject: [PATCH 9/9] chore: update unittests Signed-off-by: Michael Sprauer --- charts/nextcloud/tests/__snapshot__/defaults_test.yaml.snap | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/charts/nextcloud/tests/__snapshot__/defaults_test.yaml.snap b/charts/nextcloud/tests/__snapshot__/defaults_test.yaml.snap index 8576c2bf..88da170b 100644 --- a/charts/nextcloud/tests/__snapshot__/defaults_test.yaml.snap +++ b/charts/nextcloud/tests/__snapshot__/defaults_test.yaml.snap @@ -8,6 +8,7 @@ defaults: app.kubernetes.io/instance: RELEASE-NAME app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: nextcloud + app.kubernetes.io/version: 1.2.3 helm.sh/chart: nextcloud-1.0.0 name: RELEASE-NAME-nextcloud spec: @@ -48,7 +49,7 @@ defaults: value: nextcloud.kube.home - name: NEXTCLOUD_DATA_DIR value: /var/www/html/data - image: nextcloud:1.2.3-apache + image: docker.io/library/nextcloud:1.2.3-apache imagePullPolicy: IfNotPresent livenessProbe: failureThreshold: 3 @@ -118,6 +119,7 @@ defaults: app.kubernetes.io/instance: RELEASE-NAME app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: nextcloud + app.kubernetes.io/version: 1.2.3 helm.sh/chart: nextcloud-1.0.0 name: RELEASE-NAME-nextcloud type: Opaque @@ -130,6 +132,7 @@ defaults: app.kubernetes.io/instance: RELEASE-NAME app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: nextcloud + app.kubernetes.io/version: 1.2.3 helm.sh/chart: nextcloud-1.0.0 name: RELEASE-NAME-nextcloud spec: