Skip to content

Commit

Permalink
[ci] Parallelize yarn build and yarn lint-build
Browse files Browse the repository at this point in the history
ghstack-source-id: 33b498fd49f158d6947b4e6b38a99452328e59ef
Pull Request resolved: #30071
  • Loading branch information
poteto committed Jun 24, 2024
1 parent 6bb455b commit 3a1f728
Show file tree
Hide file tree
Showing 4 changed files with 951 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ jobs:
steps:
- checkout
- setup_node_modules
- run: yarn build
- run: yarn build --ci=circleci
- persist_to_workspace:
root: .
paths:
Expand Down
47 changes: 35 additions & 12 deletions .github/workflows/runtime_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,34 @@ on:
- 'compiler/**'

jobs:
define_build_params:
name: Build build params
runs-on: ubuntu-latest
outputs:
bundle_type: ${{ steps.define_bundle_types.outputs.result }}
release_channel: ${{ steps.define_release_channels.outputs.result }}
steps:
- uses: actions/checkout@v4
- uses: actions/github-script@v7
id: define_bundle_types
with:
script: |
const {bundleTypes} = require('./scripts/rollup/bundles');
return Object.values(bundleTypes);
- uses: actions/github-script@v7
id: define_release_channels
with:
script: |
return ['stable', 'experimental'];
build:
name: yarn build
runs-on: ubuntu-latest
needs: define_build_params
strategy:
matrix:
bundle_type: ${{ fromJSON(needs.define_build_params.outputs.bundle_type) }}
release_channel: ${{ fromJSON(needs.define_build_params.outputs.release_channel) }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
Expand All @@ -25,17 +50,17 @@ jobs:
path: "**/node_modules"
key: ${{ runner.arch }}-${{ runner.os }}-modules-${{ hashFiles('yarn.lock') }}
- run: yarn install --frozen-lockfile
- run: yarn build
- name: Cache build
uses: actions/cache@v4
id: build_cache
- run: yarn build --b=${{ matrix.bundle_type }} --r=${{ matrix.release_channel }} --ci=github
- name: Archive build
uses: actions/upload-artifact@v4
with:
path: "build/**"
key: yarn-build-${{ runner.arch }}-${{ runner.os }}-modules-${{ hashFiles('yarn.lock') }}
name: build-${{ matrix.release_channel }}-${{ matrix.bundle_type }}
path: |
build/**
lint_build:
name: yarn lint-build
needs: build
needs: [define_build_params, build]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -50,11 +75,9 @@ jobs:
with:
path: "**/node_modules"
key: ${{ runner.arch }}-${{ runner.os }}-modules-${{ hashFiles('yarn.lock') }}
- name: Restore cached build
uses: actions/cache@v4
id: build_cache
- name: Restore archived build
uses: actions/download-artifact@v4
with:
path: "build/**"
key: yarn-build-${{ runner.arch }}-${{ runner.os }}-modules-${{ hashFiles('yarn.lock') }}
name: build-${{ needs.define_build_params.outputs.release_channel }}-${{ needs.define_build_params.outputs.bundle_type }}
- run: yarn install --frozen-lockfile
- run: yarn lint-build
46 changes: 45 additions & 1 deletion scripts/rollup/build-all-release-channels.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ const {
canaryChannelLabel,
rcNumber,
} = require('../../ReactVersions');
const yargs = require('yargs');
const Bundles = require('./bundles');
const {buildEverything} = require('./build-ghaction');

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

if (process.env.CIRCLE_NODE_TOTAL) {
const argv = yargs.wrap(yargs.terminalWidth()).options({
releaseChannel: {
alias: 'r',
describe: 'Build the given release channel.',
requiresArg: true,
type: 'string',
default: 'experimental',
choices: ['experimental', 'stable'],
},
bundleType: {
alias: 'b',
describe: 'Build the given bundle type.',
requiresArg: true,
type: 'string',
choices: Object.values(Bundles.bundleTypes),
},
ci: {
describe: 'Run tests in CI',
requiresArg: false,
type: 'choices',
choices: ['circleci', 'github'],
},
}).argv;

if (argv.ci === 'github') {
// ./scripts/rollup/build was being used by spawning a new process and passing via ENV variables
// so let's just preserve this for now and rewrite it later to just take a function arg
process.env.RELEASE_CHANNEL = argv.releaseChannel;
buildEverything(argv.bundleType);
switch (argv.releaseChannel) {
case 'stable': {
processStable('./build');
break;
}
case 'experimental': {
processExperimental('./build');
break;
}
default:
throw new Error(`Unknown release channel ${argv.releaseChannel}`);
}
} else if (argv.ci === 'circleci') {
// In CI, we use multiple concurrent processes. Allocate half the processes to
// build the stable channel, and the other half for experimental. Override
// the environment variables to "trick" the underlying build script.
Expand Down
Loading

0 comments on commit 3a1f728

Please sign in to comment.