Skip to content

Commit

Permalink
Run both runtime and type tests against the dist folder during CI
Browse files Browse the repository at this point in the history
  • Loading branch information
aryaemami59 committed May 7, 2024
1 parent eb79ff3 commit b44c7e5
Showing 1 changed file with 61 additions and 38 deletions.
99 changes: 61 additions & 38 deletions .github/workflows/build-and-test-types.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
name: CI

on:
push:
branches: [master]
pull_request:
branches: [master]
on: [push, pull_request, workflow_dispatch]

jobs:
build:
Expand Down Expand Up @@ -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

Expand All @@ -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:
Expand All @@ -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: .
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -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

0 comments on commit b44c7e5

Please sign in to comment.