Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
13 changes: 13 additions & 0 deletions .github/workflows/helm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,19 @@ on:
paths:
- "charts/**"
jobs:
unit-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

Upgrade to actions/checkout@v4.

The actions/checkout@v3 action is deprecated and its runner is too old for current GitHub Actions infrastructure.

⬆️ Recommended upgrade
-      - uses: actions/checkout@v3
+      - uses: actions/checkout@v4
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- uses: actions/checkout@v3
- uses: actions/checkout@v4
🧰 Tools
🪛 actionlint (1.7.12)

[error] 13-13: the runner of "actions/checkout@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

🪛 zizmor (1.25.2)

[warning] 13-13: credential persistence through GitHub Actions artifacts (artipacked): does not set persist-credentials: false

(artipacked)


[error] 13-13: unpinned action reference (unpinned-uses): action is not pinned to a hash (required by blanket policy)

(unpinned-uses)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/helm.yaml at line 13, The actions/checkout action is using
version 3 which is deprecated and has outdated runner infrastructure. Update the
uses statement for actions/checkout to use version 4 instead. Simply change the
action reference from `@v3` to `@v4` to use the current stable version with modern
GitHub Actions infrastructure support.

Source: Linters/SAST tools


⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Add persist-credentials: false to prevent credential leakage.

Without this setting, the checkout action persists GitHub credentials in the workspace .git/config, which can be inadvertently exposed through artifacts or subsequent steps.

🔒 Recommended fix
-      - uses: actions/checkout@v3
+      - uses: actions/checkout@v4
+        with:
+          persist-credentials: false
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
persist-credentials: false
🧰 Tools
🪛 actionlint (1.7.12)

[error] 13-13: the runner of "actions/checkout@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

🪛 zizmor (1.25.2)

[warning] 13-13: credential persistence through GitHub Actions artifacts (artipacked): does not set persist-credentials: false

(artipacked)


[error] 13-13: unpinned action reference (unpinned-uses): action is not pinned to a hash (required by blanket policy)

(unpinned-uses)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/helm.yaml at line 13, The actions/checkout@v3 step is
missing security hardening. Add `persist-credentials: false` as a parameter to
the checkout action to prevent GitHub credentials from being persisted in the
workspace `.git/config` file, which could expose sensitive credentials through
artifacts or subsequent workflow steps.

Source: Linters/SAST tools

- name: Helm tool installer
uses: Azure/setup-helm@v3

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Pin action references to commit SHAs for supply-chain security.

Using mutable tag references (e.g., @v3, @v4) allows action maintainers to modify the code under those tags. Pinning to immutable SHAs prevents supply-chain attacks.

📌 Recommended pinning
-      - uses: actions/checkout@v3
+      - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
+        with:
+          persist-credentials: false
       - name: Helm tool installer
-        uses: Azure/setup-helm@v3
+        uses: Azure/setup-helm@fe7b79cd5ee1e45176fcad797de68ecaf3ca4814 # v4.2.0

Note: Verify the SHA digests correspond to the intended action versions before applying.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- uses: actions/checkout@v3
- name: Helm tool installer
uses: Azure/setup-helm@v3
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false
- name: Helm tool installer
uses: Azure/setup-helm@fe7b79cd5ee1e45176fcad797de68ecaf3ca4814 # v4.2.0
🧰 Tools
🪛 actionlint (1.7.12)

[error] 13-13: the runner of "actions/checkout@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

🪛 zizmor (1.25.2)

[warning] 13-13: credential persistence through GitHub Actions artifacts (artipacked): does not set persist-credentials: false

(artipacked)


[error] 13-13: unpinned action reference (unpinned-uses): action is not pinned to a hash (required by blanket policy)

(unpinned-uses)


[error] 15-15: unpinned action reference (unpinned-uses): action is not pinned to a hash (required by blanket policy)

(unpinned-uses)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/helm.yaml around lines 13 - 15, The workflow file uses
mutable tag references (`@v3`) for GitHub Actions which creates supply chain
security risks. Replace the mutable tag references for actions/checkout and
Azure/setup-helm with their corresponding immutable commit SHA references. For
each action, determine the specific commit SHA for the intended version and
replace the `@v3` syntax with @<full-commit-sha> to ensure the workflow always
uses the exact pinned version regardless of any future changes to those tags.

Source: Linters/SAST tools


- name: Install helm-unittest plugin
run: helm plugin install https://github.com/helm-unittest/helm-unittest

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we pin a version please?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done — pinned to --version v1.1.1 (the current latest release, which the suite is verified against). Happy to bump it in a follow-up whenever you want to track newer plugin releases.


- name: Run helm unit tests
run: helm unittest charts/kafka-ui

build-and-test:
runs-on: ubuntu-latest
steps:
Expand Down
2 changes: 1 addition & 1 deletion charts/kafka-ui/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ apiVersion: v2
name: kafka-ui
description: A Helm chart for kafka-UI
type: application
version: 1.6.4
version: 1.6.6
appVersion: v1.5.0
icon: https://raw.githubusercontent.com/kafbat/kafka-ui/main/documentation/images/logo_new.png
57 changes: 57 additions & 0 deletions charts/kafka-ui/tests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Chart unit tests

