From 9a6a41d108e1bb7c4babebebad7e72daa22a2374 Mon Sep 17 00:00:00 2001 From: Andrew Clark Date: Tue, 12 Jan 2021 11:50:38 -0600 Subject: [PATCH] Migrate build tests to combined workflow (#20574) --- .circleci/config.yml | 94 ++++++++++----------------- scripts/jest/config.build-devtools.js | 11 +++- scripts/jest/config.build.js | 11 +++- scripts/jest/jest-cli.js | 4 +- 4 files changed, 51 insertions(+), 69 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index a532fb2e067a7..75d8f945e9918 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,4 +1,4 @@ -version: 2 +version: 2.1 aliases: - &docker @@ -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 <> --ci RELEASE_CHANNEL_stable_yarn_test_dom_fixtures: docker: *docker @@ -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: @@ -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 @@ -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 @@ -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: diff --git a/scripts/jest/config.build-devtools.js b/scripts/jest/config.build-devtools.js index 39985e7416e18..0d5a6039e414d 100644 --- a/scripts/jest/config.build-devtools.js +++ b/scripts/jest/config.build-devtools.js @@ -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 => { @@ -32,11 +35,13 @@ moduleNameMapper['react-devtools-feature-flags'] = // Map packages to bundles packages.forEach(name => { // Root entry point - moduleNameMapper[`^${name}$`] = `/build/node_modules/${name}`; + moduleNameMapper[ + `^${name}$` + ] = `/build2/${NODE_MODULES_DIR}/${name}`; // Named entry points moduleNameMapper[ `^${name}\/([^\/]+)$` - ] = `/build/node_modules/${name}/$1`; + ] = `/build2/${NODE_MODULES_DIR}/${name}/$1`; }); // Allow tests to import shared code (e.g. feature flags, getStackByFiberInDevAndProd) @@ -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/', '/build/'], + transformIgnorePatterns: ['/node_modules/', '/build2/'], testRegex: 'packages/react-devtools-shared/src/__tests__/[^]+.test.js$', snapshotSerializers: [ require.resolve( diff --git a/scripts/jest/config.build.js b/scripts/jest/config.build.js index fe83740fa4fe7..95bc0e633ce5e 100644 --- a/scripts/jest/config.build.js +++ b/scripts/jest/config.build.js @@ -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 => { @@ -35,11 +38,13 @@ moduleNameMapper[ // Map packages to bundles packages.forEach(name => { // Root entry point - moduleNameMapper[`^${name}$`] = `/build/node_modules/${name}`; + moduleNameMapper[ + `^${name}$` + ] = `/build2/${NODE_MODULES_DIR}/${name}`; // Named entry points moduleNameMapper[ `^${name}\/([^\/]+)$` - ] = `/build/node_modules/${name}/$1`; + ] = `/build2/${NODE_MODULES_DIR}/${name}/$1`; }); module.exports = Object.assign({}, baseConfig, { @@ -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/', '/build/'], + transformIgnorePatterns: ['/node_modules/', '/build2/'], setupFiles: [ ...baseConfig.setupFiles, require.resolve('./setupTests.build.js'), diff --git a/scripts/jest/jest-cli.js b/scripts/jest/jest-cli.js index 19e3879c776a8..76fdd7e67581a 100644 --- a/scripts/jest/jest-cli.js +++ b/scripts/jest/jest-cli.js @@ -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) {