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

chore: e2e/integration with React 17 & 18 #35320

Merged
merged 13 commits into from
Apr 7, 2022
128 changes: 32 additions & 96 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,48 +113,22 @@ aliases:

e2e_tests_production_runtime_alias: &e2e_tests_production_runtime_alias
<<: *e2e-executor
parameters:
nightly:
type: boolean
default: false
steps:
- e2e-test:
test_path: e2e-tests/production-runtime
test_command: CYPRESS_PROJECT_ID=is8aoq CYPRESS_RECORD_KEY=cb4708d2-1578-4665-9a07-c59f8db28d91 yarn test && CYPRESS_PROJECT_ID=htpvkv CYPRESS_RECORD_KEY=0d734841-c613-41d2-86e5-df0b5968f93f yarn test:offline
skip_file_change_test: << parameters.nightly >>
- notify-status:
condition: << parameters.nightly >>

e2e_tests_development_runtime_alias: &e2e_tests_development_runtime_alias
<<: *e2e-executor
parameters:
nightly:
type: boolean
default: false
environment:
<<: *e2e-executor-env
CYPRESS_PROJECT_ID: s3j3qj
CYPRESS_RECORD_KEY: 3904ca0c-bc98-47d9-8371-b68c5e81fb9b
steps:
- e2e-test:
test_path: e2e-tests/development-runtime
skip_file_change_test: << parameters.nightly >>
- notify-status:
condition: << parameters.nightly >>

commands:
notify-status:
parameters:
condition:
type: boolean
default: false
steps:
- when:
condition: << parameters.condition >>
steps:
- slack/status:
channel: eng-react-integration-status

e2e-test:
parameters:
skip_file_change_test:
Expand All @@ -168,6 +142,9 @@ commands:
test_command:
type: string
default: "yarn test"
react_version:
type: string
default: ""
steps:
- checkout
# In case of failure, add these steps again. Cache probably got deleted
Expand All @@ -180,6 +157,14 @@ commands:
- run: ./scripts/assert-changed-files.sh "<< parameters.trigger_pattern >>|<< parameters.test_path >>/*"

- <<: *attach_to_bootstrap
- when:
condition:
not:
equal: ["", << parameters.react_version >>]
steps:
- run:
name: Upgrade React to << parameters.react_version >>
command: "REACT_VERSION=<< parameters.react_version >> TEST_PATH=<< parameters.test_path >> node ./scripts/upgrade-react"
- run:
name: Install gatsby-dev
command: yarn global add gatsby-dev-cli
Expand Down Expand Up @@ -378,20 +363,27 @@ jobs:
e2e_tests_development_runtime:
<<: *e2e_tests_development_runtime_alias

e2e_tests_development_runtime_with_experimental_react:
<<: *e2e_tests_development_runtime_alias

e2e_tests_development_runtime_with_next_react:
<<: *e2e_tests_development_runtime_alias
e2e_tests_development_runtime_with_react_18:
<<: *e2e-executor
environment:
<<: *e2e-executor-env
CYPRESS_PROJECT_ID: nusozx
CYPRESS_RECORD_KEY: 6500fa9b-7710-4968-b321-1a544c9a1fdc
steps:
- e2e-test:
test_path: e2e-tests/development-runtime
react_version: "^18.0.0"

e2e_tests_production_runtime:
<<: *e2e_tests_production_runtime_alias

e2e_tests_production_runtime_with_experimental_react:
<<: *e2e_tests_production_runtime_alias

e2e_tests_production_runtime_with_next_react:
<<: *e2e_tests_production_runtime_alias
e2e_tests_production_runtime_with_react_18:
<<: *e2e-executor
steps:
- e2e-test:
test_path: e2e-tests/production-runtime
test_command: CYPRESS_PROJECT_ID=5k8zbj CYPRESS_RECORD_KEY=ec36ff6b-3db9-48a9-8f7b-2faf301ab800 yarn test && CYPRESS_PROJECT_ID=yvdct2 CYPRESS_RECORD_KEY=2a4f4f31-0dfb-4a56-80e0-9ed42a1131a4 yarn test:offline
react_version: "^18.0.0"

themes_e2e_tests_development_runtime:
<<: *e2e-executor
Expand Down Expand Up @@ -556,69 +548,9 @@ jobs:
- store_test_results:
path: ./test-results/jest-node/

