diff --git a/.github/workflows/build-and-test-types.yml b/.github/workflows/build-and-test-types.yml index 8fa7c967..5afb02fb 100644 --- a/.github/workflows/build-and-test-types.yml +++ b/.github/workflows/build-and-test-types.yml @@ -1,10 +1,6 @@ name: CI -on: - push: - branches: [master] - pull_request: - branches: [master] +on: [push, pull_request, workflow_dispatch] jobs: build: @@ -69,13 +65,15 @@ jobs: node-version: ${{ matrix.node }} cache: 'yarn' + - name: Download build artifact + uses: actions/download-artifact@v4 + with: + name: package + path: . + - name: Install deps run: yarn install - # Build with the actual TS version in the repo - - name: Pack - run: yarn build && yarn pack - - name: Install build artifact run: yarn add ./package.tgz @@ -85,11 +83,12 @@ jobs: # Remove config line that points "reselect" to the `src` folder, # so that the typetest will use the installed version instead - - run: sed -i -e /@remap-prod-remove-line/d tsconfig.base.json vitest.config.mts + - name: Erase path aliases + run: sed -i -e /@remap-prod-remove-line/d tsconfig.base.json vitest.config.mts - name: Test types run: | - ./node_modules/.bin/tsc --version + yarn tsc --version yarn type-tests are-the-types-wrong: @@ -105,7 +104,8 @@ jobs: - name: Checkout repo uses: actions/checkout@v4 - - uses: actions/download-artifact@v4 + - name: Download build artifact + uses: actions/download-artifact@v4 with: name: package path: . @@ -147,29 +147,23 @@ jobs: - name: Clone RTK repo run: git clone https://github.com/reduxjs/redux-toolkit.git ./redux-toolkit + - name: Cache example deps + uses: actions/cache@v4 + with: + path: ./redux-toolkit/examples/publish-ci/${{ matrix.example }}/node_modules + key: test-published-artifact-${{ matrix.example }}-node_modules + - name: Check folder contents run: ls -l . - # Some weird install diffs with cloning this repo and installing. - # Just kill the lockfiles for this repo and RTK and reinstall - - - name: Remove top lockfile - run: rm yarn.lock && rm package.json - - - name: Remove RTK lockfile - working-directory: ./redux-toolkit - run: rm yarn.lock && rm package.json - - - name: Install deps + - name: Install example deps working-directory: ./redux-toolkit/examples/publish-ci/${{ matrix.example }} - env: - YARN_ENABLE_IMMUTABLE_INSTALLS: false - run: rm yarn.lock && yarn install + run: yarn install - name: Install Playwright browser if necessary working-directory: ./redux-toolkit/examples/publish-ci/${{ matrix.example }} continue-on-error: true - run: yarn playwright install + run: yarn playwright install || true - uses: actions/download-artifact@v4 with: @@ -188,17 +182,6 @@ jobs: working-directory: ./redux-toolkit/examples/publish-ci/${{ matrix.example }} run: yarn info reselect && yarn why reselect - - name: Set up JDK 17 for React Native build - if: matrix.example == 'react-native' - uses: actions/setup-java@v4 - with: - java-version: '17.x' - distribution: 'temurin' - - - name: Check MSW version - working-directory: ./redux-toolkit/examples/publish-ci/${{ matrix.example }} - run: yarn why msw - - name: Build example working-directory: ./redux-toolkit/examples/publish-ci/${{ matrix.example }} env: @@ -208,3 +191,43 @@ jobs: - name: Run test step working-directory: ./redux-toolkit/examples/publish-ci/${{ matrix.example }} run: yarn test + + test-dist: + name: Run local tests against build artifact + needs: [build] + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + node: ['20.x'] + + steps: + - name: Checkout repo + uses: actions/checkout@v4 + + - name: Use node ${{ matrix.node }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node }} + cache: 'yarn' + + - name: Install dependencies + run: yarn install + + - name: Download build artifact + uses: actions/download-artifact@v4 + with: + name: package + path: . + + - name: Check folder contents + run: ls -lah + + - name: Install build artifact + run: yarn add ./package.tgz + + - name: Erase path aliases + run: sed -i -e /@remap-prod-remove-line/d ./tsconfig.base.json ./vitest.config.mts + + - name: Run local tests against the build artifact + run: yarn test