diff --git a/.circleci/config.yml b/.circleci/config.yml index c73cf39b0c9d81..624fb005b9c4ba 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -11,6 +11,10 @@ parameters: description: The dist-tag of react to be used type: string default: stable + react-specific-version: + description: The specific version of react to be used + type: string + default: '' workflow: description: The name of the workflow to run type: string @@ -26,6 +30,10 @@ defaults: &defaults description: The dist-tag of react to be used type: string default: << pipeline.parameters.react-dist-tag >> + react-specific-version: + description: The specific version of react to be used + type: string + default: << pipeline.parameters.react-specific-version >> test-gate: description: A particular type of tests that should be run type: string @@ -40,6 +48,7 @@ defaults: &defaults # expose it globally otherwise we have to thread it from each job to the install command BROWSERSTACK_FORCE: << pipeline.parameters.browserstack-force >> REACT_DIST_TAG: << parameters.react-dist-tag >> + REACT_SPECIFIC_VERSION: << parameters.react-specific-version >> TEST_GATE: << parameters.test-gate >> AWS_REGION_ARTIFACTS: eu-central-1 working_directory: /tmp/material-ui @@ -75,6 +84,10 @@ commands: node scripts/use-react-dist-tag # log a patch for maintainers who want to check out this change git --no-pager diff HEAD + - run: + name: Resolve react specific version if set + command: | + node scripts/use-react-version - restore_cache: name: Restore yarn cache keys: @@ -822,6 +835,24 @@ workflows: equal: [profile, << pipeline.parameters.workflow >>] jobs: - test_profile + react-17: + triggers: + - schedule: + cron: '10 13 * * *' + filters: + branches: + only: + - master + - core/add-react-17-night-build + jobs: + - test_unit: + react-specific-version: 17.0.2 + - test_browser: + react-specific-version: 17.0.2 + - test_regressions: + react-specific-version: 17.0.2 + - test_e2e: + react-specific-version: 17.0.2 react-next: triggers: - schedule: diff --git a/.github/workflows/check-label-added.yml b/.github/workflows/check-label-added.yml new file mode 100644 index 00000000000000..9717c6cc26a74f --- /dev/null +++ b/.github/workflows/check-label-added.yml @@ -0,0 +1,16 @@ +name: Check if PR has label + +on: + pull_request: + types: [opened, reopened, labeled, unlabeled] + +jobs: + test-label-applied: + # Tests that label is added on the PR + runs-on: ubuntu-latest + steps: + - uses: mnajdova/github-action-required-labels@v2.0 + with: + mode: minimum + count: 1 + labels: "" diff --git a/.github/workflows/no-response.yml b/.github/workflows/no-response.yml index 496dce78ac0f97..40be2bbfda4f66 100644 --- a/.github/workflows/no-response.yml +++ b/.github/workflows/no-response.yml @@ -23,4 +23,4 @@ jobs: # Comment to post when closing an Issue for lack of response. Set to `false` to disable closeComment: > Since the issue is missing key information and has been inactive for 7 days, it has been automatically closed. - If you wish to see the issue reopened, please provide the missing information. \ No newline at end of file + If you wish to see the issue reopened, please provide the missing information. diff --git a/scripts/use-react-version.js b/scripts/use-react-version.js new file mode 100644 index 00000000000000..641523750c19fb --- /dev/null +++ b/scripts/use-react-version.js @@ -0,0 +1,77 @@ +/* eslint-disable no-console */ +/** + * Given the dist tag fetch the corresponding + * version and make sure this version is used throughout the repository. + * + * If you work on this file: + * WARNING: This script can only use built-in modules since it has to run before + * `yarn install` + */ +const fs = require('fs'); +const os = require('os'); +const path = require('path'); + +// packages published from the react monorepo per version +const versionsSupported = { + '17.0.2': { + react: '17.0.2', + 'react-dom': '17.0.2', + 'react-is': '17.0.2', + 'react-test-renderer': '17.0.2', + scheduler: '0.20.2', + }, +}; + +const devDependencies = { + '17.0.2': { + '@mnajdova/enzyme-adapter-react-18': 'npm:@eps1lon/enzyme-adapter-react-17', + '@testing-library/react': '12.1.5', + }, +}; + +async function main(options) { + const { reactVersion } = options; + + if (typeof reactVersion !== 'string') { + throw new TypeError(`expected reactVersion: string but got '${reactVersion}'`); + } + + if (reactVersion === '') { + // do nothing + return; + } + + if (!versionsSupported[reactVersion]) { + console.log( + `This version is not supported. This is the list of all supported versions: ${Object.keys( + versionsSupported, + )}`, + ); + return; + } + + const packageJsonPath = path.resolve(__dirname, '../package.json'); + const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, { encoding: 'utf8' })); + + const reactPackageNames = versionsSupported[reactVersion]; + + await Promise.all( + Object.keys(reactPackageNames).map(async (reactPackageName) => { + packageJson.resolutions[reactPackageName] = reactPackageNames[reactPackageName]; + }), + ); + + packageJson.devDependencies['@mnajdova/enzyme-adapter-react-18'] = + devDependencies[reactVersion]['@mnajdova/enzyme-adapter-react-18']; + packageJson.devDependencies['@testing-library/react'] = + devDependencies[reactVersion]['@testing-library/react']; + + // add newline for clean diff + fs.writeFileSync(packageJsonPath, `${JSON.stringify(packageJson, null, 2)}${os.EOL}`); +} + +const [reactVersion = process.env.REACT_SPECIFIC_VERSION] = process.argv.slice(2); +main({ reactVersion }).catch((error) => { + console.error(error); + process.exit(1); +});