-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
[No QA] Make GitHub Actions build asynchronously #3702
Conversation
Just a heads up |
# This stores all the process IDs of the ncc commands so they can run in parallel | ||
declare ASYNC_BUILDS | ||
|
||
for ((i=0; i < ${#GITHUB_ACTIONS[@]}; i++)); do |
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.
NAB: TIL that ${#GITHUB_ACTIONS[@]}
and ${#GITHUB_ACTIONS[*]}
will return the number of elements in the GITHUB_ACTIONS
array. Very cool!
|
||
# Build the action in the background | ||
ncc build "$ACTION" -o "$ACTION_DIR" & | ||
ASYNC_BUILDS[$i]=$! |
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.
NAB: I've used !$
before, but $!
(returning the PID of the last command) is a new one on me.
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.
Took me a minute to figure out what's going on, but it tests well and the code makes sense.
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
🚀 Deployed to staging in version: 1.0.73-4🚀
|
🚀 Deployed to production in version: 1.0.74-0🚀
|
Details
...Just something I worked on during a flight, mostly to get some much-needed practice with bash scripting. But still a nice time-saver!
This PR makes the GitHub Actions build script asynchronous, and it's considerably faster now.
Fixed Issues
n/a
Tests
Testing this was a pretty interesting task, and I mostly wanted to test two things:
To verify that the output is the same, I did the following:
git checkout temp-test
.github/libs/GithubUtils.js
. This file is used by many GHA, so it's a good way to test the build script.npm run gh-actions-build
, then commit the changes.git checkout main && git checkout Rory-AsyncGHActionsBuilds
.github/libs/GithubUtils.js
.npm run gh-actions-build
againgit diff temp-test..
. There should be no diff.git checkout main && git branch -D temp-test
To verify that the script actually runs the build faster:
Add the following function to your bash profile (or just copy/paste it into your shell):
Then from an up-to-date main, run:
Then on
Rory-AsyncGHActionsBuilds
run:It's not a perfect experiment, but it does appear to be definitively faster – roughly 1/3 the execution time of a synchronous build.
Tested On
n/a – bash only