Repository: helm/chart-testing
Pull request #606 (2023-11-01 09:16:30)

add stale action

**What this PR does / why we need it**:

- add stale action

**Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes #

**Special notes for your reviewer**:



Patch:
diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml
index 2608aa2..6259efd 100644
--- a/.github/workflows/ci.yaml
+++ b/.github/workflows/ci.yaml
@@ -111,4 +111,4 @@ jobs:
       - name: golangci-lint
         uses: golangci/golangci-lint-action@3a919529898de77ec3da873e3063ca4b10e7f5cc # v3
         with:
-          version: v1.53
+          version: v1.55
diff --git a/.github/workflows/stale.yaml b/.github/workflows/stale.yaml
new file mode 100644
index 0000000..7955a4f
--- /dev/null
+++ b/.github/workflows/stale.yaml
@@ -0,0 +1,24 @@
+name: 'Close stale issues and PRs'
+on:
+  schedule:
+    - cron: '30 1 * * *'
+
+jobs:
+  stale:
+    runs-on: ubuntu-latest
+
+    permissions:
+      issues: write
+      pull-requests: write
+
+    steps:
+      - uses: actions/stale@1160a2240286f5da8ec72b1c0816ce2481aabf84 # v8.0.0
+        with:
+          stale-issue-message: 'This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.'
+          stale-pr-message: 'This PR is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 10 days.'
+          close-issue-message: 'This issue was closed because it has been stalled for 5 days with no activity.'
+          close-pr-message: 'This PR was closed because it has been stalled for 10 days with no activity.'
+          days-before-issue-stale: 30
+          days-before-pr-stale: 45
+          days-before-issue-close: 5
+          days-before-pr-close: 5
diff --git a/ct/cmd/root.go b/ct/cmd/root.go
index de8223b..c5db25f 100644
--- a/ct/cmd/root.go
+++ b/ct/cmd/root.go
@@ -97,7 +97,10 @@ func addCommonLintAndInstallFlags(flags *pflag.FlagSet) {
 		May be specified multiple times or separate values with commas`))
 	flags.String("helm-extra-args", "", heredoc.Doc(`
 		Additional arguments for Helm. Must be passed as a single quoted string
-		(e.g. "--timeout 500s")`))
+		(e.g. '--timeout 500s')`))
+	flags.String("helm-lint-extra-args", "", heredoc.Doc(`
+		Additional arguments for Helm lint subcommand. Must be passed as a single quoted string
+		(e.g. '--quiet')`))
 	flags.StringSlice("helm-repo-extra-args", []string{}, heredoc.Doc(`
 		Additional arguments for the 'helm repo add' command to be
 		specified on a per-repo basis with an equals sign as delimiter
diff --git a/doc/ct_install.md b/doc/ct_install.md
index 7951785..8554d5e 100644
--- a/doc/ct_install.md
+++ b/doc/ct_install.md
@@ -52,9 +52,11 @@ ct install [flags]
                                              for command output
       --helm-dependency-extra-args strings   Additional arguments for 'helm dependency build' (e.g. ["--skip-refresh"]
       --helm-extra-args string               Additional arguments for Helm. Must be passed as a single quoted string
-                                             (e.g. "--timeout 500s")
+                                             (e.g. '--timeout 500s')
       --helm-extra-set-args string           Additional arguments for Helm. Must be passed as a single quoted string
                                              (e.g. "--set=name=value"
+      --helm-lint-extra-args string          Additional arguments for Helm lint subcommand. Must be passed as a single quoted string
+                                             (e.g. '--quiet')
       --helm-repo-extra-args strings         Additional arguments for the 'helm repo add' command to be
                                              specified on a per-repo basis with an equals sign as delimiter
                                              (e.g. 'myrepo=--username test --password secret'). May be specified
diff --git a/doc/ct_lint-and-install.md b/doc/ct_lint-and-install.md
index 73d13fe..ea74b53 100644
--- a/doc/ct_lint-and-install.md
+++ b/doc/ct_lint-and-install.md
@@ -44,9 +44,11 @@ ct lint-and-install [flags]
                                              for command output
       --helm-dependency-extra-args strings   Additional arguments for 'helm dependency build' (e.g. ["--skip-refresh"]
       --helm-extra-args string               Additional arguments for Helm. Must be passed as a single quoted string
-                                             (e.g. "--timeout 500s")
+                                             (e.g. '--timeout 500s')
       --helm-extra-set-args string           Additional arguments for Helm. Must be passed as a single quoted string
                                              (e.g. "--set=name=value"
+      --helm-lint-extra-args string          Additional arguments for Helm lint subcommand. Must be passed as a single quoted string
+                                             (e.g. '--quiet')
       --helm-repo-extra-args strings         Additional arguments for the 'helm repo add' command to be
                                              specified on a per-repo basis with an equals sign as delimiter
                                              (e.g. 'myrepo=--username test --password secret'). May be specified
diff --git a/doc/ct_lint.md b/doc/ct_lint.md
index f35ee02..4313585 100644
--- a/doc/ct_lint.md
+++ b/doc/ct_lint.md
@@ -54,7 +54,9 @@ ct lint [flags]
                                              for command output
       --helm-dependency-extra-args strings   Additional arguments for 'helm dependency build' (e.g. ["--skip-refresh"]
       --helm-extra-args string               Additional arguments for Helm. Must be passed as a single quoted string
-                                             (e.g. "--timeout 500s")
+                                             (e.g. '--timeout 500s')
+      --helm-lint-extra-args string          Additional arguments for Helm lint subcommand. Must be passed as a single quoted string
+                                             (e.g. '--quiet')
       --helm-repo-extra-args strings         Additional arguments for the 'helm repo add' command to be
                                              specified on a per-repo basis with an equals sign as delimiter
                                              (e.g. 'myrepo=--username test --password secret'). May be specified
diff --git a/pkg/chart/chart.go b/pkg/chart/chart.go
index 5f2907b..0f1e1f9 100644
--- a/pkg/chart/chart.go
+++ b/pkg/chart/chart.go
@@ -259,11 +259,12 @@ type TestResult struct {
 // NewTesting creates a new Testing struct with the given config.
 func NewTesting(config config.Configuration, extraSetArgs string) (Testing, error) {
 	procExec := exec.NewProcessExecutor(config.Debug)
-	extraArgs := strings.Fields(config.HelmExtraArgs)
+	helmExtraArgs := strings.Fields(config.HelmExtraArgs)
+	helmLintExtraArgs := strings.Fields(config.HelmLintExtraArgs)
 
 	testing := Testing{
 		config:           config,
-		helm:             tool.NewHelm(procExec, extraArgs, strings.Fields(extraSetArgs)),
+		helm:             tool.NewHelm(procExec, helmExtraArgs, helmLintExtraArgs, strings.Fields(extraSetArgs)),
 		git:              tool.NewGit(procExec),
 		kubectl:          tool.NewKubectl(procExec, config.KubectlTimeout),
 		linter:           tool.NewLinter(procExec),
diff --git a/pkg/config/config.go b/pkg/config/config.go
index 114e259..c6b8287 100644
--- a/pkg/config/config.go
+++ b/pkg/config/config.go
@@ -60,6 +60,7 @@ type Configuration struct {
 	ChartDirs               []string      `mapstructure:"chart-dirs"`
 	ExcludedCharts          []string      `mapstructure:"excluded-charts"`
 	HelmExtraArgs           string        `mapstructure:"helm-extra-args"`
+	HelmLintExtraArgs       string        `mapstructure:"helm-lint-extra-args"`
 	HelmRepoExtraArgs       []string      `mapstructure:"helm-repo-extra-args"`
 	HelmDependencyExtraArgs []string      `mapstructure:"helm-dependency-extra-args"`
 	Debug                   bool          `mapstructure:"debug"`
diff --git a/pkg/tool/helm.go b/pkg/tool/helm.go
index 2f22986..42724b0 100644
--- a/pkg/tool/helm.go
+++ b/pkg/tool/helm.go
@@ -22,16 +22,18 @@ import (
 )
 
 type Helm struct {
-	exec         exec.ProcessExecutor
-	extraArgs    []string
-	extraSetArgs []string
+	exec          exec.ProcessExecutor
+	extraArgs     []string
+	lintExtraArgs []string
+	extraSetArgs  []string
 }
 
-func NewHelm(exec exec.ProcessExecutor, extraArgs []string, extraSetArgs []string) Helm {
+func NewHelm(exec exec.ProcessExecutor, extraArgs, lintExtraArgs, extraSetArgs []string) Helm {
 	return Helm{
-		exec:         exec,
-		extraArgs:    extraArgs,
-		extraSetArgs: extraSetArgs,
+		exec:          exec,
+		extraArgs:     extraArgs,
+		lintExtraArgs: lintExtraArgs,
+		extraSetArgs:  extraSetArgs,
 	}
 }
 
@@ -60,7 +62,7 @@ func (h Helm) LintWithValues(chart string, valuesFile string) error {
 		values = []string{"--values", valuesFile}
 	}
 
-	return h.exec.RunProcess("helm", "lint", chart, values, h.extraArgs)
+	return h.exec.RunProcess("helm", "lint", chart, values, h.lintExtraArgs)
 }
 
 func (h Helm) InstallWithValues(chart string, valuesFile string, namespace string, release string) error {


Test patch:
diff --git a/pkg/chart/integration_test.go b/pkg/chart/integration_test.go
index 5322d0f..c6b5915 100644
--- a/pkg/chart/integration_test.go
+++ b/pkg/chart/integration_test.go
@@ -34,6 +34,8 @@ func newTestingHelmIntegration(cfg config.Configuration, extraSetArgs string) Te
 	fakeMockLinter := new(fakeLinter)
 	procExec := exec.NewProcessExecutor(true)
 	extraArgs := strings.Fields(cfg.HelmExtraArgs)
+	extraLintArgs := strings.Fields(cfg.HelmLintExtraArgs)
+
 	return Testing{
 		config:           cfg,
 		directoryLister:  util.DirectoryLister{},
@@ -41,7 +43,7 @@ func newTestingHelmIntegration(cfg config.Configuration, extraSetArgs string) Te
 		utils:            util.Utils{},
 		accountValidator: fakeAccountValidator{},
 		linter:           fakeMockLinter,
-		helm:             tool.NewHelm(procExec, extraArgs, strings.Fields(extraSetArgs)),
+		helm:             tool.NewHelm(procExec, extraArgs, extraLintArgs, strings.Fields(extraSetArgs)),
 		kubectl:          tool.NewKubectl(procExec, 30*time.Second),
 	}
 }
diff --git a/pkg/config/config_test.go b/pkg/config/config_test.go
index bc64131..80b33f0 100644
--- a/pkg/config/config_test.go
+++ b/pkg/config/config_test.go
@@ -52,7 +52,8 @@ func loadAndAssertConfigFromFile(t *testing.T, configFile string) {
 	require.Equal(t, []string{"incubator=--username test"}, cfg.HelmRepoExtraArgs)
 	require.Equal(t, []string{"stable", "incubator"}, cfg.ChartDirs)
 	require.Equal(t, []string{"common"}, cfg.ExcludedCharts)
-	require.Equal(t, "--timeout 300", cfg.HelmExtraArgs)
+	require.Equal(t, "--timeout 300s", cfg.HelmExtraArgs)
+	require.Equal(t, "--quiet", cfg.HelmLintExtraArgs)
 	require.Equal(t, true, cfg.Upgrade)
 	require.Equal(t, true, cfg.SkipMissingValues)
 	require.Equal(t, "default", cfg.Namespace)
diff --git a/pkg/config/test_config.json b/pkg/config/test_config.json
index df0b100..4dc445a 100644
--- a/pkg/config/test_config.json
+++ b/pkg/config/test_config.json
@@ -24,7 +24,8 @@
     "excluded-charts": [
         "common"
     ],
-    "helm-extra-args": "--timeout 300",
+    "helm-extra-args": "--timeout 300s",
+    "helm-lint-extra-args": "--quiet",
     "upgrade": true,
     "skip-missing-values": true,
     "namespace": "default",
diff --git a/pkg/config/test_config.yaml b/pkg/config/test_config.yaml
index 1381b96..6fe391d 100644
--- a/pkg/config/test_config.yaml
+++ b/pkg/config/test_config.yaml
@@ -19,7 +19,8 @@ chart-dirs:
   - incubator
 excluded-charts:
   - common
-helm-extra-args: --timeout 300
+helm-extra-args: --timeout 300s
+helm-lint-extra-args: --quiet
 upgrade: true
 skip-missing-values: true
 namespace: default