Skip to content

Commit

Permalink
do not check if matrix combination values in exclude exist in `incl…
Browse files Browse the repository at this point in the history
…ude` when they contain `${{ }}` (fix #414)
  • Loading branch information
rhysd committed Apr 20, 2024
1 parent a6831c3 commit ba825a9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
10 changes: 9 additions & 1 deletion rule_matrix.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,14 @@ func filterMatchesMatrixRow(row []RawYAMLValue, filter RawYAMLValue) bool {
return false
}

func isYAMLStringWithExpression(val RawYAMLValue) bool {
s, ok := val.(*RawYAMLString)
if !ok {
return false
}
return ContainsExpression(s.Value)
}

func (rule *RuleMatrix) checkExclude(m *Matrix) {
if m.Exclude == nil || len(m.Exclude.Combinations) == 0 || (m.Include != nil && m.Include.ContainsExpression()) {
return
Expand Down Expand Up @@ -178,7 +186,7 @@ Outer:
continue
}

if filterMatchesMatrixRow(vs, a.Value) {
if isYAMLStringWithExpression(a.Value) || filterMatchesMatrixRow(vs, a.Value) {
continue
}

Expand Down
12 changes: 12 additions & 0 deletions testdata/ok/issue-414_expression_in_matrix_exclude.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
on: [push]

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
foo: ['a', 'b']
exclude:
- foo: ${{ github.event_name }}
steps:
- run: echo ${{ matrix.foo }}

0 comments on commit ba825a9

Please sign in to comment.