Skip to content

Commit d60ac44

Browse files
committed
[ci] Parallelize yarn build and yarn lint-build
ghstack-source-id: 636f2bb Pull Request resolved: #30071
1 parent c6bde50 commit d60ac44

File tree

4 files changed

+950
-14
lines changed

4 files changed

+950
-14
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ jobs:
9797
steps:
9898
- checkout
9999
- setup_node_modules
100-
- run: yarn build
100+
- run: yarn build --ci=circleci
101101
- persist_to_workspace:
102102
root: .
103103
paths:

.github/workflows/runtime_build.yml

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,33 @@ on:
88
- 'compiler/**'
99

1010
jobs:
11+
define_build_params:
12+
name: Build build params
13+
runs-on: ubuntu-latest
14+
outputs:
15+
bundle_type: ${{ steps.define_bundle_types.outputs.result }}
16+
release_channel: ${{ steps.define_release_channels.outputs.result }}
17+
steps:
18+
- uses: actions/github-script@v7
19+
id: define_bundle_types
20+
with:
21+
script: |
22+
const {bundleTypes} = require('.scripts/rollup/bundles');
23+
return Object.values(bundleTypes);
24+
- uses: actions/github-script@v7
25+
id: define_release_channels
26+
with:
27+
script: |
28+
return ['stable', 'experimental'];
29+
1130
build:
1231
name: yarn build
1332
runs-on: ubuntu-latest
33+
needs: define_build_params
34+
strategy:
35+
matrix:
36+
bundle_type: ${{ fromJSON(needs.define_build_params.outputs.bundle_type) }}
37+
release_channel: ${{ fromJSON(needs.define_build_params.outputs.release_channel) }}
1438
steps:
1539
- uses: actions/checkout@v4
1640
- uses: actions/setup-node@v4
@@ -25,17 +49,17 @@ jobs:
2549
path: "**/node_modules"
2650
key: ${{ runner.arch }}-${{ runner.os }}-modules-${{ hashFiles('yarn.lock') }}
2751
- run: yarn install --frozen-lockfile
28-
- run: yarn build
29-
- name: Cache build
30-
uses: actions/cache@v4
31-
id: build_cache
52+
- run: yarn build --b=${{ matrix.bundle_type }} --r=${{ matrix.release_channel }} --ci=github
53+
- name: Archive build
54+
uses: actions/upload-artifact@v4
3255
with:
33-
path: "build/**"
34-
key: yarn-build-${{ runner.arch }}-${{ runner.os }}-modules-${{ hashFiles('yarn.lock') }}
56+
name: build-${{ matrix.release_channel }}-${{ matrix.bundle_type }}
57+
path: |
58+
build/**
3559
3660
lint_build:
3761
name: yarn lint-build
38-
needs: build
62+
needs: [define_build_params, build]
3963
runs-on: ubuntu-latest
4064
steps:
4165
- uses: actions/checkout@v4
@@ -50,11 +74,9 @@ jobs:
5074
with:
5175
path: "**/node_modules"
5276
key: ${{ runner.arch }}-${{ runner.os }}-modules-${{ hashFiles('yarn.lock') }}
53-
- name: Restore cached build
54-
uses: actions/cache@v4
55-
id: build_cache
77+
- name: Restore archived build
78+
uses: actions/download-artifact@v4
5679
with:
57-
path: "build/**"
58-
key: yarn-build-${{ runner.arch }}-${{ runner.os }}-modules-${{ hashFiles('yarn.lock') }}
80+
name: build-${{ needs.define_build_params.outputs.release_channel }}-${{ needs.define_build_params.outputs.bundle_type }}
5981
- run: yarn install --frozen-lockfile
6082
- run: yarn lint-build

scripts/rollup/build-all-release-channels.js

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ const {
1515
canaryChannelLabel,
1616
rcNumber,
1717
} = require('../../ReactVersions');
18+
const yargs = require('yargs');
19+
const Bundles = require('./bundles');
20+
const {buildEverything} = require('./build-ghaction');
1821

1922
// Runs the build script for both stable and experimental release channels,
2023
// by configuring an environment variable.
@@ -53,7 +56,48 @@ fs.writeFileSync(
5356
`export default '${PLACEHOLDER_REACT_VERSION}';\n`
5457
);
5558

56-
if (process.env.CIRCLE_NODE_TOTAL) {
59+
const argv = yargs.wrap(yargs.terminalWidth()).options({
60+
releaseChannel: {
61+
alias: 'r',
62+
describe: 'Build the given release channel.',
63+
requiresArg: true,
64+
type: 'string',
65+
default: 'experimental',
66+
choices: ['experimental', 'stable'],
67+
},
68+
bundleType: {
69+
alias: 'b',
70+
describe: 'Build the given bundle type.',
71+
requiresArg: true,
72+
type: 'string',
73+
choices: Object.values(Bundles.bundleTypes),
74+
},
75+
ci: {
76+
describe: 'Run tests in CI',
77+
requiresArg: false,
78+
type: 'choices',
79+
choices: ['circleci', 'github'],
80+
},
81+
}).argv;
82+
83+
if (argv.ci === 'github') {
84+
// ./scripts/rollup/build was being used by spawning a new process and passing via ENV variables
85+
// so let's just preserve this for now and rewrite it later to just take a function arg
86+
process.env.RELEASE_CHANNEL = argv.releaseChannel;
87+
buildEverything(argv.bundleType);
88+
switch (argv.releaseChannel) {
89+
case 'stable': {
90+
processStable('./build');
91+
break;
92+
}
93+
case 'experimental': {
94+
processExperimental('./build');
95+
break;
96+
}
97+
default:
98+
throw new Error(`Unknown release channel ${argv.releaseChannel}`);
99+
}
100+
} else if (argv.ci === 'circleci') {
57101
// In CI, we use multiple concurrent processes. Allocate half the processes to
58102
// build the stable channel, and the other half for experimental. Override
59103
// the environment variables to "trick" the underlying build script.

0 commit comments

Comments
 (0)