mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-22 09:57:02 +01:00
parent
fc0036d5b1
commit
dd20281372
@ -13,10 +13,13 @@ const getTestPathsForTestDir = async (testDir) => {
|
|||||||
return testPaths;
|
return testPaths;
|
||||||
};
|
};
|
||||||
|
|
||||||
function chunk(array, chunkSize) {
|
// Heavily inspired by: https://stackoverflow.com/a/51514813
|
||||||
|
// Splits the array into totalChunks chunks with a decent spread of items in each chunk
|
||||||
|
function chunk(array, totalChunks) {
|
||||||
|
const copyArray = [...array];
|
||||||
const result = [];
|
const result = [];
|
||||||
for (let i = 0; i < array.length; i += chunkSize) {
|
for (let chunkIndex = totalChunks; chunkIndex > 0; chunkIndex--) {
|
||||||
result.push(array.slice(i, i + chunkSize));
|
result.push(copyArray.splice(0, Math.ceil(copyArray.length / chunkIndex)));
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -77,8 +80,7 @@ async function main() {
|
|||||||
// For running E2Es in parallel in CI
|
// For running E2Es in parallel in CI
|
||||||
const currentChunkIndex = process.env.CIRCLE_NODE_INDEX ?? 0;
|
const currentChunkIndex = process.env.CIRCLE_NODE_INDEX ?? 0;
|
||||||
const totalChunks = process.env.CIRCLE_NODE_TOTAL ?? 1;
|
const totalChunks = process.env.CIRCLE_NODE_TOTAL ?? 1;
|
||||||
const chunkSize = Math.ceil(testPaths.length / totalChunks);
|
const chunks = chunk(testPaths, totalChunks);
|
||||||
const chunks = chunk(testPaths, chunkSize);
|
|
||||||
const currentChunk = chunks[currentChunkIndex];
|
const currentChunk = chunks[currentChunkIndex];
|
||||||
|
|
||||||
for (const testPath of currentChunk) {
|
for (const testPath of currentChunk) {
|
||||||
|
Loading…
Reference in New Issue
Block a user