These suites use [`helm-unittest`](https://github.com/helm-unittest/helm-unittest)
to render the chart's templates and assert on the resulting manifests. They run
in milliseconds, need no Kubernetes cluster, and catch template regressions
(missing fields, broken conditionals, failed `fail`/`required` guards) before a
change is ever applied.

## Running locally

Install the plugin once:

```bash
helm plugin install https://github.com/helm-unittest/helm-unittest
```

Then run the suites from the repository root:

```bash
helm unittest charts/kafka-ui
```

## Layout

One suite per template, named `<template>_test.yaml`:

| Suite | Template under test | Highlights |
|-------|---------------------|------------|
| `ingress_test.yaml` | `ingress.yaml` | API version selection, TLS, ingressClassName, templated host |
| `service_test.yaml` | `service.yaml` | type/port, NodePort/LoadBalancer specifics, selector labels |
| `deployment_test.yaml` | `deployment.yaml` | replicas vs. autoscaling, image reference, probes, env wiring |
| `notes_test.yaml` | `NOTES.txt` | ClusterIP port-forward fallback |

## Adding tests for a new feature

When you add or change a template, add or update the matching `*_test.yaml`
suite in the same PR. A good suite covers:

1. **Does not render when disabled** — the feature's `enabled: false` path.
2. **Renders correctly when enabled** — kind, apiVersion, name, namespace.
3. **Each configurable knob** — one assertion per value that changes output.
4. **Guards** — every `fail`/`required` is exercised with `failedTemplate`
so a misconfiguration is a red test, not a red CI render.

### Notes for templates that `include` siblings

`deployment.yaml` builds checksum annotations by `include`-ing `configmap.yaml`,
`configmap_fromValues.yaml` and `secret.yaml`. Those templates must be listed
under `templates:` so the includes resolve, and each test uses a
`documentSelector` with `skipEmptyTemplates: true` to assert against the
Deployment document while ignoring the (often empty) configmap/secret renders.

### Notes for `NOTES.txt`

`NOTES.txt` is plain text, not a manifest, so use the raw assertions
(`matchRegexRaw`, `equalRaw`) which operate on the rendered text directly
instead of a YAML `path`.
172 changes: 172 additions & 0 deletions charts/kafka-ui/tests/deployment_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
suite: Deployment

# deployment.yaml computes checksum annotations by include-ing configmap.yaml,
# configmap_fromValues.yaml and secret.yaml, so those templates must be loaded
# for the suite to render. Those three emit no documents under most of these
# cases, so each test selects the Deployment document and skips empty templates.
templates:
- deployment.yaml
- configmap.yaml
- configmap_fromValues.yaml
- secret.yaml

tests:
- it: renders a Deployment with the fullname and release namespace
release:
name: kafka-ui
namespace: kafka
documentSelector:
path: kind
value: Deployment
skipEmptyTemplates: true
asserts:
- isKind:
of: Deployment
- isAPIVersion:
of: apps/v1
- equal:
path: metadata.name
value: kafka-ui
- equal:
path: metadata.namespace
value: kafka

- it: sets replicas from replicaCount when autoscaling is disabled
set:
replicaCount: 3
autoscaling:
enabled: false
documentSelector:
path: kind
value: Deployment
skipEmptyTemplates: true
asserts:
- equal:
path: spec.replicas
value: 3

- it: omits replicas when autoscaling is enabled
set:
autoscaling:
enabled: true
documentSelector:
path: kind
value: Deployment
skipEmptyTemplates: true
asserts:
- notExists:
path: spec.replicas

- it: builds the image reference from registry, repository and appVersion
chart:
appVersion: v1.5.0
documentSelector:
path: kind
value: Deployment
skipEmptyTemplates: true
asserts:
- equal:
path: spec.template.spec.containers[0].image
value: ghcr.io/kafbat/kafka-ui:v1.5.0

- it: allows the image tag to be overridden
set:
image:
tag: v1.4.0
documentSelector:
path: kind
value: Deployment
skipEmptyTemplates: true
asserts:
- equal:
path: spec.template.spec.containers[0].image
value: ghcr.io/kafbat/kafka-ui:v1.4.0

- it: honours a global imageRegistry override
set:
global:
imageRegistry: my-mirror.example.com
image:
tag: v1.5.0
documentSelector:
path: kind
value: Deployment
skipEmptyTemplates: true
asserts:
- equal:
path: spec.template.spec.containers[0].image
value: my-mirror.example.com/kafbat/kafka-ui:v1.5.0

- it: exposes the http container port 8080
documentSelector:
path: kind
value: Deployment
skipEmptyTemplates: true
asserts:
- equal:
path: spec.template.spec.containers[0].ports[0].name
value: http
- equal:
path: spec.template.spec.containers[0].ports[0].containerPort
value: 8080

- it: wires the service account name
release:
name: kafka-ui
set:
serviceAccount:
create: true
documentSelector:
path: kind
value: Deployment
skipEmptyTemplates: true
asserts:
- equal:
path: spec.template.spec.serviceAccountName
value: kafka-ui

- it: defines liveness, readiness and startup probes
documentSelector:
path: kind
value: Deployment
skipEmptyTemplates: true
asserts:
- exists:
path: spec.template.spec.containers[0].livenessProbe
- exists:
path: spec.template.spec.containers[0].readinessProbe
- exists:
path: spec.template.spec.containers[0].startupProbe

- it: renders env entries supplied via env
set:
env:
- name: MY_VAR
value: my-value
documentSelector:
path: kind
value: Deployment
skipEmptyTemplates: true
asserts:
- contains:
path: spec.template.spec.containers[0].env
content:
name: MY_VAR
value: my-value

- it: sets the config additional-location env when yamlApplicationConfig is set
set:
yamlApplicationConfig:
kafka:
clusters:
- name: local
documentSelector:
path: kind
value: Deployment
skipEmptyTemplates: true
asserts:
- contains:
path: spec.template.spec.containers[0].env
content:
name: SPRING_CONFIG_ADDITIONAL-LOCATION
value: /kafka-ui/config.yml
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Loading