Skip to content
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

Fixes include when using matrix and strategy build. #415

Merged
merged 7 commits into from
Dec 8, 2020

Conversation

SteffenSeckler
Copy link
Contributor

The include of the matrix strategy was incorrectly handled.
This simply appends the provided includes to the matrix product, s.t. this works (taken from the official doc)

runs-on: ${{ matrix.os }}
strategy:
  matrix:
    os: [macos-latest, windows-latest, ubuntu-18.04]
    node: [4, 6, 8, 10]
    include:
      # includes a new variable of npm with a value of 2
      # for the matrix leg matching the os and version
      - os: windows-latest
        node: 4
        npm: 2

Also replaces the comparison of the commonKeysMatch() with a reflect.DeepEqual to be able to compare maps.
Potentially the entire loop could be replaced that way`

PS:
I do not know how testing works in this project, so I cannot easily add one. But I have seen, that neither include nor exclude appears to be tested.

@@ -195,7 +192,7 @@ func (j *Job) GetMatrixes() []map[string]interface{} {

func commonKeysMatch(a map[string]interface{}, b map[string]interface{}) bool {
Copy link
Contributor Author

@SteffenSeckler SteffenSeckler Nov 11, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Potentially, this entire function could be replaced with a reflect.DeepEqual(a, b).
What do you think?
I would replace the call to it in that case (l.175) and remove this function.

@cplee
Copy link
Contributor

cplee commented Nov 16, 2020

@SteffenSeckler - can you include some test cases for this? For examples of how to test sample workflow files, see: https://github.com/nektos/act/blob/master/pkg/runner/runner_test.go#L34

Copy link
Contributor

@cplee cplee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you include some test cases for this? For examples of how to test sample workflow files, see: https://github.com/nektos/act/blob/master/pkg/runner/runner_test.go#L34

@cplee cplee merged commit e47a239 into nektos:master Dec 8, 2020
edtan added a commit to edtan/act that referenced this pull request Jan 23, 2021
This fixes nektos#499, where a matrix strategy with only include keys ends up
causing multiple builds.  This bugs appears to have been introduced in nektos#415,
when extra include keys are added in the matrix strategy.  The cause
seems to be because the CartesianProduct function returns an item with
empty keys, instead of return an empty set.
cplee pushed a commit that referenced this pull request Jan 23, 2021
This fixes #499, where a matrix strategy with only include keys ends up
causing multiple builds.  This bugs appears to have been introduced in #415,
when extra include keys are added in the matrix strategy.  The cause
seems to be because the CartesianProduct function returns an item with
empty keys, instead of return an empty set.

Co-authored-by: Ed Tan <[email protected]>
@mumoshu mumoshu mentioned this pull request Feb 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants