Skip to content

Commit de59b1c

Browse files
jlegronescottrigby
authored andcommitted
Test chart upgrades (#103)
* Test chart upgrades against previous version Upgrade testing will be run if the --upgrade flag is set (default true) and chart version increment does not indicate a breaking change according to the SemVer 2.0 spec. Any releases associated with previous chart versions which fail to roll out or for which an initial `helm test` fails will be ignored. Signed-off-by: Jacob LeGrone <[email protected]> * fix(dep): add version constraint for github.com/otiai10/copy Signed-off-by: Jacob LeGrone <[email protected]> * refactor(git): checkout whole repository with worktree Signed-off-by: Jacob LeGrone <[email protected]> * Rename test* to do* Signed-off-by: Jacob LeGrone <[email protected]> * Return bool, error from BreakingChangeAllowed Signed-off-by: Jacob LeGrone <[email protected]> * Use errors.Wrapf Co-Authored-By: jlegrone <[email protected]> Signed-off-by: Jacob LeGrone <[email protected]> * Explicitly disable upgrade when not install Signed-off-by: Jacob LeGrone <[email protected]>
1 parent 9dfa4f2 commit de59b1c

20 files changed

+431
-67
lines changed

Gopkg.lock

+17
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ct/cmd/install.go

+11-4
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,17 @@ func newInstallCmd() *cobra.Command {
3131
Use: "install",
3232
Short: "Install and test a chart",
3333
Long: heredoc.Doc(`
34-
Run 'helm install' and ' helm test' on
34+
Run 'helm install', 'helm test', and optionally 'helm upgrade' on
3535
3636
* changed charts (default)
3737
* specific charts (--charts)
3838
* all charts (--all)
3939
40-
in given chart directories.
40+
in given chart directories. If upgrade (--upgrade) is true, then this
41+
command will validate that 'helm test' passes for the following upgrade paths:
42+
43+
* previous chart revision => current chart version (if non-breaking SemVer change)
44+
* current chart version => current chart version
4145
4246
Charts may have multiple custom values files matching the glob pattern
4347
'*-values.yaml' in a directory named 'ci' in the root of the chart's
@@ -61,12 +65,15 @@ func addInstallFlags(flags *flag.FlagSet) {
6165
flags.String("helm-extra-args", "", heredoc.Doc(`
6266
Additional arguments for Helm. Must be passed as a single quoted string
6367
(e.g. "--timeout 500 --tiller-namespace tiller"`))
68+
flags.Bool("upgrade", false, heredoc.Doc(`
69+
Whether to test an in-place upgrade of each chart from its previous revision if the
70+
current version should not introduce a breaking change according to the SemVer spec`))
6471
flags.String("namespace", "", heredoc.Doc(`
6572
Namespace to install the release(s) into. If not specified, each release will be
66-
installed in its own randomly generated namespace.`))
73+
installed in its own randomly generated namespace`))
6774
flags.String("release-label", "app.kubernetes.io/instance", heredoc.Doc(`
6875
The label to be used as a selector when inspecting resources created by charts.
69-
This is only used if namespace is specified.`))
76+
This is only used if namespace is specified`))
7077
}
7178

7279
func install(cmd *cobra.Command, args []string) {

ct/cmd/listChanged.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@ package cmd
1616

1717
import (
1818
"fmt"
19-
"github.com/MakeNowJust/heredoc"
2019
"os"
2120

21+
"github.com/MakeNowJust/heredoc"
22+
2223
"github.com/helm/chart-testing/pkg/chart"
2324
"github.com/helm/chart-testing/pkg/config"
2425
"github.com/spf13/cobra"

doc/ct.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@ in given chart directories.
2626
* [ct list-changed](ct_list-changed.md) - List changed charts
2727
* [ct version](ct_version.md) - Print version information
2828

29-
###### Auto generated by spf13/cobra on 31-Jan-2019
29+
###### Auto generated by spf13/cobra on 26-Feb-2019

doc/ct_install.md

+11-5
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,17 @@ Install and test a chart
44

55
### Synopsis
66

7-
Run 'helm install' and ' helm test' on
7+
Run 'helm install', 'helm test', and optionally 'helm upgrade' on
88

99
* changed charts (default)
1010
* specific charts (--charts)
1111
* all charts (--all)
1212

13-
in given chart directories.
13+
in given chart directories. If upgrade (--upgrade) is true, then this
14+
command will validate that 'helm test' passes for the following upgrade paths:
15+
16+
* previous chart revision => current chart version (if non-breaking SemVer change)
17+
* current chart version => current chart version
1418

1519
Charts may have multiple custom values files matching the glob pattern
1620
'*-values.yaml' in a directory named 'ci' in the root of the chart's
@@ -51,15 +55,17 @@ ct install [flags]
5155
multiple times or separate values with commas
5256
-h, --help help for install
5357
--namespace string Namespace to install the release(s) into. If not specified, each release will be
54-
installed in its own randomly generated namespace.
58+
installed in its own randomly generated namespace
5559
--release-label string The label to be used as a selector when inspecting resources created by charts.
56-
This is only used if namespace is specified. (default "app.kubernetes.io/instance")
60+
This is only used if namespace is specified (default "app.kubernetes.io/instance")
5761
--remote string The name of the Git remote used to identify changed charts (default "origin")
5862
--target-branch string The name of the target branch used to identify changed charts (default "master")
63+
--upgrade Whether to test an in-place upgrade of each chart from its previous revision if the
64+
current version should not introduce a breaking change according to the SemVer spec
5965
```
6066

6167
### SEE ALSO
6268

6369
* [ct](ct.md) - The Helm chart testing tool
6470

65-
###### Auto generated by spf13/cobra on 31-Jan-2019
71+
###### Auto generated by spf13/cobra on 26-Feb-2019

doc/ct_lint-and-install.md

+5-3
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,13 @@ ct lint-and-install [flags]
4646
is searched in the current directory, '$HOME/.ct', and '/etc/ct', in
4747
that order
4848
--namespace string Namespace to install the release(s) into. If not specified, each release will be
49-
installed in its own randomly generated namespace.
49+
installed in its own randomly generated namespace
5050
--release-label string The label to be used as a selector when inspecting resources created by charts.
51-
This is only used if namespace is specified. (default "app.kubernetes.io/instance")
51+
This is only used if namespace is specified (default "app.kubernetes.io/instance")
5252
--remote string The name of the Git remote used to identify changed charts (default "origin")
5353
--target-branch string The name of the target branch used to identify changed charts (default "master")
54+
--upgrade Whether to test an in-place upgrade of each chart from its previous revision if the
55+
current version should not introduce a breaking change according to the SemVer spec
5456
--validate-chart-schema Enable schema validation of 'Chart.yaml' using Yamale (default: true) (default true)
5557
--validate-maintainers Enable validation of maintainer account names in chart.yml (default: true).
5658
Works for GitHub, GitLab, and Bitbucket (default true)
@@ -61,4 +63,4 @@ ct lint-and-install [flags]
6163

6264
* [ct](ct.md) - The Helm chart testing tool
6365

64-
###### Auto generated by spf13/cobra on 31-Jan-2019
66+
###### Auto generated by spf13/cobra on 26-Feb-2019

doc/ct_lint.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,4 @@ ct lint [flags]
6565

6666
* [ct](ct.md) - The Helm chart testing tool
6767

68-
###### Auto generated by spf13/cobra on 31-Jan-2019
68+
###### Auto generated by spf13/cobra on 26-Feb-2019

doc/ct_list-changed.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@ ct list-changed [flags]
2828

2929
* [ct](ct.md) - The Helm chart testing tool
3030

31-
###### Auto generated by spf13/cobra on 31-Jan-2019
31+
###### Auto generated by spf13/cobra on 26-Feb-2019

doc/ct_version.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ ct version [flags]
2020

2121
* [ct](ct.md) - The Helm chart testing tool
2222

23-
###### Auto generated by spf13/cobra on 31-Jan-2019
23+
###### Auto generated by spf13/cobra on 26-Feb-2019

0 commit comments

Comments
 (0)