Skip to content

Commit

Permalink
Fix parsing pipelines what use a string as the skip key in a matrix a…
Browse files Browse the repository at this point in the history
…djustment

Also, demote SoftFail on matrix adjustments to being a RemainingField, as it's unused by the agent
moskyb committed Oct 3, 2023

Unverified

No user is associated with the committer email.
1 parent 91890fa commit f6c41e1
Showing 2 changed files with 36 additions and 8 deletions.
24 changes: 20 additions & 4 deletions internal/pipeline/parser_matrix_test.go
Original file line number Diff line number Diff line change
@@ -104,6 +104,8 @@ steps:
skip: true
- with: 42
soft_fail: true
- with: banana
skip: "how dare you, you know i'm allergic to bananas!"
`,
want: &Pipeline{
Steps: Steps{
@@ -119,8 +121,14 @@ steps:
Skip: true,
},
{
With: MatrixAdjustmentWith{"": 42},
SoftFail: true,
With: MatrixAdjustmentWith{"": 42},
RemainingFields: map[string]any{
"soft_fail": true,
},
},
{
With: MatrixAdjustmentWith{"": "banana"},
Skip: "how dare you, you know i'm allergic to bananas!",
},
},
},
@@ -140,6 +148,10 @@ steps:
{
"soft_fail": true,
"with": 42
},
{
"skip": "how dare you, you know i'm allergic to bananas!",
"with": "banana"
}
],
"setup": [
@@ -265,7 +277,9 @@ steps:
"arch": "ppc",
"os": 8,
},
SoftFail: true,
RemainingFields: map[string]any{
"soft_fail": true,
},
},
},
},
@@ -369,7 +383,9 @@ steps:
"arch": "s390x",
"os": "zos",
},
SoftFail: true,
RemainingFields: map[string]any{
"soft_fail": true,
},
},
},
},
20 changes: 16 additions & 4 deletions internal/pipeline/step_command_matrix.go
Original file line number Diff line number Diff line change
@@ -176,11 +176,23 @@ type MatrixAdjustments []*MatrixAdjustment
// MatrixAdjustment models an adjustment - a combination of (possibly new)
// matrix values, and skip/soft fail configuration.
type MatrixAdjustment struct {
With MatrixAdjustmentWith `yaml:"with"`
Skip bool `yaml:"skip,omitempty"`
SoftFail bool `yaml:"soft_fail,omitempty"`
With MatrixAdjustmentWith `yaml:"with"`
Skip any `yaml:"skip,omitempty"`

RemainingFields map[string]any `yaml:",inline"`
RemainingFields map[string]any `yaml:",inline"` // NB: soft_fail is in the remaining fields
}

func (ma *MatrixAdjustment) ShouldSkip() bool {
switch s := ma.Skip.(type) {
case bool:
return s

case nil:
return false

default:
return true
}
}

// MarshalJSON is needed to use inlineFriendlyMarshalJSON.

0 comments on commit f6c41e1

Please sign in to comment.