@@ -13,6 +13,9 @@ import (
1313
1414 "github.com/siderolabs/kres/internal/config"
1515 "github.com/siderolabs/kres/internal/dag"
16+ "github.com/siderolabs/kres/internal/output/dockerfile"
17+ "github.com/siderolabs/kres/internal/output/dockerfile/step"
18+ "github.com/siderolabs/kres/internal/output/dockerignore"
1619 "github.com/siderolabs/kres/internal/output/ghworkflow"
1720 "github.com/siderolabs/kres/internal/output/makefile"
1821 "github.com/siderolabs/kres/internal/project/meta"
@@ -33,6 +36,32 @@ func NewBuild(meta *meta.Options) *Build {
3336 }
3437}
3538
39+ // CompileDockerfile implements dockerfile.Compiler.
40+ func (helm * Build ) CompileDockerfile (output * dockerfile.Output ) error {
41+ output .Stage ("helm-docs-run" ).
42+ Description ("runs helm-docs" ).
43+ From ("base" ).
44+ Step (step .Copy (helm .meta .HelmChartDir , filepath .Join ("/src" , helm .meta .HelmChartDir ))).
45+ Step (step .Run ("helm-docs" , "--badge-style=flat" , "--template-files=README.md.gotpl" ).
46+ MountCache (filepath .Join (helm .meta .CachePath , "go-build" ), helm .meta .GitHubRepository ).
47+ MountCache (filepath .Join (helm .meta .CachePath , "helm-docs" ), helm .meta .GitHubRepository , step .CacheLocked ))
48+
49+ output .Stage ("helm-docs" ).
50+ Description ("clean helm-docs output" ).
51+ From ("scratch" ).
52+ Step (step .Copy (filepath .Join ("/src" , helm .meta .HelmChartDir ), helm .meta .HelmChartDir ).From ("helm-docs-run" ))
53+
54+ return nil
55+ }
56+
57+ // CompileDockerignore implements dockerignore.Compiler.
58+ func (helm * Build ) CompileDockerignore (output * dockerignore.Output ) error {
59+ output .
60+ AllowLocalPath (helm .meta .HelmChartDir )
61+
62+ return nil
63+ }
64+
3665// CompileMakefile implements makefile.Compiler.
3766func (helm * Build ) CompileMakefile (output * makefile.Output ) error {
3867 helmReleaseScript := fmt .Sprintf (`@helm push $(ARTIFACTS)/%s-*.tgz oci://$(HELMREPO) 2>&1 | tee $(ARTIFACTS)/.digest
@@ -41,7 +70,8 @@ func (helm *Build) CompileMakefile(output *makefile.Output) error {
4170
4271 output .VariableGroup (makefile .VariableGroupCommon ).
4372 Variable (makefile .OverridableVariable ("HELMREPO" , "$(REGISTRY)/$(USERNAME)/charts" )).
44- Variable (makefile .OverridableVariable ("COSIGN_ARGS" , "" ))
73+ Variable (makefile .OverridableVariable ("COSIGN_ARGS" , "" )).
74+ Variable (makefile .OverridableVariable ("HELMDOCS_VERSION" , config .HelmDocsVersion ))
4575
4676 generateTarget := output .GetTarget ("generate" )
4777 if generateTarget != nil {
@@ -67,7 +97,10 @@ func (helm *Build) CompileMakefile(output *makefile.Output) error {
6797 output .Target ("helm-plugin-install" ).
6898 Description ("Install helm plugins" ).
6999 Phony ().
70- Script (fmt .Sprintf ("-helm plugin install https://github.com/helm-unittest/helm-unittest.git --verify=false --version=%s" , config .HelmUnitTestVersion ))
100+ Script (
101+ fmt .Sprintf ("-helm plugin install https://github.com/helm-unittest/helm-unittest.git --verify=false --version=%s" , config .HelmUnitTestVersion ),
102+ fmt .Sprintf ("-helm plugin install https://github.com/losisin/helm-values-schema-json.git --verify=false --version=%s" , config .HelmValuesSchemaJSONVersion ),
103+ )
71104
72105 output .Target ("kuttl-plugin-install" ).
73106 Description ("Install kubectl kuttl plugin" ).
@@ -84,6 +117,14 @@ func (helm *Build) CompileMakefile(output *makefile.Output) error {
84117 Phony ().
85118 Script (fmt .Sprintf ("@helm unittest %s --output-type junit --output-file $(ARTIFACTS)/helm-unittest-report.xml" , helm .meta .HelmChartDir ))
86119
120+ output .Target ("chart-gen-schema" ).
121+ Description ("Generate helm chart schema" ).
122+ Phony ().
123+ Script (fmt .Sprintf ("@helm schema --use-helm-docs --draft=7 --indent=2 --values=%s/values.yaml --output=%s/values.schema.json" , helm .meta .HelmChartDir , helm .meta .HelmChartDir ))
124+
125+ output .Target ("helm-docs" ).Description ("Runs helm-docs and generates chart documentation" ).
126+ Script ("@$(MAKE) local-$@ DEST=." )
127+
87128 return nil
88129}
89130
@@ -145,6 +186,27 @@ func (helm *Build) CompileGitHubWorkflow(output *ghworkflow.Output) error {
145186 return err
146187 }
147188
189+ schemaStep := ghworkflow .Step ("Generate schema" ).
190+ SetMakeStep ("chart-gen-schema" )
191+
192+ if err := schemaStep .SetConditions ("on-pull-request" ); err != nil {
193+ return err
194+ }
195+
196+ docsStep := ghworkflow .Step ("Generate docs" ).
197+ SetMakeStep ("helm-docs" )
198+
199+ if err := docsStep .SetConditions ("on-pull-request" ); err != nil {
200+ return err
201+ }
202+
203+ checkDirtyStep := ghworkflow .Step ("Check dirty" ).
204+ SetMakeStep ("check-dirty" )
205+
206+ if err := checkDirtyStep .SetConditions ("on-pull-request" ); err != nil {
207+ return err
208+ }
209+
148210 helmLoginStep := ghworkflow .Step ("helm login" ).
149211 SetEnv ("HELM_CONFIG_HOME" , "/var/tmp/.config/helm" ).
150212 SetCommand (fmt .Sprintf ("helm registry login -u %s -p ${{ secrets.GITHUB_TOKEN }} ghcr.io" , "${{ github.repository_owner }}" ))
@@ -202,6 +264,9 @@ func (helm *Build) CompileGitHubWorkflow(output *ghworkflow.Output) error {
202264 templateStep ,
203265 unittestPluginInstallStep ,
204266 unittestStep ,
267+ schemaStep ,
268+ docsStep ,
269+ checkDirtyStep ,
205270 helmLoginStep ,
206271 helmReleaseStep ,
207272 },
0 commit comments