Repository navigation
🐛 fix(actions): guard empty arrays for bash 3.2 - #50
Merged
Merged
Conversation
macOS runners run `shell: bash` steps with /bin/bash 3.2. Under `set -u`
that shell aborts on `"${array[@]}"` when the array is empty, so
`install-locked-tools` failed on macOS when no targets were given. The
other composite Actions and the check workflow expand arrays the same way.
Expand arrays that can be empty with `${array[@]+"${array[@]}"}`, which
bash 3.2 accepts. Arrays that are always filled where they expand keep the
plain form. A test scans the run blocks of every Action, the tools scripts,
and the workflow jobs that take their runner from an expression, and fails
on any unguarded expansion that is not on its list of provably non-empty
arrays.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A macOS job that calls
install-locked-toolsorexport-build-constraintswithouttargetsstopped withunbound variablebefore it exported any build constraints. 🍎 The same expansion appears in other Actions and in thecheckworkflow, whose test jobs run on the caller's runner. After this merges, those jobs run to completion with empty inputs, and callers need no change.Each Action guards the arrays that can be empty with
${array[@]+"${array[@]}"}, the form that Bash 3.2 accepts, and leaves arrays that are always filled as they are. Bash 5 gives the same result for both forms, so Ubuntu runners see no change. A check reads the run blocks of every Action, the shared scripts, and the workflow jobs whose runner comes from an expression. It fails on an unguarded expansion that is not on its list of arrays that cannot be empty, and each entry on that list carries a reason.This change covers empty arrays only.⚠️ Bash 3.2 still rejects other constructs in these Actions:
render-release-notescallsmapfile, a Bash 4 builtin, andprepare-jetbrains-post-releasehas a conditional expression that Bash 3.2 cannot parse. Underen_US.UTF-8, thepublish-post-release-prmanifest check accepts an uppercaseBas a hex digit on Bash 3.2. The ubuntu-onlyupdate-python-dependenciesworkflow expands empty arrays the same way and is unchanged.