Skip to content

Commit 602f012

Browse files
authored
Merge pull request #4307 from aryaemami59/fix-codegen-tests
2 parents b66ab1a + 91aea9a commit 602f012

File tree

10 files changed

+1032
-224
lines changed

10 files changed

+1032
-224
lines changed

.github/workflows/test-codegen.yml

Lines changed: 77 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
22
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
33

4-
name: RTK-Query OpenAPI Codegen Tests
4+
name: RTKQ OpenAPI Codegen
55
defaults:
66
run:
77
working-directory: ./packages/rtk-query-codegen-openapi
@@ -23,24 +23,94 @@ jobs:
2323
codegen:
2424
- 'packages/rtk-query-codegen-openapi/**'
2525
- 'yarn.lock'
26+
- '.github/workflows/test-codegen.yml'
2627
2728
build:
2829
needs: changes
2930
if: ${{ needs.changes.outputs.codegen == 'true' }}
3031

31-
runs-on: ubuntu-latest
32+
defaults:
33+
run:
34+
working-directory: ./packages/rtk-query-codegen-openapi
35+
36+
runs-on: ${{ matrix.os }}
37+
38+
name: Build artifact for ${{ matrix.os }} with Node ${{ matrix.node-version }}
3239

3340
strategy:
3441
matrix:
3542
node-version: ['20.x']
43+
os: [ubuntu-latest]
3644

3745
steps:
38-
- uses: actions/checkout@v4
39-
- name: Use Node.js ${{ matrix.node-version }}
46+
- name: Checkout repository
47+
uses: actions/checkout@v4
48+
49+
- name: Setup Node ${{ matrix.node-version }}
4050
uses: actions/setup-node@v4
4151
with:
42-
node-version: ${{ matrix.node }}
52+
node-version: ${{ matrix.node-version }}
4353
cache: 'yarn'
4454

45-
- run: yarn install
46-
- run: yarn test
55+
- name: Install dependencies
56+
run: yarn install
57+
58+
- name: Pack
59+
run: yarn pack
60+
61+
- name: Upload artifact
62+
uses: actions/upload-artifact@v4
63+
id: artifact-upload-step
64+
with:
65+
name: package
66+
path: ./packages/rtk-query-codegen-openapi/package.tgz
67+
68+
- name: Did we fail?
69+
if: failure()
70+
run: ls -R
71+
72+
test:
73+
needs: build
74+
defaults:
75+
run:
76+
working-directory: ./packages/rtk-query-codegen-openapi
77+
name: Test final build artifact with Node.js ${{ matrix.node-version }} on ${{ matrix.os }}
78+
runs-on: ${{ matrix.os }}
79+
strategy:
80+
fail-fast: false
81+
matrix:
82+
node-version: [20.x]
83+
os: [ubuntu-latest]
84+
85+
steps:
86+
- name: Checkout repository
87+
uses: actions/checkout@v4
88+
89+
- name: Setup Node ${{ matrix.node-version }}
90+
uses: actions/setup-node@v4
91+
with:
92+
node-version: ${{ matrix.node-version }}
93+
cache: 'yarn'
94+
95+
- name: Download artifact
96+
id: download-artifact
97+
uses: actions/download-artifact@v4
98+
with:
99+
path: ./packages/rtk-query-codegen-openapi
100+
name: package
101+
102+
- name: Install dependencies
103+
run: yarn install
104+
105+
- name: Install build artifact
106+
run: yarn add ./package.tgz
107+
108+
- name: Remove path alias
109+
run: sed -i -e /@remap-prod-remove-line/d ./tsconfig.json
110+
111+
- name: Run tests
112+
run: yarn test
113+
114+
- name: Did we fail?
115+
if: failure()
116+
run: ls -R

packages/rtk-query-codegen-openapi/package.json

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@
1717
"rtk-query-codegen-openapi": "lib/bin/cli.js"
1818
},
1919
"scripts": {
20-
"build": "yarn clean && tsc && chmod +x lib/bin/cli.js",
20+
"build": "yarn clean && tsc -p tsconfig.build.json && chmod +x lib/bin/cli.js",
2121
"clean": "rimraf lib",
22-
"prepare": "yarn build && chmod +x lib/bin/cli.js",
22+
"prepack": "yarn build",
2323
"format": "prettier --write \"src/**/*.ts\"",
2424
"test:update": "vitest --run --update",
2525
"test:update:enum": "lib/bin/cli.js test/config.example.enum.ts",
26-
"test": "vitest --run",
26+
"test": "vitest --run --typecheck",
2727
"test:watch": "vitest --watch",
2828
"cli": "esr src/bin/cli.ts"
2929
},
@@ -35,6 +35,7 @@
3535
"@babel/core": "^7.12.10",
3636
"@babel/preset-env": "^7.12.11",
3737
"@babel/preset-typescript": "^7.12.7",
38+
"@oazapfts/runtime": "^1.0.3",
3839
"@reduxjs/toolkit": "^1.6.0",
3940
"@types/commander": "^2.12.2",
4041
"@types/glob-to-regexp": "^0.4.0",
@@ -43,7 +44,7 @@
4344
"@types/semver": "^7.3.9",
4445
"chalk": "^4.1.0",
4546
"del": "^6.0.0",
46-
"esbuild": "~0.17",
47+
"esbuild": "^0.23.1",
4748
"esbuild-runner": "^2.2.1",
4849
"husky": "^4.3.6",
4950
"msw": "^2.1.5",
@@ -52,7 +53,8 @@
5253
"pretty-quick": "^4.0.0",
5354
"rimraf": "^5.0.5",
5455
"ts-node": "^10.9.2",
55-
"vitest": "^1.6.0",
56+
"vite-tsconfig-paths": "^5.0.1",
57+
"vitest": "^2.0.5",
5658
"yalc": "^1.0.0-pre.47"
5759
},
5860
"dependencies": {

0 commit comments

Comments
 (0)