Skip to content

Commit e27c601

Browse files
committed
fix: fix helm-docs and do various helm improvements
- Add valuesFiles option to HelmTemplate config for passing additional values files to helm template command - Remove redundant -f values.yaml flag from helm template (chart's default values.yaml is used automatically) - Remove --template-files flag with typo from helm-docs (default README.md.gotmpl is correct) - Add buildx setup step to helm workflow to fix CI hang (was missing remote buildkit driver) - Extract SetupBuildxStep() to avoid code duplication - Add test helm chart to validate helm CI flow - Fix the workdir of helm-docs Signed-off-by: Utku Ozdemir <utku.ozdemir@siderolabs.com>
1 parent 4879152 commit e27c601

18 files changed

Lines changed: 343 additions & 26 deletions

File tree

.dockerignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT.
22
#
3-
# Generated on 2025-08-14T09:17:18Z by kres 9f63e23-dirty.
3+
# Generated on 2026-01-30T10:07:13Z by kres d81080ef-dirty.
44

55
*
66
!cmd
@@ -11,3 +11,4 @@
1111
!README.md
1212
!.markdownlint.json
1313
!hack/govulncheck.sh
14+
!test/test-helm-chart

.github/workflows/helm.yaml

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT.
2+
#
3+
# Generated on 2026-01-30T10:33:51Z by kres ae0b9fab-dirty.
4+
5+
concurrency:
6+
group: helm-${{ github.head_ref || github.run_id }}
7+
cancel-in-progress: true
8+
"on":
9+
push:
10+
tags:
11+
- v*
12+
pull_request:
13+
branches:
14+
- main
15+
- release-*
16+
paths:
17+
- test/**
18+
name: helm
19+
jobs:
20+
default:
21+
permissions:
22+
actions: read
23+
contents: write
24+
id-token: write
25+
issues: read
26+
packages: write
27+
pull-requests: read
28+
runs-on:
29+
group: generic
30+
steps:
31+
- name: gather-system-info
32+
id: system-info
33+
uses: kenchan0130/actions-system-info@59699597e84e80085a750998045983daa49274c4 # version: v1.4.0
34+
continue-on-error: true
35+
- name: print-system-info
36+
run: |
37+
MEMORY_GB=$((${{ steps.system-info.outputs.totalmem }}/1024/1024/1024))
38+
39+
OUTPUTS=(
40+
"CPU Core: ${{ steps.system-info.outputs.cpu-core }}"
41+
"CPU Model: ${{ steps.system-info.outputs.cpu-model }}"
42+
"Hostname: ${{ steps.system-info.outputs.hostname }}"
43+
"NodeName: ${NODE_NAME}"
44+
"Kernel release: ${{ steps.system-info.outputs.kernel-release }}"
45+
"Kernel version: ${{ steps.system-info.outputs.kernel-version }}"
46+
"Name: ${{ steps.system-info.outputs.name }}"
47+
"Platform: ${{ steps.system-info.outputs.platform }}"
48+
"Release: ${{ steps.system-info.outputs.release }}"
49+
"Total memory: ${MEMORY_GB} GB"
50+
)
51+
52+
for OUTPUT in "${OUTPUTS[@]}";do
53+
echo "${OUTPUT}"
54+
done
55+
continue-on-error: true
56+
- name: checkout
57+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # version: v6.0.1
58+
- name: Unshallow
59+
run: |
60+
git fetch --prune --unshallow
61+
- name: Set up Docker Buildx
62+
id: setup-buildx
63+
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # version: v3.12.0
64+
with:
65+
driver: remote
66+
endpoint: tcp://buildkit-amd64.ci.svc.cluster.local:1234
67+
timeout-minutes: 10
68+
- name: Install Helm
69+
uses: azure/setup-helm@1a275c3b69536ee54be43f2070a358922e12c8d4 # version: v4.3.1
70+
- name: Install cosign
71+
if: github.event_name != 'pull_request'
72+
uses: sigstore/cosign-installer@faadad0cce49287aee09b3a48701e75088a2c6ad # version: v4.0.0
73+
- name: Login to registry
74+
if: github.event_name != 'pull_request'
75+
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # version: v3.6.0
76+
with:
77+
password: ${{ secrets.GITHUB_TOKEN }}
78+
registry: ghcr.io
79+
username: ${{ github.repository_owner }}
80+
- name: Lint chart
81+
if: github.event_name == 'pull_request'
82+
run: |
83+
helm lint test/test-helm-chart
84+
- name: Template chart
85+
if: github.event_name == 'pull_request'
86+
run: |
87+
helm template -f test/test-helm-chart/ci-values.yaml test-helm-chart test/test-helm-chart
88+
- name: Install unit test plugin
89+
if: github.event_name == 'pull_request'
90+
run: |
91+
make helm-plugin-install
92+
- name: Unit test chart
93+
if: github.event_name == 'pull_request'
94+
run: |
95+
make chart-unittest
96+
- name: Generate schema
97+
if: github.event_name == 'pull_request'
98+
run: |
99+
make chart-gen-schema
100+
- name: Generate docs
101+
if: github.event_name == 'pull_request'
102+
run: |
103+
make helm-docs
104+
- name: Check dirty
105+
if: github.event_name == 'pull_request'
106+
run: |
107+
make check-dirty
108+
- name: helm login
109+
if: startsWith(github.ref, 'refs/tags/')
110+
env:
111+
HELM_CONFIG_HOME: /var/tmp/.config/helm
112+
run: |
113+
helm registry login -u ${{ github.repository_owner }} -p ${{ secrets.GITHUB_TOKEN }} ghcr.io
114+
- name: Release chart
115+
if: startsWith(github.ref, 'refs/tags/')
116+
env:
117+
HELM_CONFIG_HOME: /var/tmp/.config/helm
118+
run: |
119+
make helm-release

.kres.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,11 @@ spec:
9191
matchDatasources:
9292
- docker
9393
allowedVersions: /^24\.\d+\.\d+-alpine$/
94+
---
95+
kind: auto.Helm
96+
spec:
97+
enabled: true
98+
chartDir: test/test-helm-chart
99+
template:
100+
valuesFiles:
101+
- test/test-helm-chart/ci-values.yaml

Dockerfile

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,16 @@
22

33
# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT.
44
#
5-
# Generated on 2026-01-16T08:46:36Z by kres 6f7b97a-dirty.
5+
# Generated on 2026-01-30T10:46:03Z by kres 7e95617c-dirty.
66

77
ARG TOOLCHAIN=scratch
88

9+
# helm toolchain
10+
FROM --platform=${BUILDPLATFORM} ${TOOLCHAIN} AS helm-toolchain
11+
ARG HELMDOCS_VERSION
12+
RUN --mount=type=cache,target=/root/.cache/go-build,id=kres/root/.cache/go-build --mount=type=cache,target=/go/pkg,id=kres/go/pkg go install github.com/norwoodj/helm-docs/cmd/helm-docs@${HELMDOCS_VERSION} \
13+
&& mv /go/bin/helm-docs /bin/helm-docs
14+
915
FROM ghcr.io/siderolabs/ca-certificates:v1.12.0 AS image-ca-certificates
1016

1117
FROM ghcr.io/siderolabs/fhs:v1.12.0 AS image-fhs
@@ -22,6 +28,12 @@ RUN bunx markdownlint --ignore "CHANGELOG.md" --ignore "**/node_modules/**" --ig
2228
FROM --platform=${BUILDPLATFORM} ${TOOLCHAIN} AS toolchain
2329
RUN apk --update --no-cache add bash build-base curl jq protoc protobuf-dev
2430

31+
# runs helm-docs
32+
FROM helm-toolchain AS helm-docs-run
33+
WORKDIR /src
34+
COPY test/test-helm-chart /src/test/test-helm-chart
35+
RUN --mount=type=cache,target=/root/.cache/go-build,id=kres/root/.cache/go-build --mount=type=cache,target=/root/.cache/helm-docs,id=kres/root/.cache/helm-docs,sharing=locked helm-docs --badge-style=flat
36+
2537
# build tools
2638
FROM --platform=${BUILDPLATFORM} toolchain AS tools
2739
ENV GO111MODULE=on
@@ -44,6 +56,10 @@ ARG GOFUMPT_VERSION
4456
RUN go install mvdan.cc/gofumpt@${GOFUMPT_VERSION} \
4557
&& mv /go/bin/gofumpt /bin/gofumpt
4658

59+
# clean helm-docs output
60+
FROM scratch AS helm-docs
61+
COPY --from=helm-docs-run /src/test/test-helm-chart test/test-helm-chart
62+
4763
# tools and sources
4864
FROM tools AS base
4965
WORKDIR /src

Makefile

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT.
22
#
3-
# Generated on 2026-01-28T15:12:29Z by kres edff623.
3+
# Generated on 2026-01-30T10:07:13Z by kres d81080ef-dirty.
44

55
# common variables
66

@@ -36,6 +36,9 @@ GOTOOLCHAIN ?= local
3636
GOEXPERIMENT ?=
3737
GO_BUILDFLAGS += -tags $(GO_BUILDTAGS)
3838
TESTPKGS ?= ./...
39+
HELMREPO ?= $(REGISTRY)/$(USERNAME)/charts
40+
COSIGN_ARGS ?=
41+
HELMDOCS_VERSION ?= v1.14.2
3942
KRES_IMAGE ?= ghcr.io/siderolabs/kres:latest
4043
CONFORMANCE_IMAGE ?= ghcr.io/siderolabs/conform:latest
4144

@@ -76,6 +79,7 @@ COMMON_ARGS += --build-arg=DEEPCOPY_VERSION="$(DEEPCOPY_VERSION)"
7679
COMMON_ARGS += --build-arg=GOLANGCILINT_VERSION="$(GOLANGCILINT_VERSION)"
7780
COMMON_ARGS += --build-arg=GOFUMPT_VERSION="$(GOFUMPT_VERSION)"
7881
COMMON_ARGS += --build-arg=TESTPKGS="$(TESTPKGS)"
82+
COMMON_ARGS += --build-arg=HELMDOCS_VERSION="$(HELMDOCS_VERSION)"
7983
TOOLCHAIN ?= docker.io/golang:1.25-alpine
8084

8185
# help menu
@@ -144,7 +148,7 @@ else
144148
GO_LDFLAGS += -s
145149
endif
146150

147-
all: unit-tests kres image-kres lint
151+
all: unit-tests kres image-kres helm lint
148152

149153
$(ARTIFACTS): ## Creates artifacts directory.
150154
@mkdir -p $(ARTIFACTS)
@@ -177,6 +181,7 @@ check-dirty:
177181

178182
generate: ## Generate .proto definitions.
179183
@$(MAKE) local-$@ DEST=./
184+
@sed -i "s/appVersion: .*/appVersion: \"$$(cat internal/version/data/tag)\"/" test/test-helm-chart/Chart.yaml
180185

181186
lint-golangci-lint: ## Runs golangci-lint linter.
182187
@$(MAKE) target-$@
@@ -255,6 +260,44 @@ lint-fmt: lint-golangci-lint-fmt ## Run all linter formatters and fix up the so
255260
image-kres: ## Builds image for kres.
256261
@$(MAKE) registry-$@ IMAGE_NAME="kres"
257262

263+
.PHONY: helm
264+
helm: ## Package helm chart
265+
@helm package test/test-helm-chart -d $(ARTIFACTS)
266+
267+
.PHONY: helm-release
268+
helm-release: helm ## Release helm chart
269+
@helm push $(ARTIFACTS)/test-helm-chart-*.tgz oci://$(HELMREPO) 2>&1 | tee $(ARTIFACTS)/.digest
270+
@cosign sign --yes $(COSIGN_ARGS) $(HELMREPO)/test-helm-chart@$$(cat $(ARTIFACTS)/.digest | awk -F "[, ]+" '/Digest/{print $$NF}')
271+
272+
.PHONY: chart-lint
273+
chart-lint: ## Lint helm chart
274+
@helm lint test/test-helm-chart
275+
276+
.PHONY: helm-plugin-install
277+
helm-plugin-install: ## Install helm plugins
278+
-helm plugin install https://github.com/helm-unittest/helm-unittest.git --verify=false --version=v1.0.3
279+
-helm plugin install https://github.com/losisin/helm-values-schema-json.git --verify=false --version=v2.3.1
280+
281+
.PHONY: kuttl-plugin-install
282+
kuttl-plugin-install: ## Install kubectl kuttl plugin
283+
kubectl krew install kuttl
284+
285+
.PHONY: chart-e2e
286+
chart-e2e: ## Run helm chart e2e tests
287+
export KUBECONFIG=$(shell pwd)/$(ARTIFACTS)/kubeconfig && cd test/e2e && kubectl kuttl test
288+
289+
.PHONY: chart-unittest
290+
chart-unittest: $(ARTIFACTS) ## Run helm chart unit tests
291+
@helm unittest test/test-helm-chart --output-type junit --output-file $(ARTIFACTS)/helm-unittest-report.xml
292+
293+
.PHONY: chart-gen-schema
294+
chart-gen-schema: ## Generate helm chart schema
295+
@helm schema --use-helm-docs --draft=7 --indent=2 --values=test/test-helm-chart/values.yaml --output=test/test-helm-chart/values.schema.json
296+
297+
.PHONY: helm-docs
298+
helm-docs: ## Runs helm-docs and generates chart documentation
299+
@$(MAKE) local-$@ DEST=.
300+
258301
.PHONY: rekres
259302
rekres:
260303
@docker pull $(KRES_IMAGE)

internal/output/ghworkflow/gh_workflow.go

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -481,23 +481,28 @@ func DefaultJobPermissions() map[string]string {
481481
}
482482
}
483483

