-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Testing: Test Create Block with more OS and Node versions #38368
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
0c08f5d
Testing: Test Create Block with more OS and Node versions
gziolo 0c041bf
Update create-block.yml
gziolo eadf75d
Add build folder verification for the scaffolded block
gziolo 319a6bc
Try prepending sh
ockham b0be3c9
Try awk instead of xargs
gziolo b9d8bfe
Try to run the shell script directly in GA
gziolo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,10 @@ status () { | |
echo -e "\n\033[1;34m$1\033[0m\n" | ||
} | ||
|
||
error () { | ||
echo -e "\n\033[1;31m$1\033[0m\n" | ||
} | ||
|
||
cleanup() { | ||
rm -rf "$DIRECTORY/esnext-test" | ||
} | ||
|
@@ -31,6 +35,14 @@ status "Formatting files..." | |
status "Building block..." | ||
../node_modules/.bin/wp-scripts build | ||
|
||
status "Verifying build..." | ||
expected=5 | ||
actual=$( ls build | wc -l | awk '{$1=$1};1' ) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Mysterious incantation! 😄 OK, I think I got it: is the issue that, because
|
||
if [ "$expected" != "$actual" ]; then | ||
error "Expected $expected files in the build folder, but found $actual." | ||
exit 1 | ||
fi | ||
|
||
status "Lintig CSS files..." | ||
../node_modules/.bin/wp-scripts lint-style | ||
|
||
|
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.
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.
Unless there is a GitHub Actions quirk that I am not aware of, in a normal environment this invocation is problematic, because
test-create-block.sh
isn't a POSIX shell script, but a Bash script with specific Bashisms. So it should be:I'll open a follow-up PR.
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.
❤️
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.
(FWIW, we're setting the shell to
bash
, so in practice, it shouldn't matter much IIUC.)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.
Indeed, but I don't understand what that actually means, mechanically. :) That is, in the end in the runtime there must be something equivalent to exec, and this could either mean that some layer is honouring the hashbang (parsing the first line of the script —
#!/bin/bash
— and thus exec'ing/bin/bash
with the script path as argument), or that some layer is directly exec'ing entire string in the config —bash ./bin/test-create-block.sh
. I have no idea what kind of effectshell: bash
plays in the middle of this!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.
BTW, coming back to this from another angle: Are there even that many Bashisms left? Seems like
-ne
could be actually POSIX-compliant 🤔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.
Actually, the
-ne
is fine and dates back to the original Unix days, I believe. :) According to ShellCheck, the only Bashism is the-e
flag passed toecho
. Replacingecho -e
withprintf
should be enough — just don't forget the trailing newline.Btw, ShellCheck is available as a linter. I have it in Vim, so I'm sure it's trivial to install in VSCode. I highly recommend it. It not only prevents mistakes, but it has also taught me a lot thanks to the detailed explanations in the wiki. :)
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 for the reminder! I was still copying code back and forth into shellcheck.net. (I have yet to try if it's clever enough to work inside of the workflow YAML 🤔 )