Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parallelize E2E tests to cut CI time in half #16417

Merged
merged 4 commits into from
Nov 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,7 @@ jobs:

test-e2e-chrome:
executor: node-browsers
parallelism: 8
steps:
- checkout
- run:
Expand Down Expand Up @@ -543,6 +544,7 @@ jobs:

test-e2e-chrome-mv3:
executor: node-browsers
parallelism: 8
steps:
- checkout
- run:
Expand Down Expand Up @@ -570,6 +572,7 @@ jobs:

test-e2e-firefox-snaps:
executor: node-browsers
parallelism: 2
steps:
- checkout
- run:
Expand Down Expand Up @@ -597,6 +600,7 @@ jobs:

test-e2e-chrome-snaps:
executor: node-browsers
parallelism: 2
steps:
- checkout
- run:
Expand Down Expand Up @@ -624,6 +628,7 @@ jobs:

test-e2e-firefox:
executor: node-browsers-medium-plus
parallelism: 8
steps:
- checkout
- run:
Expand Down
17 changes: 16 additions & 1 deletion test/e2e/run-all.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ const getTestPathsForTestDir = async (testDir) => {
return testPaths;
};

function chunk(array, chunkSize) {
const result = [];
for (let i = 0; i < array.length; i += chunkSize) {
result.push(array.slice(i, i + chunkSize));
}
return result;
}

async function main() {
const { argv } = yargs(hideBin(process.argv))
.usage(
Expand Down Expand Up @@ -66,7 +74,14 @@ async function main() {
args.push('--retries', retries);
}

for (const testPath of testPaths) {
// For running E2Es in parallel in CI
const currentChunkIndex = process.env.CIRCLE_NODE_INDEX ?? 0;
const totalChunks = process.env.CIRCLE_NODE_TOTAL ?? 1;
const chunkSize = Math.ceil(testPaths.length / totalChunks);
const chunks = chunk(testPaths, chunkSize);
const currentChunk = chunks[currentChunkIndex];

for (const testPath of currentChunk) {
await runInShell('node', [...args, testPath]);
}
}
Expand Down