484+
// SetupBuildxStep returns the buildx setup step.
485+
func SetupBuildxStep() *JobStep {
486+
return &JobStep{
487+
Name: "Set up Docker Buildx",
488+
ID: "setup-buildx",
489+
Uses: ActionRef{
490+
Image: "docker/setup-buildx-action@" + config.SetupBuildxActionRef,
491+
Comment: "version: " + config.SetupBuildxActionVersion,
492+
},
493+
With: map[string]string{
494+
"driver": "remote",
495+
"endpoint": "tcp://buildkit-amd64.ci.svc.cluster.local:1234",
496+
},
497+
TimeoutMinutes: 10,
498+
}
499+
}
500+
484501
// DefaultSteps returns default steps for the workflow.
485502
func DefaultSteps() []*JobStep {
486503
return append(
487504
CommonSteps(),
488-
&JobStep{
489-
Name: "Set up Docker Buildx",
490-
ID: "setup-buildx",
491-
Uses: ActionRef{
492-
Image: "docker/setup-buildx-action@" + config.SetupBuildxActionRef,
493-
Comment: "version: " + config.SetupBuildxActionVersion,
494-
},
495-
With: map[string]string{
496-
"driver": "remote",
497-
"endpoint": "tcp://buildkit-amd64.ci.svc.cluster.local:1234",
498-
},
499-
TimeoutMinutes: 10,
500-
},
505+
SetupBuildxStep(),
501506
)
502507
}
503508

