Parallelize Flow in CI (#20794)
* Parallelize Flow in CI We added more host configs recently, and we run all the checks in sequence, so sometimes Flow ends up being the slowest CI job. This splits the job across multiple processes. * Fix environment variable typo Co-authored-by: Ricky <rickhanlonii@gmail.com> Co-authored-by: Ricky <rickhanlonii@gmail.com>
Andrew Clark committed
Feb 10, 2021 at 17:54 UTC
9e9be6c6b34452a327d5f34d3120f4c93edcfcd9
2 files changed
+19
-8
.circleci/config.yml
+4
-3
@@ -83,6 +83,7 @@ jobs:
83
yarn_flow:
84
docker: *docker
85
environment: *environment
86
+ parallelism: 5
87
88
steps:
89
- checkout
@@ -384,9 +385,6 @@ workflows:
385
- yarn_lint:
386
requires:
387
- setup
387
- - yarn_flow:
388
- requires:
389
- - setup
388
- RELEASE_CHANNEL_stable_yarn_build:
389
requires:
390
- setup
@@ -426,6 +424,9 @@ workflows:
424
unless: << pipeline.parameters.prerelease_commit_sha >>
425
jobs:
426
- setup
427
+ - yarn_flow:
428
+ requires:
429
+ - setup
430
- yarn_test:
431
requires:
432
- setup
scripts/tasks/flow-ci.js
+15
-5
@@ -14,12 +14,22 @@ process.on('unhandledRejection', err => {
14
const runFlow = require('../flow/runFlow');
15
const inlinedHostConfigs = require('../shared/inlinedHostConfigs');
16
17
+// Parallelize tests across multiple tasks.
18
+const nodeTotal = process.env.CIRCLE_NODE_TOTAL
19
+ ? parseInt(process.env.CIRCLE_NODE_TOTAL, 10)
20
+ : 1;
21
+const nodeIndex = process.env.CIRCLE_NODE_INDEX
22
+ ? parseInt(process.env.CIRCLE_NODE_INDEX, 10)
23
+ : 0;
24
+
25
async function checkAll() {
18
- // eslint-disable-next-line no-for-of-loops/no-for-of-loops
19
- for (let rendererInfo of inlinedHostConfigs) {
20
- if (rendererInfo.isFlowTyped) {
21
- await runFlow(rendererInfo.shortName, ['check']);
22
- console.log();
26
+ for (let i = 0; i < inlinedHostConfigs.length; i++) {
27
+ if (i % nodeTotal === nodeIndex) {
28
+ const rendererInfo = inlinedHostConfigs[i];
29
+ if (rendererInfo.isFlowTyped) {
30
+ await runFlow(rendererInfo.shortName, ['check']);
31
+ console.log();
32
+ }
33
}
34
}
35
}