Skip to content

Commit

Permalink
[ci] Parallelize flow github action
Browse files Browse the repository at this point in the history
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: 4dee39707ad7608093c88319d8fa80519ebd7248
Pull Request resolved: #30026
  • Loading branch information
poteto committed Jun 21, 2024
1 parent ac3d5fc commit bb9d3e6
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 3 deletions.
26 changes: 23 additions & 3 deletions .github/workflows/flow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,28 @@ on:
pull_request:

jobs:
flow:
name: Run flow
discover_flow_inline_configs:
name: Discover flow inline configs
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.result }}
steps:
- uses: actions/checkout@v4
- uses: actions/github-script@v7
id: set-matrix
with:
script: |
const inlinedHostConfigs = require('./scripts/shared/inlinedHostConfigs.js');
return inlinedHostConfigs.map(config => config.shortName);
Flow:
name: Flow check ${{ matrix.flow_inline_config_shortname }}
needs: discover_flow_inline_configs
runs-on: ubuntu-latest
continue-on-error: true
strategy:
matrix:
flow_inline_config_shortname: ${{ needs.discover_flow_inline_configs.outputs }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
Expand All @@ -18,8 +37,9 @@ jobs:
cache-dependency-path: yarn.lock
- name: Restore cached node_modules
uses: actions/cache@v4
id: node_modules
with:
path: "**/node_modules"
key: ${{ runner.arch }}-${{ runner.os }}-modules-${{ hashFiles('yarn.lock') }}
- run: yarn install --frozen-lockfile
- run: node ./scripts/tasks/flow-ci
- run: node ./scripts/tasks/flow-ci-ghaction ${{ matrix.flow_inline_config_shortname }}
28 changes: 28 additions & 0 deletions scripts/tasks/flow-ci-ghaction.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

'use strict';

process.on('unhandledRejection', err => {
throw err;
});

const runFlow = require('../flow/runFlow');
const inlinedHostConfigs = require('../shared/inlinedHostConfigs');

async function check(idx) {
if (idx == null) {
throw new Error('Expected an inlinedHostConfig index');
}
const rendererInfo = inlinedHostConfigs[+idx];
if (rendererInfo.isFlowTyped) {
await runFlow(rendererInfo.shortName, ['check']);
console.log();
}
}

check(process.argv[2]);

0 comments on commit bb9d3e6

Please sign in to comment.