Skip to content

Commit

Permalink
Feature: add extra flags to skip helm dependencies download and upgra…
Browse files Browse the repository at this point in the history
…de Go to 1.23 (#690)

Signed-off-by: cpanato <[email protected]>
  • Loading branch information
cpanato authored Nov 8, 2024
1 parent 821eb03 commit 3e61ea4
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 13 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ jobs:
check-latest: true

- uses: azure/setup-helm@fe7b79cd5ee1e45176fcad797de68ecaf3ca4814 # v4.2.0
with:
version: v3.14.4

- name: Install GoReleaser
uses: goreleaser/goreleaser-action@286f3b13b1b49da4ac219696163fb8c1c93e1200 # v6.0.0
Expand Down Expand Up @@ -111,4 +109,4 @@ jobs:
- name: golangci-lint
uses: golangci/golangci-lint-action@971e284b6050e8a5849b72094c50ab08da042db8 # v6.1.1
with:
version: v1.57
version: v1.61
3 changes: 2 additions & 1 deletion .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
project_name: chart-testing
version: 2

env:
- COSIGN_YES=true
Expand Down Expand Up @@ -46,7 +47,7 @@ checksum:
name_template: 'checksums.txt'

snapshot:
name_template: "{{ .Tag }}-next"
version_template: "{{ .Tag }}-next"

dockers:
- skip_push: false
Expand Down
2 changes: 2 additions & 0 deletions ct/cmd/lint.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ func addLintFlags(flags *flag.FlagSet) {
Enable schema validation of 'Chart.yaml' using Yamale`))
flags.Bool("validate-yaml", true, heredoc.Doc(`
Enable linting of 'Chart.yaml' and values files`))
flags.Bool("skip-helm-dependencies", false, heredoc.Doc(`
Skip running 'helm dependency build' before linting`))
flags.StringSlice("additional-commands", []string{}, heredoc.Doc(`
Additional commands to run per chart (default: [])
Commands will be executed in the same order as provided in the list and will
Expand Down
1 change: 1 addition & 0 deletions doc/ct_lint-and-install.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ ct lint-and-install [flags]
--remote string The name of the Git remote used to identify changed charts (default "origin")
--since string The Git reference used to identify changed charts (default "HEAD")
--skip-clean-up Skip resources clean-up. Used if need to continue other flows or keep it around.
--skip-helm-dependencies Skip running 'helm dependency build' before linting
--skip-missing-values When --upgrade has been passed, this flag will skip testing CI values files from the
previous chart revision if they have been deleted or renamed at the current chart
revision
Expand Down
1 change: 1 addition & 0 deletions doc/ct_lint.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ ct lint [flags]
expose sensitive data when helm-repo-extra-args contains passwords)
--remote string The name of the Git remote used to identify changed charts (default "origin")
--since string The Git reference used to identify changed charts (default "HEAD")
--skip-helm-dependencies Skip running 'helm dependency build' before linting
--target-branch string The name of the target branch used to identify changed charts (default "main")
--use-helmignore Use .helmignore when identifying changed charts
--validate-chart-schema Enable schema validation of 'Chart.yaml' using Yamale (default true)
Expand Down
4 changes: 1 addition & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
module github.com/helm/chart-testing/v3

go 1.22.0

toolchain go1.22.4
go 1.23

require (
github.com/MakeNowJust/heredoc v1.0.0
Expand Down
16 changes: 10 additions & 6 deletions pkg/chart/chart.go
Original file line number Diff line number Diff line change
Expand Up @@ -384,17 +384,21 @@ func (t *Testing) processCharts(action func(chart *Chart) TestResult) ([]TestRes
}
defer t.git.RemoveWorktree(worktreePath) // nolint: errcheck

for _, chart := range charts {
if err := t.helm.BuildDependenciesWithArgs(t.computePreviousRevisionPath(chart.Path()), t.config.HelmDependencyExtraArgs); err != nil {
// Only print error (don't exit) if building dependencies for previous revision fails.
fmt.Printf("failed building dependencies for previous revision of chart %q: %v\n", chart, err.Error())
if !t.config.SkipHelmDependencies {
for _, chart := range charts {
if err := t.helm.BuildDependenciesWithArgs(t.computePreviousRevisionPath(chart.Path()), t.config.HelmDependencyExtraArgs); err != nil {
// Only print error (don't exit) if building dependencies for previous revision fails.
fmt.Printf("failed building dependencies for previous revision of chart %q: %v\n", chart, err.Error())
}
}
}
}

for _, chart := range charts {
if err := t.helm.BuildDependenciesWithArgs(chart.Path(), t.config.HelmDependencyExtraArgs); err != nil {
return nil, fmt.Errorf("failed building dependencies for chart %q: %w", chart, err)
if !t.config.SkipHelmDependencies {
if err := t.helm.BuildDependenciesWithArgs(chart.Path(), t.config.HelmDependencyExtraArgs); err != nil {
return nil, fmt.Errorf("failed building dependencies for chart %q: %w", chart, err)
}
}

result := action(chart)
Expand Down
1 change: 1 addition & 0 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ type Configuration struct {
ValidateMaintainers bool `mapstructure:"validate-maintainers"`
ValidateChartSchema bool `mapstructure:"validate-chart-schema"`
ValidateYaml bool `mapstructure:"validate-yaml"`
SkipHelmDependencies bool `mapstructure:"skip-helm-dependencies"`
AdditionalCommands []string `mapstructure:"additional-commands"`
CheckVersionIncrement bool `mapstructure:"check-version-increment"`
ProcessAllCharts bool `mapstructure:"all"`
Expand Down

0 comments on commit 3e61ea4

Please sign in to comment.