From b145bfa7ccd9dae018a93c0eeb3660642cf26c33 Mon Sep 17 00:00:00 2001 From: Josh Black Date: Tue, 8 Jul 2025 14:16:11 -0500 Subject: [PATCH 1/2] ci: add support for testing React 19 --- .github/workflows/ci.yml | 10 ++++++++ script/setup-react-19.mts | 49 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 script/setup-react-19.mts diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7819ca11b48..3eb4fa816a0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -53,6 +53,9 @@ jobs: test: runs-on: ubuntu-latest + strategy: + matrix: + react-version: [18, 19] steps: - name: Checkout repository uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 @@ -61,6 +64,8 @@ jobs: with: node-version: 22 cache: 'npm' + - if: ${{ matrix.react-version == 19 }} + run: node --experimental-strip-types script/setup-react-19.mts - name: Install dependencies run: npm ci - name: Build @@ -74,6 +79,9 @@ jobs: type-check: runs-on: ubuntu-latest + strategy: + matrix: + react-version: [18, 19] steps: - name: Checkout repository uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 @@ -82,6 +90,8 @@ jobs: with: node-version: 22 cache: 'npm' + - if: ${{ matrix.react-version == 19 }} + run: node --experimental-strip-types script/setup-react-19.mts - name: Install dependencies run: npm ci - name: Build project diff --git a/script/setup-react-19.mts b/script/setup-react-19.mts new file mode 100644 index 00000000000..75c8ca67baf --- /dev/null +++ b/script/setup-react-19.mts @@ -0,0 +1,49 @@ +import fs from 'node:fs' +import {spawn as spawnCallback} from 'node:child_process' +import path from 'node:path' +import {promisify} from 'node:util' + +const spawn = promisify(spawnCallback) +const ROOT_DIRECTORY = path.resolve(import.meta.dirname, '../') +const workspaces = ['examples/codesandbox', 'examples/nextjs', 'examples/theming', 'packages/react'] + +async function main() { + const overrides = { + react: '19.1.0', + 'react-dom': '19.1.0', + 'react-test-renderer': '19.1.0', + '@types/react': '19.1.4', + '@types/react-dom': '19.1.5', + } as const + + for (const workspace of workspaces) { + const packageJsonPath = path.join(ROOT_DIRECTORY, workspace, 'package.json') + const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8')) + + for (const [key, value] of Object.entries(overrides)) { + if (packageJson.devDependencies?.[key]) { + packageJson.devDependencies[key] = value + } + + if (packageJson.dependencies?.[key]) { + packageJson.dependencies[key] = value + } + + if (packageJson.peerDependencies?.[key]) { + packageJson.peerDependencies[key] = value + } + } + + fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2) + '\n') + } + + await spawn('npm', ['install'], { + cwd: ROOT_DIRECTORY, + stdio: 'inherit', + }) +} + +main().catch(error => { + console.error(error) + process.exit(1) +}) From 9cd2049cae9239de723941be13cc31ad7edc4b63 Mon Sep 17 00:00:00 2001 From: Josh Black Date: Tue, 8 Jul 2025 14:26:02 -0500 Subject: [PATCH 2/2] ci: disable fail fast --- .github/workflows/ci.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3eb4fa816a0..356022c096e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -54,8 +54,9 @@ jobs: test: runs-on: ubuntu-latest strategy: + fail-fast: false matrix: - react-version: [18, 19] + react-version: [react-18, react-19] steps: - name: Checkout repository uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 @@ -64,7 +65,7 @@ jobs: with: node-version: 22 cache: 'npm' - - if: ${{ matrix.react-version == 19 }} + - if: ${{ matrix.react-version == 'react-19' }} run: node --experimental-strip-types script/setup-react-19.mts - name: Install dependencies run: npm ci @@ -80,8 +81,9 @@ jobs: type-check: runs-on: ubuntu-latest strategy: + fail-fast: false matrix: - react-version: [18, 19] + react-version: [react-18, react-19] steps: - name: Checkout repository uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 @@ -90,7 +92,7 @@ jobs: with: node-version: 22 cache: 'npm' - - if: ${{ matrix.react-version == 19 }} + - if: ${{ matrix.react-version == 'react-19' }} run: node --experimental-strip-types script/setup-react-19.mts - name: Install dependencies run: npm ci