-
Notifications
You must be signed in to change notification settings - Fork 497
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
🐛 Fixing parsing for Github workflow when matrix is an expression #1145
🐛 Fixing parsing for Github workflow when matrix is an expression #1145
Conversation
} | ||
for _, os := range jobOses { | ||
if !strings.HasPrefix(strings.ToLower(os), "windows-") { | ||
return false | ||
if !strings.HasPrefix(strings.ToLower(os), "windows") { |
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.
I removed the -
because I noticed in lucas-clemente/quic-go that you can use expressions to construct the OS name. 🤮
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.
Thanks Chris!
checks/pinned_dependencies.go
Outdated
jobOses = job.Strategy.Matrix.Os | ||
} else { | ||
jobOses = job.RunsOn | ||
if len(job.RunsOn) != 1 || !strings.Contains(job.RunsOn[0], "matrix.os") { |
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.
- does this work if there's a single os defined, i.e.,
len(job.RunsOn) == 1
? Seems like the following code assumes data is in thejob.Strategy.Matrix
if this if-statement is false. - is there a chance that
job.RunsOn
has length0
and!strings.Contains(job.RunsOn[0], "matrix.os")
evaluation will crash?
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.
I tweaked this code to make it more readable. With my changes I think it'll be easier to see the code will work when len(job.RunsOn)
is 1 or 0.
4c2767f
to
57454e0
Compare
name: "Matrix as expression", | ||
filename: "./testdata/github-workflow-matrix-expression.yaml", | ||
expected: scut.TestReturn{ | ||
Error: nil, |
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.
I would have thought this test would return an error since we don't try to parse things like fromJson(needs.matrix.outputs.latest)
and return error unable to determine OS for job
.
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.
In github-workflow-matrix-expression.yaml
and in ljharb/array-includes
, the runs-on
field contains the OS so we are able to avoid returning an error.
What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)
Bug fix
What is the current behavior? (You can also link to an open issue here)
Running
./scorecard --repo=ljharb/array-includes --show-details --checks=Pinned-Dependencies
errors out when parsing one of the gh workflow files. This is becausematrix
does not have anos
key:Part of #839
No