Add github workflows to run unit tests and helm lint#7
Add github workflows to run unit tests and helm lint#7chandrams wants to merge 15 commits intokruize:mvp_demofrom
Conversation
Signed-off-by: Chandrakala Subramanyam <csubrama@redhat.com>
Signed-off-by: Chandrakala Subramanyam <csubrama@redhat.com>
Signed-off-by: Chandrakala Subramanyam <csubrama@redhat.com>
Signed-off-by: Chandrakala Subramanyam <csubrama@redhat.com>
Signed-off-by: Chandrakala Subramanyam <csubrama@redhat.com>
Signed-off-by: Chandrakala Subramanyam <csubrama@redhat.com>
Signed-off-by: Chandrakala Subramanyam <csubrama@redhat.com>
Signed-off-by: Chandrakala Subramanyam <csubrama@redhat.com>
Signed-off-by: Chandrakala Subramanyam <csubrama@redhat.com>
Signed-off-by: Chandrakala Subramanyam <csubrama@redhat.com>
Signed-off-by: Chandrakala Subramanyam <csubrama@redhat.com>
Signed-off-by: Chandrakala Subramanyam <csubrama@redhat.com>
Signed-off-by: Chandrakala Subramanyam <csubrama@redhat.com>
Signed-off-by: Chandrakala Subramanyam <csubrama@redhat.com>
Signed-off-by: Chandrakala Subramanyam <csubrama@redhat.com>
Reviewer's GuideIntroduces a full Kruize Helm chart (templates, values, and tests) for Kubernetes/OpenShift/Minikube along with GitHub Actions workflows to lint the chart and run helm-unittest-based unit tests on pushes and pull requests. Sequence diagram for GitHub Actions Helm lint and unit test workflowssequenceDiagram
actor Dev as Developer
participant GitHub as GitHub
participant WF_Lint as Workflow_Helm_Lint
participant WF_UT as Workflow_Helm_UnitTests
participant Helm as Helm_CLI
participant Artifacts as Test_Artifacts
Dev->>GitHub: Push or PR to main/mvp_demo (charts/kruize/**)
GitHub->>WF_Lint: Trigger helm-lint workflow
GitHub->>WF_UT: Trigger helm-unittest workflow
rect rgb(230,230,230)
WF_Lint->>WF_Lint: Checkout repository
WF_Lint->>WF_Lint: Set up Helm v3.13.0
WF_Lint->>Helm: helm lint charts/kruize (default values)
WF_Lint->>Helm: helm lint -f values-minikube.yaml (if present)
WF_Lint->>Helm: helm lint -f values-openshift.yaml (if present)
WF_Lint->>WF_Lint: Validate chart structure (files/directories)
end
rect rgb(230,230,250)
WF_UT->>WF_UT: Checkout repository
WF_UT->>WF_UT: Set up Helm v3.13.0
WF_UT->>Helm: Install helm-unittest plugin
WF_UT->>Helm: Run helm unittest (default/minikube/openshift tests)
WF_UT->>Helm: Generate JUnit XML report
WF_UT->>Helm: Generate HTML report
WF_UT->>Artifacts: Upload test-results.xml and test-results.html
WF_UT->>WF_UT: Parse XML summary, fail on 0 tests or failures
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 3 issues, and left some high level feedback:
- In
kruize_db_deployment.yaml, thelabels:block under the pod template has a tab-based indentation before{{- include "kruize.selectorLabels" . | nindent 8 }}, which will produce invalid YAML; switch to spaces and align the helper call correctly underlabels:. - The
storage_manual.yamltemplate relies onlookupagainst a cluster-scopedStorageClass(manual), which breakshelm template/lint in environments without live cluster access; consider gating creation with a value flag instead oflookup, or documenting that this StorageClass must be managed outside the chart.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In `kruize_db_deployment.yaml`, the `labels:` block under the pod template has a tab-based indentation before `{{- include "kruize.selectorLabels" . | nindent 8 }}`, which will produce invalid YAML; switch to spaces and align the helper call correctly under `labels:`.
- The `storage_manual.yaml` template relies on `lookup` against a cluster-scoped `StorageClass` (`manual`), which breaks `helm template`/lint in environments without live cluster access; consider gating creation with a value flag instead of `lookup`, or documenting that this StorageClass must be managed outside the chart.
## Individual Comments
### Comment 1
<location path="charts/kruize/templates/kruize_db_deployment.yaml" line_range="20" />
<code_context>
+ template:
+ metadata:
+ labels:
+ {{- include "kruize.selectorLabels" . | nindent 8 }}
+ app: {{ $fullName }}-db
+ spec:
</code_context>
<issue_to_address>
**issue (bug_risk):** Tab indentation here will produce invalid YAML in the rendered manifest.
YAML does not allow tab characters for indentation, so this tab will make the manifest invalid and be rejected by `helm template` / `kubectl`. Please replace it with spaces matching the surrounding indentation.
</issue_to_address>
### Comment 2
<location path="charts/kruize/templates/role.yaml" line_range="8-10" />
<code_context>
+metadata:
+ name: {{ $fullName }}-recommendation-updater
+rules:
+ - apiGroups:
+ - ""
+ resources:
+ - pods
+ - customresourcedefinitions
</code_context>
<issue_to_address>
**issue (bug_risk):** Granting `customresourcedefinitions` under the core API group is invalid and may cause RBAC validation errors.
Here `apiGroups: ["""]` with `resources: ["pods", "customresourcedefinitions"]` is invalid because `customresourcedefinitions` belong to `apiextensions.k8s.io`, not the core group. Since you already grant `apiextensions.k8s.io/customresourcedefinitions` in a separate rule, this entry is both wrong and redundant. Please remove `customresourcedefinitions` here and keep only `pods` to avoid RBAC validation issues.
</issue_to_address>
### Comment 3
<location path=".github/workflows/helm-unittest.yaml" line_range="31" />
<code_context>
+
+ steps:
+ - name: Checkout code
+ uses: actions/checkout@v6
+
+ - name: Set up Helm
</code_context>
<issue_to_address>
**issue (bug_risk):** The specified major versions for some GitHub Actions do not exist and will cause the workflow to fail.
`actions/checkout@v6` and `actions/upload-artifact@v7` are not published (current latest major for both is v4), so the workflow will fail when resolving these actions. Please update to existing versions (e.g. `actions/checkout@v4` / `actions/upload-artifact@v4`) or pin to specific SHAs so the workflow can run successfully.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| template: | ||
| metadata: | ||
| labels: | ||
| {{- include "kruize.selectorLabels" . | nindent 8 }} |
There was a problem hiding this comment.
issue (bug_risk): Tab indentation here will produce invalid YAML in the rendered manifest.
YAML does not allow tab characters for indentation, so this tab will make the manifest invalid and be rejected by helm template / kubectl. Please replace it with spaces matching the surrounding indentation.
| - apiGroups: | ||
| - "" | ||
| resources: |
There was a problem hiding this comment.
issue (bug_risk): Granting customresourcedefinitions under the core API group is invalid and may cause RBAC validation errors.
Here apiGroups: ["""] with resources: ["pods", "customresourcedefinitions"] is invalid because customresourcedefinitions belong to apiextensions.k8s.io, not the core group. Since you already grant apiextensions.k8s.io/customresourcedefinitions in a separate rule, this entry is both wrong and redundant. Please remove customresourcedefinitions here and keep only pods to avoid RBAC validation issues.
|
|
||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v6 |
There was a problem hiding this comment.
issue (bug_risk): The specified major versions for some GitHub Actions do not exist and will cause the workflow to fail.
actions/checkout@v6 and actions/upload-artifact@v7 are not published (current latest major for both is v4), so the workflow will fail when resolving these actions. Please update to existing versions (e.g. actions/checkout@v4 / actions/upload-artifact@v4) or pin to specific SHAs so the workflow can run successfully.
Add github workflows to run unit tests and helm lint
Summary by Sourcery
Add a Helm chart for deploying the Kruize application, including database and UI components, with environment-specific configuration for Kubernetes, OpenShift, and Minikube, and wire it into automated linting and unit testing in CI.
Build:
CI:
Documentation:
Tests: