RR-5 typescript: split type-only imports in docs snippets #1627
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | |
| 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: | |
| [ | |
| 'cra4', | |
| 'cra5', | |
| 'next', | |
| 'vite', | |
| 'node-standard', | |
| 'node-esm', | |
| 'react-native', | |
| 'expo', | |
| ] | |
| steps: | |
| - name: Checkout repo | |
| uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| with: | |
| persist-credentials: false | |
| # This job runs Yarn only, inside the RTK clone in $RUNNER_TEMP, and | |
| # never installs at the repo root. There is no root yarn.lock to key a | |
| # `cache: 'yarn'` entry on any more, and setup-node errors when the | |
| # lockfile it looks for is missing. The example's node_modules are | |
| # cached explicitly by the actions/cache step below instead. | |
| - name: Use node ${{ matrix.node }} | |
| uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e # v4.3.0 | |
| with: | |
| node-version: ${{ matrix.node }} | |
| # The clone deliberately lives outside the checkout. It originally | |
| # guarded against Yarn merging every `.yarnrc.yml` found walking up from | |
| # the cwd: this repo used to ship one, and RTK pins its own older Yarn | |
| # via `yarnPath`, which aborts on any option it doesn't recognise. This | |
| # repo is on pnpm now and has no `.yarnrc.yml`, but pnpm resolves | |
| # `.npmrc` hierarchically the same way, so keeping the clone outside the | |
| # checkout is still the safer arrangement. | |
| - name: Clone RTK repo (pinned to known-good commit) | |
| run: | | |
| git init "$RUNNER_TEMP/redux-toolkit" | |
| git -C "$RUNNER_TEMP/redux-toolkit" fetch --depth 1 https://github.com/reduxjs/redux-toolkit.git d974a4d252090eab9e029842042757bc43af8980 | |
| git -C "$RUNNER_TEMP/redux-toolkit" checkout FETCH_HEAD | |
| - name: Cache example deps | |
| uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 | |
| with: | |
| path: ${{ runner.temp }}/redux-toolkit/examples/publish-ci/${{ matrix.example }}/node_modules | |
| key: test-published-artifact-${{ matrix.example }}-node_modules | |
| - 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 }} | |
| env: | |
| YARN_ENABLE_SCRIPTS: false | |
| run: yarn install | |
| - name: Install Playwright browser if necessary | |
| working-directory: ${{ runner.temp }}/redux-toolkit/examples/publish-ci/${{ matrix.example }} | |
| continue-on-error: true | |
| run: yarn playwright install || true | |
| - 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: yarn add ./package.tgz | |
| - name: Show installed package versions | |
| working-directory: ${{ runner.temp }}/redux-toolkit/examples/publish-ci/${{ matrix.example }} | |
| run: yarn info react-redux && yarn why react-redux | |
| - name: Build example | |
| working-directory: ${{ runner.temp }}/redux-toolkit/examples/publish-ci/${{ matrix.example }} | |
| env: | |
| NODE_OPTIONS: --openssl-legacy-provider | |
| # 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 | |
| run: yarn build | |
| - name: Run test step | |
| working-directory: ${{ runner.temp }}/redux-toolkit/examples/publish-ci/${{ matrix.example }} | |
| run: yarn 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 |