internal/project/auto/config.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,12 @@ type Helm struct {
5252

5353
// HelmTemplate defines helm template settings.
5454
type HelmTemplate struct {
55-
Set []string `yaml:"set"`
56-
SetFile []string `yaml:"setFile"`
57-
SetJSON []string `yaml:"setJSON"`
58-
SetLiteral []string `yaml:"setLiteral"`
59-
SetString []string `yaml:"setString"`
55+
ValuesFiles []string `yaml:"valuesFiles"`
56+
Set []string `yaml:"set"`
57+
SetFile []string `yaml:"setFile"`
58+
SetJSON []string `yaml:"setJSON"`
59+
SetLiteral []string `yaml:"setLiteral"`
60+
SetString []string `yaml:"setString"`
6061
}
6162

6263
// IntegrationTests defines integration tests builder to be generated.

internal/project/auto/helm.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ func (builder *builder) DetectHelm() (bool, error) {
4343

4444
var flags []string
4545

46+
for _, valuesFile := range helm.Template.ValuesFiles {
47+
flags = append(flags, "-f", valuesFile)
48+
}
49+
4650
for _, flag := range helm.Template.Set {
4751
flags = append(flags, "--set", flag)
4852
}

internal/project/helm/build.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func NewBuild(meta *meta.Options) *Build {
4444
func (helm *Build) CompileDockerfile(output *dockerfile.Output) error {
4545
output.Stage("helm-toolchain").
4646
Description("helm toolchain").
47-
From("base").
47+
From("--platform=${BUILDPLATFORM} ${TOOLCHAIN}").
4848
Step(step.Arg("HELMDOCS_VERSION")).
4949
Step(step.Script(
5050
fmt.Sprintf(
@@ -58,8 +58,9 @@ func (helm *Build) CompileDockerfile(output *dockerfile.Output) error {
5858
output.Stage("helm-docs-run").
5959
Description("runs helm-docs").
6060
From("helm-toolchain").
61+
Step(step.WorkDir("/src")).
6162
Step(step.Copy(helm.meta.HelmChartDir, filepath.Join("/src", helm.meta.HelmChartDir))).
62-
Step(step.Run("helm-docs", "--badge-style=flat", "--template-files=README.md.gotpl").
63+
Step(step.Run("helm-docs", "--badge-style=flat").
6364
MountCache(filepath.Join(helm.meta.CachePath, "go-build"), helm.meta.GitHubRepository).
6465
MountCache(filepath.Join(helm.meta.CachePath, "helm-docs"), helm.meta.GitHubRepository, step.CacheLocked))
6566

@@ -180,8 +181,7 @@ func (helm *Build) CompileGitHubWorkflow(output *ghworkflow.Output) error {
180181
}
181182

182183
templateStep := ghworkflow.Step("Template chart").
183-
SetCommand(fmt.Sprintf("helm template -f %s %s %s %s",
184-
filepath.Join(helm.meta.HelmChartDir, "values.yaml"),
184+
SetCommand(fmt.Sprintf("helm template %s %s %s",
185185
strings.Join(helm.meta.HelmTemplateFlags, " "),
186186
filepath.Base(helm.meta.HelmChartDir),
187187
helm.meta.HelmChartDir,
@@ -246,6 +246,7 @@ func (helm *Build) CompileGitHubWorkflow(output *ghworkflow.Output) error {
246246
jobPermissions["id-token"] = "write"
247247

248248
jobSteps := []*ghworkflow.JobStep{
249+
ghworkflow.SetupBuildxStep(),
249250
{
250251
Name: "Install Helm",
251252
Uses: ghworkflow.ActionRef{

0 commit comments

Comments
 (0)