Faster CI runs
This commit is contained in:
parent
109c3036c9
commit
ec8d6a7359
26 changed files with 242 additions and 207 deletions
27
ts/scripts/mocha-separator.ts
Normal file
27
ts/scripts/mocha-separator.ts
Normal file
|
@ -0,0 +1,27 @@
|
|||
// Copyright 2025 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import { spawnSync } from 'node:child_process';
|
||||
import { join } from 'node:path';
|
||||
|
||||
const MOCHA = join(__dirname, '..', '..', 'node_modules', '.bin', 'mocha');
|
||||
const WORKER_COUNT = parseInt(process.env.WORKER_COUNT || '1', 10);
|
||||
const WORKER_INDEX = parseInt(process.env.WORKER_INDEX || '0', 10);
|
||||
|
||||
const separator = process.argv.indexOf('--');
|
||||
if (separator === -1) {
|
||||
throw new Error('Expected `--` separator between options and files');
|
||||
}
|
||||
|
||||
const flags = process.argv.slice(2, separator);
|
||||
const files = process.argv.slice(separator + 1);
|
||||
|
||||
const filteredFiles = files.filter((_file, index) => {
|
||||
return index % WORKER_COUNT === WORKER_INDEX;
|
||||
});
|
||||
|
||||
console.log(`Running on ${filteredFiles.length}/${files.length} of files`);
|
||||
|
||||
spawnSync(MOCHA, [...flags, ...filteredFiles], {
|
||||
stdio: 'inherit',
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue