|
| 1 | +# Contributing to the Sim Helm chart |
| 2 | + |
| 3 | +Thanks for improving the chart. This page covers how to run the checks that CI |
| 4 | +runs on every PR, so you can catch regressions locally before pushing. |
| 5 | + |
| 6 | +## Prerequisites |
| 7 | + |
| 8 | +- [Helm](https://helm.sh/docs/intro/install/) v3.16+ |
| 9 | +- The [`helm-unittest`](https://github.com/helm-unittest/helm-unittest) plugin: |
| 10 | + |
| 11 | + ```bash |
| 12 | + helm plugin install https://github.com/helm-unittest/helm-unittest --version v0.7.2 |
| 13 | + ``` |
| 14 | + |
| 15 | +- (Optional, for schema validation) [kubeconform](https://github.com/yannh/kubeconform) |
| 16 | + |
| 17 | +## What CI runs |
| 18 | + |
| 19 | +The `Helm Chart` workflow (`.github/workflows/helm-chart.yml`) runs four gates: |
| 20 | + |
| 21 | +1. **`helm lint --strict`** — catches template syntax errors and chart-metadata problems. |
| 22 | +2. **`helm unittest`** — runs every YAML suite in `helm/sim/tests/`. |
| 23 | +3. **`helm template`** against every file in `helm/sim/ci/` — proves the chart |
| 24 | + actually renders under each supported install mode. |
| 25 | +4. **`kubeconform`** on the rendered output — validates every manifest against |
| 26 | + Kubernetes API schemas (`-kubernetes-version 1.30.0`, `-strict`, |
| 27 | + `-ignore-missing-schemas` so CRDs from optional dependencies don't fail). |
| 28 | + |
| 29 | +## Running the same checks locally |
| 30 | + |
| 31 | +```bash |
| 32 | +cd helm/sim |
| 33 | +helm dependency build |
| 34 | +helm lint . --strict |
| 35 | +helm unittest . |
| 36 | +for f in ci/*.yaml; do |
| 37 | + helm template t . -f "$f" > /dev/null |
| 38 | +done |
| 39 | +``` |
| 40 | + |
| 41 | +If you have kubeconform installed: |
| 42 | + |
| 43 | +```bash |
| 44 | +for f in ci/*.yaml; do |
| 45 | + helm template t . -f "$f" | kubeconform -strict -ignore-missing-schemas \ |
| 46 | + -kubernetes-version 1.30.0 -summary |
| 47 | +done |
| 48 | +``` |
| 49 | + |
| 50 | +## Adding a unit test |
| 51 | + |
| 52 | +Tests live in `helm/sim/tests/` and use the |
| 53 | +[helm-unittest DSL](https://github.com/helm-unittest/helm-unittest/blob/main/DOCUMENT.md). |
| 54 | +Each file is one suite. A test sets values, renders a template, and asserts on |
| 55 | +the rendered manifest: |
| 56 | + |
| 57 | +```yaml |
| 58 | +suite: my feature |
| 59 | +release: |
| 60 | + name: t |
| 61 | + namespace: sim |
| 62 | +tests: |
| 63 | + - it: renders the thing |
| 64 | + template: deployment-app.yaml |
| 65 | + set: |
| 66 | + app.env.BETTER_AUTH_SECRET: x |
| 67 | + app.env.ENCRYPTION_KEY: x |
| 68 | + app.env.INTERNAL_API_SECRET: x |
| 69 | + app.env.CRON_SECRET: x |
| 70 | + postgresql.auth.password: x |
| 71 | + myFeature.enabled: true |
| 72 | + asserts: |
| 73 | + - contains: |
| 74 | + path: spec.template.spec.containers[0].env |
| 75 | + content: { name: MY_FEATURE_FLAG, value: "true" } |
| 76 | +``` |
| 77 | +
|
| 78 | +Use the existing suites as references: |
| 79 | +
|
| 80 | +- `tests/smoke_test.yaml` — minimal render checks |
| 81 | +- `tests/validators_test.yaml` — `failedTemplate` assertions for required-value gates |
| 82 | +- `tests/secret-modes_test.yaml` — inline / existingSecret / ESO routing |
| 83 | +- `tests/env-defaults_test.yaml` — `envDefaults` secret-mode-aware inlining |
| 84 | +- `tests/chart-computed-env_test.yaml` — chart-computed env keys cannot be overridden |
| 85 | +- `tests/networkpolicy_test.yaml` — NetworkPolicy ingress/egress shape |
| 86 | +- `tests/pdb-hpa_test.yaml` — PDB tri-state + HPA conditional rendering |
| 87 | + |
| 88 | +When you fix a template bug, please add a regression test for it. |
| 89 | + |
| 90 | +## Adding a ci/*.yaml render fixture |
| 91 | + |
| 92 | +`helm/sim/ci/*.yaml` files are minimal values overlays that CI renders end-to-end |
| 93 | +plus validates with kubeconform. Add one when you introduce a new install mode |
| 94 | +(new secret backend, new database backend, new deployment topology). Keep them |
| 95 | +small — they should test that the mode *renders*, not exercise every option; |
| 96 | +detailed behavior belongs in unit tests. |
| 97 | + |
| 98 | +## Updating `Chart.yaml` |
| 99 | + |
| 100 | +- Bump `version` (the chart version) on every user-visible change. |
| 101 | +- Bump `appVersion` when targeting a new Sim release. |
| 102 | +- Follow SemVer: breaking values changes → major bump, additive → minor, fix → patch. |
| 103 | + |
| 104 | +## Touching `values.schema.json` |
| 105 | + |
| 106 | +The chart ships a JSON Schema that validates user-supplied values. If you add a |
| 107 | +new top-level value or change a type, update the schema in the same PR. |
0 commit comments