Running tests in parallel
For every CI job, Semaphore checks out and runs your code inside an isolated container or virtual machine, called Box. Boxes are powerful, isolated CI job runners engineered to provide bare metal performance at the convenience of cloud.
Use your boxes to parallelize a large test suite, or build and deploy multiple branches across different projects. Semaphore does not limit how you use your boxes in any way.
To split your test suite into parallel jobs, simply rearrange your build commands for multiple jobs in your project’s settings.
A new job block will appear, with an input field to enter a build command.
Since in this example all the commands we want to run have already been entered,
we’ll press the Escape key, and drag and drop the
bundle exec rake cucumber
command into our new job:
You can now rename the job from “Job #2” to “Cucumber” in order to be able to differentiate between jobs more easily later. This text will also appear on the pages showing build results. To rename the job, click on “Rename” next to “Job #2”, enter your prefered name, and press Return.
Repeating the same for
npm test gives us a 3-job setup, as shown on the
From this point on, all new builds will run in three parallel jobs — faster than if all tests ran sequentially, i.e. one by one. Note that the total build time duration is now determined by the longest running job.