2021-07-26 14:10:10 +03:00
|
|
|
import execa from 'execa';
|
|
|
|
import { globby } from 'globby';
|
2021-02-07 06:21:15 -08:00
|
|
|
|
2021-07-26 14:10:10 +03:00
|
|
|
async function runCypress() {
|
2021-02-07 06:21:15 -08:00
|
|
|
if (process.env.IS_FORK === 'true') {
|
|
|
|
const machineIndex = parseInt(process.env.MACHINE_INDEX);
|
|
|
|
const machineCount = parseInt(process.env.MACHINE_COUNT);
|
|
|
|
const specs = await globby(['cypress/integration/*spec*.js']);
|
|
|
|
const specsPerMachine = Math.floor(specs.length / machineCount);
|
|
|
|
const start = (machineIndex - 1) * specsPerMachine;
|
|
|
|
const machineSpecs =
|
|
|
|
machineIndex === machineCount
|
|
|
|
? specs.slice(start)
|
|
|
|
: specs.slice(start, start + specsPerMachine);
|
|
|
|
|
|
|
|
await execa(
|
|
|
|
'cypress',
|
|
|
|
['run', '--browser', 'chrome', '--headless', '--spec', machineSpecs.join(',')],
|
|
|
|
{ stdio: 'inherit', preferLocal: true },
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
await execa(
|
|
|
|
'cypress',
|
|
|
|
[
|
|
|
|
'run',
|
|
|
|
'--browser',
|
|
|
|
'chrome',
|
|
|
|
'--headless',
|
|
|
|
'--record',
|
|
|
|
'--parallel',
|
|
|
|
'--ci-build-id',
|
|
|
|
process.env.GITHUB_SHA,
|
|
|
|
'--group',
|
|
|
|
'GitHub CI',
|
|
|
|
],
|
|
|
|
{ stdio: 'inherit', preferLocal: true },
|
|
|
|
);
|
|
|
|
}
|
2021-07-26 14:10:10 +03:00
|
|
|
}
|
2021-02-07 06:21:15 -08:00
|
|
|
|
2021-02-10 09:16:08 -08:00
|
|
|
runCypress();
|