For example Circle CI can provide CIRCLE_NODE_INDEX and CIRCLE_NODE_TOTAL env. variables. Naive implementation of splitting can look like this.
class Runner
{
...
public function run()
{
...
$nodeIndex = (int) getenv('CIRCLE_NODE_INDEX');
$nodeTotal = (int) getenv('CIRCLE_NODE_TOTAL');
if ($nodeTotal) {
$this->jobs = array_values(array_filter(
$this->jobs,
function (int $jobIndex) use ($nodeIndex, $nodeTotal) {
return ($jobIndex % $nodeTotal) === $nodeIndex;
},
ARRAY_FILTER_USE_KEY
));
}
Better implementation should automatically balance the tests based on the time it took to execute them in previous run.
For example Circle CI can provide
CIRCLE_NODE_INDEXandCIRCLE_NODE_TOTALenv. variables. Naive implementation of splitting can look like this.Better implementation should automatically balance the tests based on the time it took to execute them in previous run.