Skip to content

Reduce the TypeScript page to typing connect and move it to the Legac… #1684

Reduce the TypeScript page to typing connect and move it to the Legac…

Reduce the TypeScript page to typing connect and move it to the Legac… #1684

Workflow file for this run

name: Tests
on: [push, pull_request, workflow_dispatch]
permissions:
contents: read
jobs:
build:
name: Build and run test Suite
runs-on: ubuntu-latest
strategy:
matrix:
node: ['24.x']
steps:
- name: Checkout code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false
- name: Install pnpm
uses: pnpm/setup@84cb39b217b10273981911c288cd62326dc7c6d2 # v2.0.2
with:
# Every job here runs its own install step, with the flags that job
# needs. pnpm/setup installs by default, which would install twice.
install: false
- name: Use node ${{ matrix.node }}
uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e # v4.3.0
with:
node-version: ${{ matrix.node }}
cache: 'pnpm'
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Lint
run: pnpm lint
- name: Check formatting
run: pnpm format:check
- name: Run test suite
run: pnpm test
- name: Build
run: pnpm build
# `pnpm pack` names the tarball `<name>-<version>.tgz`; `yarn pack`
# defaulted to `package.tgz`, which every downstream job expects.
- name: Pack
run: pnpm pack --out package.tgz
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: package
path: ./package.tgz
test-types:
name: Test Types with TypeScript ${{ matrix.ts }} and React ${{ matrix.react.version }}
needs: [build]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node: ['24.x']
ts: ['5.6', '5.7', '5.8', '5.9', '6.0']
react:
[
{
version: '^18',
types: ^18,
react-dom: { version: '^18', types: '^18' },
},
{
version: '^19',
types: '^19',
react-dom: { version: '^19', types: '^19' },
},
]
steps:
- name: Checkout repo
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false
- name: Install pnpm
uses: pnpm/setup@84cb39b217b10273981911c288cd62326dc7c6d2 # v2.0.2
with:
# Every job here runs its own install step, with the flags that job
# needs. pnpm/setup installs by default, which would install twice.
install: false
- name: Use node ${{ matrix.node }}
uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e # v4.3.0
with:
node-version: ${{ matrix.node }}
cache: 'pnpm'
- name: Download build artifact
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
name: package
path: .
- name: Install deps
run: pnpm install --frozen-lockfile
- name: Install React ${{ matrix.react.version }} and React-DOM ${{ matrix.react.react-dom.version }}
run: pnpm add -D react@${{ matrix.react.version }} react-dom@${{ matrix.react.react-dom.version }} @types/react@${{ matrix.react.types }} @types/react-dom@${{ matrix.react.react-dom.types }}
- name: Install TypeScript ${{ matrix.ts }}
run: pnpm add typescript@${{ matrix.ts }}
- name: Install build artifact
run: pnpm add ./package.tgz
- name: Erase path aliases
run: sed -i -e /@remap-prod-remove-line/d ./tsconfig.base.json
- name: Test types
env:
TEST_DIST: true
run: |
pnpm exec tsc --version
pnpm type-tests
test-types-typescript-7:
name: 'Test Types: TypeScript 7 (advisory)'
runs-on: ubuntu-latest
# Advisory only. TypeScript 7 is not a supported target yet, so this job
# reports differences without blocking the workflow.
continue-on-error: true
strategy:
fail-fast: false
matrix:
node: ['24.x']
steps:
- name: Checkout repo
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false
- name: Install pnpm
uses: pnpm/setup@84cb39b217b10273981911c288cd62326dc7c6d2 # v2.0.2
with:
# Every job here runs its own install step, with the flags that job
# needs. pnpm/setup installs by default, which would install twice.
install: false
- name: Use node ${{ matrix.node }}
uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e # v4.3.0
with:
node-version: ${{ matrix.node }}
cache: 'pnpm'
- name: Install deps
run: pnpm install --frozen-lockfile
# Installed under an npm alias so the `typescript` devDependency, and
# every other tool that resolves it, stays on the supported version.
- name: Install TypeScript 7
run: pnpm add -D typescript-7@npm:typescript@7
# Invoked by path rather than through `pnpm exec tsc`. The alias also
# claims the `tsc` bin, so `pnpm exec tsc` happens to resolve to 7 today,
# but relying on that would let this job silently test the wrong compiler.
- name: Test types with TypeScript 7
run: |
node node_modules/typescript-7/bin/tsc --version
node node_modules/typescript-7/bin/tsc -p tsconfig.test.json --noEmit
are-the-types-wrong:
name: Check package config with are-the-types-wrong
needs: [build]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node: ['24.x']
steps:
- name: Checkout repo
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false
- name: Install pnpm
uses: pnpm/setup@84cb39b217b10273981911c288cd62326dc7c6d2 # v2.0.2
with:
# Every job here runs its own install step, with the flags that job
# needs. pnpm/setup installs by default, which would install twice.
install: false
- name: Use node ${{ matrix.node }}
uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e # v4.3.0
with:
node-version: ${{ matrix.node }}
cache: 'pnpm'
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
name: package
path: .
- name: Install dependencies
run: pnpm install
# Note: We currently expect "FalseCJS" failures for Node16 + `moduleResolution: "node16",
- name: Run are-the-types-wrong
run: pnpm exec attw ./package.tgz --format table --ignore-rules false-cjs --exclude-entrypoints alternate-renderers
test-published-artifact:
name: Test Published Artifact ${{ matrix.example }}
needs: [build]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node: ['24.x']
example: ['next', 'vite', 'node', 'react-native', 'expo']
# The `runner` context is not available in `jobs.<id>.defaults.run`, so the
# example directory is repeated as a step-level `working-directory` below.
steps:
- name: Checkout repo
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false
- name: Install pnpm
uses: pnpm/setup@84cb39b217b10273981911c288cd62326dc7c6d2 # v2.0.2
with:
# The examples are cloned below, so there is nothing to install yet.
# Each example is installed explicitly once it exists.
install: false
# No `cache:` here. setup-node's cache input runs the package manager at
# the repository root, and the projects this job installs live in a
# separate clone under $RUNNER_TEMP with their own lockfiles.
- name: Use node ${{ matrix.node }}
uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e # v4.3.0
with:
node-version: ${{ matrix.node }}
# The examples are RTK's `examples/publish-ci/*` projects, cloned at a
# pinned commit so a change on RTK's side cannot break this job without
# someone bumping the pin. The clone lives outside the checkout so that
# nothing in this repo's tree (`pnpm-workspace.yaml`, `.npmrc`) can be
# picked up by config discovery walking up from the example directory.
- name: Clone RTK repo (pinned to known-good commit)
working-directory: ${{ runner.temp }}
run: |
git init "$RUNNER_TEMP/redux-toolkit"
git -C "$RUNNER_TEMP/redux-toolkit" fetch --depth 1 https://github.com/reduxjs/redux-toolkit.git 5b4795b5d3e8a0ab19bf94d8d3413168804ade64
git -C "$RUNNER_TEMP/redux-toolkit" checkout FETCH_HEAD
- name: Check folder contents
working-directory: ${{ runner.temp }}/redux-toolkit/examples/publish-ci/${{ matrix.example }}
run: ls -l .
- name: Install example deps
working-directory: ${{ runner.temp }}/redux-toolkit/examples/publish-ci/${{ matrix.example }}
run: pnpm install --frozen-lockfile
# There is deliberately no "remove the existing react-redux" step.
# `pnpm add ./package.tgz` replaces the dependency on its own, and a
# `pnpm remove` step has intermittently left a child process holding the
# step's stdout pipe open after the command finished, which Actions
# reports as a step that never ends.
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
name: package
path: ${{ runner.temp }}/redux-toolkit/examples/publish-ci/${{ matrix.example }}
- name: Check folder contents
working-directory: ${{ runner.temp }}/redux-toolkit/examples/publish-ci/${{ matrix.example }}
run: ls -l .
- name: Install build artifact
working-directory: ${{ runner.temp }}/redux-toolkit/examples/publish-ci/${{ matrix.example }}
run: pnpm add ./package.tgz
- name: Show installed package versions
working-directory: ${{ runner.temp }}/redux-toolkit/examples/publish-ci/${{ matrix.example }}
run: pnpm list react-redux && pnpm why react-redux
# No `cache: 'gradle'` here: setup-java hashes gradle files under the
# checkout to build its cache key and fails when none match, and the
# example's `android/` directory is in the $RUNNER_TEMP clone.
- name: Set up JDK 21 for React Native build
if: matrix.example == 'react-native' || matrix.example == 'expo'
uses: actions/setup-java@b6effb05e454b25005698d916606bdc6ffcbf961 # v5.7.0
with:
java-version: '21.x'
distribution: 'temurin'
- name: Build example
env:
# The RTK examples are cloned at a pinned commit, so their
# `caniuse-lite` is frozen and will always look stale here.
BROWSERSLIST_IGNORE_OLD_DATA: true
working-directory: ${{ runner.temp }}/redux-toolkit/examples/publish-ci/${{ matrix.example }}
run: pnpm build
- name: Install Playwright browser
if: matrix.example == 'next' || matrix.example == 'vite'
working-directory: ${{ runner.temp }}/redux-toolkit/examples/publish-ci/${{ matrix.example }}
run: pnpm exec playwright install --with-deps chromium
# Each example's `test` script first runs RTK's bundled-modules snapshot
# check, which records which `react-redux/dist/*` file the bundler
# picked, so this also verifies the package's `exports` map end to end.
- name: Run test step
working-directory: ${{ runner.temp }}/redux-toolkit/examples/publish-ci/${{ matrix.example }}
run: pnpm test
test-published-artifact-local:
name: Test Published Artifact (Local) ${{ matrix.example }}
needs: [build]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node: ['24.x']
example: ['rr-rsc-context']
defaults:
run:
working-directory: ./examples/publish-ci/${{ matrix.example }}
steps:
- name: Checkout repo
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false
- name: Install pnpm
uses: pnpm/setup@84cb39b217b10273981911c288cd62326dc7c6d2 # v2.0.2
with:
# `defaults.run.working-directory` applies to `run` steps only, never
# to `uses` steps, so pnpm/setup's default install would run at the
# repo root and install the wrong project. This job installs the
# example itself below.
install: false
# This example is its own pnpm project with its own lockfile, and every
# `run` step here executes inside it. Point the cache at that lockfile
# rather than the root one.
- name: Use node ${{ matrix.node }}
uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e # v4.3.0
with:
node-version: ${{ matrix.node }}
cache: 'pnpm'
cache-dependency-path: examples/publish-ci/${{ matrix.example }}/pnpm-lock.yaml
- name: Install deps
run: pnpm install --frozen-lockfile
# There is deliberately no "remove the existing react-redux" step here.
# `pnpm add ./package.tgz` below replaces the dependency on its own, and
# every other job in this workflow installs the tarball that way. A
# `pnpm remove` step also intermittently left a child process holding the
# step's stdout pipe open after the command itself had finished, which
# Actions reports as a step that never ends: the job hung for hours with
# `Done in 876ms` as its last line.
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
name: package
path: ./examples/publish-ci/${{ matrix.example }}
- name: Check folder contents
run: ls -l .
- name: Install build artifact
run: pnpm add ./package.tgz
# `pnpm info` queries the registry, unlike `yarn info`, which reported the
# installed package. `pnpm list` is the local equivalent.
- name: Show installed React-Redux versions
run: pnpm list react-redux && pnpm why react-redux
- name: Build example
run: pnpm build
test-dist:
name: Run local tests against build artifact (React ${{ matrix.react.version }})
needs: [build]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node: ['24.x']
react:
[
{
version: '^18',
types: ^18,
react-dom: { version: '^18', types: '^18' },
},
{
version: '^19',
types: '^19',
react-dom: { version: '^19', types: '^19' },
},
]
steps:
- name: Checkout repo
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false
- name: Install pnpm
uses: pnpm/setup@84cb39b217b10273981911c288cd62326dc7c6d2 # v2.0.2
with:
# Every job here runs its own install step, with the flags that job
# needs. pnpm/setup installs by default, which would install twice.
install: false
- name: Use node ${{ matrix.node }}
uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e # v4.3.0
with:
node-version: ${{ matrix.node }}
cache: 'pnpm'
- name: Install deps
run: pnpm install --frozen-lockfile
- name: Download build artifact
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
name: package
path: .
- name: Check folder contents
run: ls -lah
- name: Install React ${{ matrix.react.version }} and React-DOM ${{ matrix.react.react-dom.version }}
run: pnpm add -D react@${{ matrix.react.version }} react-dom@${{ matrix.react.react-dom.version }} @types/react@${{ matrix.react.types }} @types/react-dom@${{ matrix.react.react-dom.types }}
- name: Install build artifact
run: pnpm add ./package.tgz
- name: Erase path aliases
run: sed -i -e /@remap-prod-remove-line/d ./tsconfig.base.json
- name: Run local tests against the build artifact
env:
TEST_DIST: true
run: pnpm test