Skip to content

Commit

Permalink
Migrate build tests to combined workflow (facebook#20574)
Browse files Browse the repository at this point in the history
  • Loading branch information
acdlite authored and koto committed Jun 15, 2021
1 parent 99964b9 commit 087886a
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 69 deletions.
94 changes: 33 additions & 61 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: 2
version: 2.1

aliases:
- &docker
Expand Down Expand Up @@ -455,37 +455,20 @@ jobs:
command: yarn lint-build
- run: scripts/circleci/check_minified_errors.sh

yarn_test-stable_build:
docker: *docker
environment: *environment
parallelism: *TEST_PARALLELISM
steps:
- checkout
- attach_workspace: *attach_workspace
- run: yarn workspaces info | head -n -1 > workspace_info.txt
- *restore_node_modules
- run: yarn test-stable --build --ci

yarn_test_build:
docker: *docker
environment: *environment
parallelism: *TEST_PARALLELISM
parameters:
args:
type: string
steps:
- checkout
- attach_workspace: *attach_workspace
- run: yarn workspaces info | head -n -1 > workspace_info.txt
- *restore_node_modules
- run: yarn test --build --ci

yarn_test_build_devtools:
docker: *docker
environment: *environment
steps:
- checkout
- attach_workspace: *attach_workspace
- attach_workspace:
at: build2
- run: yarn workspaces info | head -n -1 > workspace_info.txt
- *restore_node_modules
- run: yarn test --project=devtools --build --ci
- run: yarn test --build <<parameters.args>> --ci

RELEASE_CHANNEL_stable_yarn_test_dom_fixtures:
docker: *docker
Expand Down Expand Up @@ -518,28 +501,6 @@ jobs:
FUZZ_TEST_SEED=$RANDOM yarn test fuzz --ci
FUZZ_TEST_SEED=$RANDOM yarn test --prod fuzz --ci
yarn_test-stable_build_prod:
docker: *docker
environment: *environment
parallelism: *TEST_PARALLELISM
steps:
- checkout
- attach_workspace: *attach_workspace
- run: yarn workspaces info | head -n -1 > workspace_info.txt
- *restore_node_modules
- run: yarn test-stable --build --prod --ci

yarn_test_build_prod:
docker: *docker
environment: *environment
parallelism: *TEST_PARALLELISM
steps:
- checkout
- attach_workspace: *attach_workspace
- run: yarn workspaces info | head -n -1 > workspace_info.txt
- *restore_node_modules
- run: yarn test --build --prod --ci

workflows:
version: 2
stable:
Expand Down Expand Up @@ -584,12 +545,6 @@ workflows:
- RELEASE_CHANNEL_stable_yarn_lint_build:
requires:
- RELEASE_CHANNEL_stable_yarn_build
- yarn_test-stable_build:
requires:
- RELEASE_CHANNEL_stable_yarn_build
- yarn_test-stable_build_prod:
requires:
- RELEASE_CHANNEL_stable_yarn_build
- RELEASE_CHANNEL_stable_yarn_test_dom_fixtures:
requires:
- RELEASE_CHANNEL_stable_yarn_build
Expand Down Expand Up @@ -624,18 +579,9 @@ workflows:
- sizebot_experimental:
requires:
- yarn_build
- yarn_test_build:
requires:
- yarn_build
- yarn_test_build_prod:
requires:
- yarn_build
- yarn_lint_build:
requires:
- yarn_build
- yarn_test_build_devtools:
requires:
- yarn_build
- build_devtools_and_process_artifacts:
requires:
- yarn_build
Expand All @@ -660,6 +606,32 @@ workflows:
- process_artifacts_combined:
requires:
- yarn_build_combined
- yarn_test_build:
requires:
- yarn_build_combined
matrix:
parameters:
args:
# Intentionally passing these as strings instead of creating a
# separate parameter per CLI argument, since it's easier to
# control/see which combinations we want to run.
- "-r=stable --env=development"
- "-r=stable --env=production"
- "-r=experimental --env=development"
- "-r=experimental --env=production"

# Dev Tools
- "--project=devtools -r=experimental"

# TODO: Update test config to support www build tests
# - "-r=www-classic --env=development"
# - "-r=www-classic --env=production"
# - "-r=www-classic --env=development --variant"
# - "-r=www-classic --env=production --variant"
# - "-r=www-modern --env=development"
# - "-r=www-modern --env=production"
# - "-r=www-modern --env=development --variant"
# - "-r=www-modern --env=production --variant"

fuzz_tests:
triggers:
Expand Down
11 changes: 8 additions & 3 deletions scripts/jest/config.build-devtools.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ const {readdirSync, statSync} = require('fs');
const {join} = require('path');
const baseConfig = require('./config.base');

const NODE_MODULES_DIR =
process.env.RELEASE_CHANNEL === 'stable' ? 'oss-stable' : 'oss-experimental';

// Find all folders in packages/* with package.json
const packagesRoot = join(__dirname, '..', '..', 'packages');
const packages = readdirSync(packagesRoot).filter(dir => {
Expand Down Expand Up @@ -32,11 +35,13 @@ moduleNameMapper['react-devtools-feature-flags'] =
// Map packages to bundles
packages.forEach(name => {
// Root entry point
moduleNameMapper[`^${name}$`] = `<rootDir>/build/node_modules/${name}`;
moduleNameMapper[
`^${name}$`
] = `<rootDir>/build2/${NODE_MODULES_DIR}/${name}`;
// Named entry points
moduleNameMapper[
`^${name}\/([^\/]+)$`
] = `<rootDir>/build/node_modules/${name}/$1`;
] = `<rootDir>/build2/${NODE_MODULES_DIR}/${name}/$1`;
});

// Allow tests to import shared code (e.g. feature flags, getStackByFiberInDevAndProd)
Expand All @@ -50,7 +55,7 @@ module.exports = Object.assign({}, baseConfig, {
// Don't run bundle tests on -test.internal.* files
testPathIgnorePatterns: ['/node_modules/', '-test.internal.js$'],
// Exclude the build output from transforms
transformIgnorePatterns: ['/node_modules/', '<rootDir>/build/'],
transformIgnorePatterns: ['/node_modules/', '<rootDir>/build2/'],
testRegex: 'packages/react-devtools-shared/src/__tests__/[^]+.test.js$',
snapshotSerializers: [
require.resolve(
Expand Down
11 changes: 8 additions & 3 deletions scripts/jest/config.build.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ const baseConfig = require('./config.base');

process.env.IS_BUILD = true;

const NODE_MODULES_DIR =
process.env.RELEASE_CHANNEL === 'stable' ? 'oss-stable' : 'oss-experimental';

// Find all folders in packages/* with package.json
const packagesRoot = join(__dirname, '..', '..', 'packages');
const packages = readdirSync(packagesRoot).filter(dir => {
Expand Down Expand Up @@ -35,11 +38,13 @@ moduleNameMapper[
// Map packages to bundles
packages.forEach(name => {
// Root entry point
moduleNameMapper[`^${name}$`] = `<rootDir>/build/node_modules/${name}`;
moduleNameMapper[
`^${name}$`
] = `<rootDir>/build2/${NODE_MODULES_DIR}/${name}`;
// Named entry points
moduleNameMapper[
`^${name}\/([^\/]+)$`
] = `<rootDir>/build/node_modules/${name}/$1`;
] = `<rootDir>/build2/${NODE_MODULES_DIR}/${name}/$1`;
});

module.exports = Object.assign({}, baseConfig, {
Expand All @@ -52,7 +57,7 @@ module.exports = Object.assign({}, baseConfig, {
// Don't run bundle tests on -test.internal.* files
testPathIgnorePatterns: ['/node_modules/', '-test.internal.js$'],
// Exclude the build output from transforms
transformIgnorePatterns: ['/node_modules/', '<rootDir>/build/'],
transformIgnorePatterns: ['/node_modules/', '<rootDir>/build2/'],
setupFiles: [
...baseConfig.setupFiles,
require.resolve('./setupTests.build.js'),
Expand Down
4 changes: 2 additions & 2 deletions scripts/jest/jest-cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,10 +212,10 @@ function validateOptions() {

if (argv.build) {
// TODO: We could build this if it hasn't been built yet.
const buildDir = path.resolve('./build');
const buildDir = path.resolve('./build2');
if (!fs.existsSync(buildDir)) {
logError(
'Build directory does not exist, please run `yarn build` or remove the --build option.'
'Build directory does not exist, please run `yarn build-combined` or remove the --build option.'
);
success = false;
} else if (Date.now() - fs.statSync(buildDir).mtimeMs > 1000 * 60 * 15) {
Expand Down

0 comments on commit 087886a

Please sign in to comment.