Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Core/add react 17 night build #33

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
31 changes: 31 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
16 changes: 16 additions & 0 deletions .github/workflows/check-label-added.yml
Original file line number Diff line number Diff line change
@@ -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: ""
2 changes: 1 addition & 1 deletion .github/workflows/no-response.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
If you wish to see the issue reopened, please provide the missing information.
77 changes: 77 additions & 0 deletions scripts/use-react-version.js
Original file line number Diff line number Diff line change
@@ -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);
});