From f51b119cfe7dfb465d0a7ad8daab89302922a558 Mon Sep 17 00:00:00 2001 From: Arya Emami Date: Mon, 24 Jun 2024 16:33:16 -0500 Subject: [PATCH] Fix CI tests - It seems like the new version of Vite much like Node.js allows packages to self-reference themselves, which became a problem considering how we were running the tests against the build artifact during CI. --- .github/workflows/test.yml | 28 +++++++++++++++++++++------- vitest.config.mts | 5 ++++- 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 46832e9..ce767fe 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,10 +1,6 @@ name: CI -on: - push: - branches: [master] - pull_request: - branches: [master] +on: [push, pull_request, workflow_dispatch] jobs: build: @@ -66,7 +62,8 @@ jobs: - name: Install deps run: yarn install - - uses: actions/download-artifact@v4 + - name: Download build artifact + uses: actions/download-artifact@v4 with: name: package path: . @@ -76,9 +73,12 @@ jobs: - name: Install build artifact run: yarn add ./package.tgz - - 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 - name: Run tests, against dist + env: + TEST_DIST: true run: yarn test test-types: @@ -102,13 +102,27 @@ 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 - name: Install TypeScript ${{ matrix.ts }} run: yarn add typescript@${{ matrix.ts }} + - 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 + - name: Test types + env: + TEST_DIST: true run: | yarn tsc --version yarn type-tests diff --git a/vitest.config.mts b/vitest.config.mts index 3c1a63e..43fbe0c 100644 --- a/vitest.config.mts +++ b/vitest.config.mts @@ -4,7 +4,10 @@ export default defineConfig({ test: { globals: true, alias: { - 'redux-thunk': new URL('src/index.ts', import.meta.url).pathname, // @remap-prod-remove-line + 'redux-thunk': new URL( + process.env.TEST_DIST ? 'node_modules/redux-thunk' : 'src/index.ts', + import.meta.url + ).pathname, // this mapping is disabled as we want `dist` imports in the tests only to be used for "type-only" imports which don't play a role for jest '@internal': new URL('src', import.meta.url).pathname