Is that possible to run shell commands in parallel in steps

I am trying to run xcuitest for ios with a video recording but looks like command lines with ‘&’ was not able to run or display logs and simply return green check.
This is a command I run in a step.

xcodebuild test -project ... & sleep 4; xcrun simctl io booted recordVideo abc.mov & FOO_PID=$!
kill -2 $FOO_PID

First line should be able to run the tests and recording the video. This works fine locally but not able to run github actions. Not sure if it is running or not, but no logs were displayed and green check was returned instantly.

@granluo,
NOTE: The priority in the scripts is “()>;>&”.
So, in your case,

xcodebuild test -project ... & sleep 4; xcrun simctl io booted recordVideo abc.mov & FOO_PID=$!

the order of the command executions is:

  • The commands “xcodebuild test -project …” and “sleep 4” run in parallel at first.
  • After the previous two commands are completed, “xcrun simctl io booted recordVideo abc.mov” and “FOO_PID=$!” run in parallel.

If your expected order is the commands “xcodebuild test -project …”, “sleep 4; xcrun simctl io booted recordVideo abc.mov” and “FOO_PID=$!” run in parallel, you can use “()” to group the commands.

xcodebuild test -project ... &
(sleep 4; xcrun simctl io booted recordVideo abc.mov) &
FOO_PID=$!
wait

NOTE: by default, after the last command line completed in the scripts, the shell will exit and not wait the previous commands that are in-process to complete. So you need to add the “wait” command to wait for all the commands to complete before the shell exit.

The following workflow is an simple example as reference:


@granluo,
how are things going?
Have you tried my above solution? Is it helpful to you?
Please try it, any updates or questions about this ticket, feel free to tell me.