@samitouri / QOS-React / commits / 419ace93ec

[ci] Parallelize flow github action

The existing flow-ci script makes some assumptions about running inside of circleci for parallelization. This PR forks the script with very smal ll tweaks to allow for a short name to be passed in as an argument. These short names are discovered in a new GH job and then each one is passed as an argument for parallelization ghstack-source-id: dc85486388f74088c22b386b77b45996ef753f1a Pull Request resolved: https://github.com/facebook/react/pull/30026

Lauren Tan committed Jun 21, 2024 at 12:19 UTC 419ace93ecf4a1d941d5b29ad2664f64c467d6d8
2 files changed +54 -2
.github/workflows/flow.yml
+24 -2
@@ -4,11 +4,32 @@ on:
4 push:
5 branches: [main]
6 pull_request:
7 + paths-ignore:
8 + - 'compiler/**'
9
10 jobs:
11 + discover_flow_inline_configs:
12 + name: Discover flow inline configs
13 + runs-on: ubuntu-latest
14 + outputs:
15 + matrix: ${{ steps.set-matrix.outputs.result }}
16 + steps:
17 + - uses: actions/checkout@v4
18 + - uses: actions/github-script@v7
19 + id: set-matrix
20 + with:
21 + script: |
22 + const inlinedHostConfigs = require('./scripts/shared/inlinedHostConfigs.js');
23 + return inlinedHostConfigs.map(config => config.shortName);
24 +
25 flow:
10 - name: Run flow
26 + name: Flow check ${{ matrix.flow_inline_config_shortname }}
27 + needs: discover_flow_inline_configs
28 runs-on: ubuntu-latest
29 + continue-on-error: true
30 + strategy:
31 + matrix:
32 + flow_inline_config_shortname: ${{ fromJSON(needs.discover_flow_inline_configs.outputs.matrix) }}
33 steps:
34 - uses: actions/checkout@v4
35 - uses: actions/setup-node@v4
@@ -18,8 +39,9 @@ jobs:
39 cache-dependency-path: yarn.lock
40 - name: Restore cached node_modules
41 uses: actions/cache@v4
42 + id: node_modules
43 with:
44 path: "**/node_modules"
45 key: ${{ runner.arch }}-${{ runner.os }}-modules-${{ hashFiles('yarn.lock') }}
46 - run: yarn install --frozen-lockfile
25 - - run: node ./scripts/tasks/flow-ci
47 + - run: node ./scripts/tasks/flow-ci-ghaction ${{ matrix.flow_inline_config_shortname }}
scripts/tasks/flow-ci-ghaction.js new
+30
@@ -0,0 +1,30 @@
1 +/**
2 + * Copyright (c) Meta Platforms, Inc. and affiliates.
3 + *
4 + * This source code is licensed under the MIT license found in the
5 + * LICENSE file in the root directory of this source tree.
6 + */
7 +
8 +'use strict';
9 +
10 +process.on('unhandledRejection', err => {
11 + throw err;
12 +});
13 +
14 +const runFlow = require('../flow/runFlow');
15 +const inlinedHostConfigs = require('../shared/inlinedHostConfigs');
16 +
17 +async function check(shortName) {
18 + if (shortName == null) {
19 + throw new Error('Expected an inlinedHostConfig shortName');
20 + }
21 + const rendererInfo = inlinedHostConfigs.find(
22 + config => config.shortName === shortName
23 + );
24 + if (rendererInfo.isFlowTyped) {
25 + await runFlow(rendererInfo.shortName, ['check']);
26 + console.log();
27 + }
28 +}
29 +
30 +check(process.argv[2]);