@@ -25,6 +25,7 @@ import (
25
25
26
26
"github.com/helm/chart-testing/v3/pkg/config"
27
27
"github.com/helm/chart-testing/v3/pkg/exec"
28
+ "github.com/helm/chart-testing/v3/pkg/ignore"
28
29
"github.com/helm/chart-testing/v3/pkg/tool"
29
30
"github.com/helm/chart-testing/v3/pkg/util"
30
31
)
@@ -242,6 +243,7 @@ type Testing struct {
242
243
directoryLister DirectoryLister
243
244
utils Utils
244
245
previousRevisionWorktree string
246
+ loadRules func (string ) (* ignore.Rules , error )
245
247
}
246
248
247
249
// TestResults holds results and overall status
@@ -271,6 +273,7 @@ func NewTesting(config config.Configuration, extraSetArgs string) (Testing, erro
271
273
accountValidator : tool.AccountValidator {},
272
274
directoryLister : util.DirectoryLister {},
273
275
utils : util.Utils {},
276
+ loadRules : ignore .LoadRules ,
274
277
}
275
278
276
279
versionString , err := testing .helm .Version ()
@@ -744,7 +747,7 @@ func (t *Testing) ComputeChangedChartDirectories() ([]string, error) {
744
747
return nil , fmt .Errorf ("failed creating diff: %w" , err )
745
748
}
746
749
747
- var changedChartDirs [] string
750
+ changedChartFiles := map [ string ][] string {}
748
751
for _ , file := range allChangedChartFiles {
749
752
pathElements := strings .SplitN (filepath .ToSlash (file ), "/" , 3 )
750
753
if len (pathElements ) < 2 || util .StringSliceContains (cfg .ExcludedCharts , pathElements [1 ]) {
@@ -761,15 +764,33 @@ func (t *Testing) ComputeChangedChartDirectories() ([]string, error) {
761
764
continue
762
765
}
763
766
}
764
- // Only add it if not already in the list
765
- if ! util .StringSliceContains (changedChartDirs , chartDir ) {
766
- changedChartDirs = append (changedChartDirs , chartDir )
767
- }
767
+ changedChartFiles [chartDir ] = append (changedChartFiles [chartDir ], strings .TrimPrefix (file , chartDir + "/" ))
768
768
} else {
769
769
fmt .Fprintf (os .Stderr , "Directory %q is not a valid chart directory. Skipping...\n " , dir )
770
770
}
771
771
}
772
772
773
+ changedChartDirs := []string {}
774
+ if t .config .UseHelmignore {
775
+ for chartDir , changedChartFiles := range changedChartFiles {
776
+ rules , err := t .loadRules (chartDir )
777
+ if err != nil {
778
+ return nil , err
779
+ }
780
+ filteredChartFiles , err := ignore .FilterFiles (changedChartFiles , rules )
781
+ if err != nil {
782
+ return nil , err
783
+ }
784
+ if len (filteredChartFiles ) > 0 {
785
+ changedChartDirs = append (changedChartDirs , chartDir )
786
+ }
787
+ }
788
+ } else {
789
+ for chartDir := range changedChartFiles {
790
+ changedChartDirs = append (changedChartDirs , chartDir )
791
+ }
792
+ }
793
+
773
794
return changedChartDirs , nil
774
795
}
775
796
0 commit comments