bootstrap-with-experimental-react:
executor: node
parameters:
version:
type: string
default: "next"
steps:
- checkout
# python 2 is not built in and node-gyp needs it to build lmdb
- run: sudo apt-get update && sudo apt-get install python -y
- run:
name: "Update React to prerelease"
command: "REACT_CHANNEL=<< parameters.version >> node ./scripts/upgrade-react"
- run: yarn install
- run: yarn bootstrap -- concurrency=2
- run: yarn list react
- persist_to_workspace:
root: ./
paths:
- "*"

workflows:
version: 2

nightly-react-next:
triggers:
- schedule:
cron: "0 0 * * 1,2,3,4,5"
filters:
branches:
only:
- master
jobs:
- bootstrap-with-experimental-react:
version: "next"
- e2e_tests_development_runtime_with_next_react:
nightly: true
requires:
- bootstrap-with-experimental-react
- e2e_tests_production_runtime_with_next_react:
nightly: true
requires:
- bootstrap-with-experimental-react
nightly-react-experimental:
triggers:
- schedule:
cron: "0 0 * * 1,2,3,4,5"
filters:
branches:
only:
- master
jobs:
- bootstrap-with-experimental-react:
version: "experimental"
- e2e_tests_development_runtime_with_experimental_react:
nightly: true
requires:
- bootstrap-with-experimental-react
- e2e_tests_production_runtime_with_experimental_react:
nightly: true
requires:
- bootstrap-with-experimental-react

