docs(core): improve run commands in parallel section (#21083)
Co-authored-by: Isaac Mann <isaacplmann@users.noreply.github.com> Co-authored-by: Altan Stalker <stalkeraltan@gmail.com>
This commit is contained in:
parent
b93dd1c577
commit
3c8db4eedf
@ -163,22 +163,30 @@ jobs:
|
||||
|
||||
- name: Run commands in parallel
|
||||
run: |
|
||||
# initialize an array to store process IDs (PIDs)
|
||||
pids=()
|
||||
|
||||
# function to run commands and store the PID
|
||||
function run_command() {
|
||||
local command=$1
|
||||
$command & # run the command in the background
|
||||
pids+=($!) # store the PID of the background process
|
||||
}
|
||||
|
||||
# list of commands to be run on main has env flag NX_CLOUD_DISTRIBUTED_EXECUTION set to false
|
||||
NX_CLOUD_DISTRIBUTED_EXECUTION=false npx nx-cloud record -- npx nx format:check & pids+=($!)
|
||||
run_command "NX_CLOUD_DISTRIBUTED_EXECUTION=false npx nx-cloud record -- npx nx format:check"
|
||||
|
||||
# list of commands to be run on agents
|
||||
npx nx affected -t lint,test,build --parallel=3 &
|
||||
pids+=($!)
|
||||
run_command "npx nx affected -t lint,test,build --parallel=3"
|
||||
|
||||
# run all commands in parallel and bail if one of them fails
|
||||
# wait for all background processes to finish
|
||||
for pid in ${pids[*]}; do
|
||||
if ! wait $pid; then
|
||||
exit 1
|
||||
exit 1 # exit with an error status if any process fails
|
||||
fi
|
||||
done
|
||||
|
||||
exit 0
|
||||
exit 0 # exits with success status if a all processes complete successfully
|
||||
|
||||
agents:
|
||||
name: Agent ${{ matrix.agent }}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user