-
Notifications
You must be signed in to change notification settings - Fork 62.3k
feat: describe matrix variables of type array of objects #31251
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
Conversation
Thanks for opening this pull request! A GitHub docs team member should be by to give feedback soon. In the meantime, please check out the contributing guidelines. |
@deemp Thanks so much for opening a PR! I'll get this triaged for review ✨ |
- matrix.os: ubuntu-latest | ||
matrix.node.version: 14 | ||
matrix.node.env: '' |
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.
This isn't technically correct — matrix.node.env
is simply not set for contexts where it's not included as part of the matrix. It's not part of the matrix.node
object at all. All contexts are not created with the same structure, when matrix expansion is performed on homogeneous objects. Instead, each expanded context has whatever structure is explicitly defined by its set of inputs.
GitHub's workflow syntax expands ${{ foo }}
to the empty string, for any undefined foo, but that doesn't mean that object actually exists.
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.
Which is something that actually requires some care, because for example this workflow:
jobs:
build:
runs-on: ${{ matrix.os.host }}
strategy:
matrix:
os:
- host: macos-latest
- host: windows-latest
shell: 'msys2 {0}'
- host: ubuntu-latest
compiler:
- gcc
- clang
defaults:
run:
shell: ${{ matrix.os.shell }}
...will fail on Ubuntu and macOS, when it tries to set the run.shell
default value to nothing.
Error: The template is not valid. foo.yml (Line: Y, Col: X): Unexpected value ''
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.
It can be fixed with a fallback, e.g.:
defaults:
run:
shell: ${{ matrix.os.shell || 'bash' }}
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.
GitHub's workflow syntax expands ${{ foo }} to the empty string, for any undefined foo, but that doesn't mean that object actually exists.
Where is this documented?
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.
Ah, I see (link)
If you attempt to dereference a nonexistent property, it will evaluate to an empty string.
Co-authored-by: Frank Dana <ferdnyc@gmail.com>
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.
Thank you for making this update @deemp!
I added a couple suggestions below and would love to hear what you think.
There are some versions of GitHub Enterprise Server that do not support Node 20. To adjust for this, we use feature-based versioning. The actions-node20-support
feature-based versioning file to make sure that only the right versions of our documentation show information about Node 20.
My question for you is would Node 16 be a suitable replacement in this case?
Thanks!
Co-authored-by: Joe Clark <31087804+jc-clark@users.noreply.github.com>
Co-authored-by: Joe Clark <31087804+jc-clark@users.noreply.github.com>
Co-authored-by: Joe Clark <31087804+jc-clark@users.noreply.github.com>
@jc-clark, @nguyenalex836, thanks for a review. I believe these node versions are OK. The point of this example was to demonstrate how a matrix unwraps into multiple job configurations. If you think an example without specific |
Thanks very much for contributing! Your pull request has been merged 🎉 You should see your changes appear on the site in approximately 24 hours. If you're looking for your next contribution, check out our help wanted issues ⚡ |
Why:
Partially closes: #26469
I used this hidden knowledge in freckle/stack-action#35 and decided to document it.
What's being changed (if available, include any code snippets, screenshots, or gifs):
Check off the following:
I have reviewed my changes in staging, available via the View deployment link in this PR's timeline (this link will be available after opening the PR).
data
directory.For content changes, I have completed the self-review checklist.