-
Notifications
You must be signed in to change notification settings - Fork 223
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix regression in changed chart detection #85
Conversation
Please enter the commit message for your changes. Lines starting Signed-off-by: Reinhard Nägele <[email protected]>
0392068
to
d4e63ae
Compare
Seems good to me 👍 Tested:
|
Also tested setting chart-dirs as
|
dir := path.Join(pathElements[0], pathElements[1])
rootDir := filepath.Dir(file)
// Only add if not already in list and double-check if it is a chart directory
if !util.StringSliceContains(changedChartDirs, dir) && t.chartUtils.IsChartDir(dir) {
changedChartDirs = append(changedChartDirs, dir)
} else if !util.StringSliceContains(changedChartDirs, rootDir) && t.chartUtils.IsChartDir(rootDir) {
changedChartDirs = append(changedChartDirs, rootDir)
} Works for both cases, even tho its not so pretty 😄 |
Signed-off-by: Reinhard Nägele <[email protected]>
I refactored it a little bit. Could you test this again? I just quickly made the tests pass but would like to improve those as well. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested a bit again:
λ ~/Code/Go/bin/app lint --debug
Linting charts...
Using config file: /Users/flydiverny/Code/gleerups/chart-repository/ct.yaml
------------------------------------------------------------------------------------------------------------------------
Configuration
------------------------------------------------------------------------------------------------------------------------
Remote: origin
TargetBranch: master
BuildId:
LintConf: lintconf.yaml
ChartYamlSchema: chart_schema.yaml
ValidateMaintainers: true
ValidateChartSchema: true
ValidateYaml: true
CheckVersionIncrement: true
ProcessAllCharts: false
Charts: []
ChartRepos: []
ChartDirs: [.]
ExcludedCharts: []
HelmExtraArgs: --timeout 800
HelmRepoExtraArgs: []
Debug: true
Namespace:
ReleaseLabel:
------------------------------------------------------------------------------------------------------------------------
>>> git merge-base origin/master HEAD
>>> git diff --find-renames --name-only b00fdb7fcc0dbd813517b6523cdecb0a6c01d68b -- .
------------------------------------------------------------------------------------------------------------------------
Charts to be processed:
------------------------------------------------------------------------------------------------------------------------
notifications
notifications
notifications
notifications
notifications
notifications
notifications
------------------------------------------------------------------------------------------------------------------------
Detects changes for both charts in root dir and a "normal" setup with eg stable folder.
However if multiple files are changed for the same chart it will lint it multipletimes.
pkg/chart/chart.go
Outdated
@@ -424,8 +424,13 @@ func (t *Testing) ComputeChangedChartDirectories() ([]string, error) { | |||
} | |||
dir := filepath.Dir(file) | |||
// Only add if not already in list and double-check if it is a chart directory | |||
if !util.StringSliceContains(changedChartDirs, dir) && t.chartUtils.IsChartDir(dir) { | |||
changedChartDirs = append(changedChartDirs, dir) | |||
if !util.StringSliceContains(changedChartDirs, dir) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to change order here and check if chartDir
is added already. Otherwise we will get multiple entries if there are multiple files changed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should work:
chartDir, err := t.chartUtils.LookupChartDir(cfg.ChartDirs, dir)
if err == nil {
if !util.StringSliceContains(changedChartDirs, chartDir) {
changedChartDirs = append(changedChartDirs, chartDir)
}
} else {
fmt.Printf("Directory '%s' is not chart directory. Skipping...", chartDir)
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed as suggested. I figured more elaborate test would no be easy. I'd leave them as is for now.
Signed-off-by: Reinhard Nägele <[email protected]>
Signed-off-by: Reinhard Nägele <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tested last update works as far as I can tell :)
I also tested the same cases in #85 (comment) and it works 👍 |
Fixes #84