# Ideally, we should trigger this when any new release is created, sadly there is no easy way to do it:
# - Can't rely on tags: GitHub won't send webhook to CircleCI when there are more than 3 tags in one push
# See: https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#push
Expand Down Expand Up @@ -692,6 +624,10 @@ workflows:
<<: *e2e-test-workflow
- e2e_tests_production_runtime:
<<: *e2e-test-workflow
- e2e_tests_development_runtime_with_react_18:
<<: *e2e-test-workflow
- e2e_tests_production_runtime_with_react_18:
<<: *e2e-test-workflow
- themes_e2e_tests_production_runtime:
<<: *e2e-test-workflow
- themes_e2e_tests_development_runtime:
Expand Down
4 changes: 2 additions & 2 deletions e2e-tests/contentful/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
"gatsby-transformer-sqip": "3.3.1",
"modern-normalize": "^1.0.0",
"prop-types": "^15.7.2",
"react": "^17.0.1",
"react-dom": "^17.0.1",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"slugify": "^1.5.0"
},
"keywords": [
Expand Down
38 changes: 19 additions & 19 deletions e2e-tests/development-runtime/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,26 @@
"author": "Dustin Schau <[email protected]>",
"dependencies": {
"babel-plugin-search-and-replace": "^1.1.0",
"gatsby": "^4.6.0-next.4",
"gatsby-image": "^3.0.0-next.0",
"gatsby-plugin-image": "^1.0.0-next.5",
"gatsby-plugin-less": "^5.1.0-next.2",
"gatsby-plugin-manifest": "^3.0.0-next.0",
"gatsby-plugin-offline": "^4.0.0-next.1",
"gatsby-plugin-react-helmet": "^4.0.0-next.0",
"gatsby-plugin-sass": "^4.1.0-next.2",
"gatsby-plugin-sharp": "^3.0.0-next.5",
"gatsby-plugin-stylus": "^3.1.0-next.2",
"gatsby-remark-images": "^6.6.0-next.2",
"gatsby": "next",
"gatsby-image": "next",
"gatsby-plugin-image": "next",
"gatsby-plugin-less": "next",
"gatsby-plugin-manifest": "next",
"gatsby-plugin-offline": "next",
"gatsby-plugin-react-helmet": "next",
"gatsby-plugin-sass": "next",
"gatsby-plugin-sharp": "next",
"gatsby-plugin-stylus": "next",
"gatsby-remark-images": "next",
"gatsby-seo": "^0.1.0",
"gatsby-source-filesystem": "^3.0.0-next.2",
"gatsby-transformer-json": "^3.0.0-next.0",
"gatsby-transformer-remark": "^5.6.0-next.2",
"gatsby-transformer-sharp": "^3.0.0-next.1",
"gatsby-source-filesystem": "next",
"gatsby-transformer-json": "next",
"gatsby-transformer-remark": "next",
"gatsby-transformer-sharp": "next",
"node-fetch": "^2.6.1",
"prop-types": "^15.6.2",
"react": "16.9.0",
"react-dom": "16.9.0",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-helmet": "^5.2.1",
"sass": "^1.32.8"
},
Expand Down Expand Up @@ -59,8 +59,8 @@
"cypress": "6.1.0",
"cypress-image-snapshot": "^4.0.1",
"fs-extra": "^7.0.1",
"gatsby-core-utils": "^2.12.0",
"gatsby-cypress": "^0.1.7",
"gatsby-core-utils": "next",
"gatsby-cypress": "next",
"is-ci": "^2.0.0",
"prettier": "2.0.4",
"start-server-and-test": "^1.7.11",
Expand Down
4 changes: 2 additions & 2 deletions e2e-tests/gatsby-image/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"gatsby-plugin-sharp": "^2.0.20",
"gatsby-source-filesystem": "^2.0.20",
"gatsby-transformer-sharp": "^2.1.13",
"react": "^16.9.0",
"react-dom": "^16.9.0",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-helmet": "^5.2.0"
},
"keywords": [
Expand Down
4 changes: 2 additions & 2 deletions e2e-tests/gatsby-static-image/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"gatsby-plugin-image": "^0.0.2",
"gatsby-plugin-sharp": "^2.0.20",
"gatsby-source-filesystem": "^3.3.0",
"react": "^16.9.0",
"react-dom": "^16.9.0"
"react": "^17.0.2",
"react-dom": "^17.0.2"
},
"keywords": [
"gatsby"
Expand Down
4 changes: 2 additions & 2 deletions e2e-tests/mdx-less-babel/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"gatsby": "^2.0.118",
"gatsby-plugin-mdx": "^1.2.19",
"gatsby-source-filesystem": "^2.3.14",
"react": "^16.9.0",
"react-dom": "^16.9.0",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"theme-ui": "^0.3.1"
},
"keywords": [
Expand Down
4 changes: 2 additions & 2 deletions e2e-tests/mdx/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
"gatsby": "^3.0.0",
"gatsby-plugin-mdx": "^2.0.0",
"gatsby-source-filesystem": "^3.0.0",
"react": "^17.0.0",
"react-dom": "^17.0.0",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"theme-ui": "^0.3.1"
},
"keywords": [
Expand Down
4 changes: 2 additions & 2 deletions e2e-tests/path-prefix/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
"gatsby-plugin-sitemap": "^2.0.12",
"gatsby-source-filesystem": "^2.8.1",
"gatsby-transformer-sharp": "^2.9.0",
"react": "^16.9.0",
"react-dom": "^16.9.0",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-helmet": "^5.2.0"
},
"keywords": [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
describe(`Production build tests`, () => {
// TODO: In https://github.com/gatsbyjs/gatsby/pull/35226 the skip needs to be removed

describe.skip(`Production build tests`, () => {
it(`should remount when navigating to different template`, () => {
cy.visit(`/`).waitForRouteChange()

Expand Down
4 changes: 2 additions & 2 deletions e2e-tests/production-runtime/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
"gatsby-seo": "^0.1.0",
"gatsby-source-filesystem": "^4.1.3",
"glob": "^7.1.3",
"react": "^16.9.0",
"react-dom": "^16.9.0",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-helmet": "^5.2.0",
"sass": "^1.32.8",
"typeface-merriweather": "^1.1.13"
Expand Down
44 changes: 20 additions & 24 deletions e2e-tests/production-runtime/src/utils/instrument-page.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,29 @@
import * as React from "react"

export default Page =>
class extends React.Component {
addLogEntry(action) {
function InstrumentPage(Component) {
return function WithInstrumentPageComponent({ ...props }) {
function addLogEntry(action) {
if (typeof window !== `undefined`) {
window.___PageComponentLifecycleCallsLog.push({
action,
pageComponent: this.props.pageResources.page.componentChunkName,
locationPath: this.props.location.pathname,
pagePath: this.props.pageResources.page.path,
pageComponent: props.pageResources.page.componentChunkName,
locationPath: props.location.pathname,
pagePath: props.pageResources.page.path,
})
}
}

constructor(props) {
super(props)
this.addLogEntry(`constructor`)
}

componentDidMount() {
this.addLogEntry(`componentDidMount`)
}

componentWillUnmount() {
this.addLogEntry(`componentWillUnmount`)
}

render() {
this.addLogEntry(`render`)
return <Page {...this.props} />
}

React.useEffect(() => {
addLogEntry(`componentDidMount`)
return () => {
addLogEntry(`componentWillUnmount`)
}
}, [])

addLogEntry(`render`)

return <Component {...props} />
}
}

export default InstrumentPage
4 changes: 2 additions & 2 deletions e2e-tests/themes/development-runtime/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"dependencies": {
"gatsby": "^2.13.14",
"gatsby-theme-about": "*",
"react": "^16.9.0",
"react-dom": "^16.9.0"
"react": "^17.0.2",
"react-dom": "^17.0.2"
},
"license": "MIT",
"scripts": {
Expand Down
Loading