1616 default : false
1717
1818jobs :
19- node-modules-cache :
19+ # This job is used to cache node_modules and build output
20+ # 1. Install latest dependencies
21+ # 2. Cache node_modules
22+ # 3. Build package
23+ # 4. Cache build output
24+ install-and-build :
2025 if : ${{ inputs.use-matrix == true }}
2126 runs-on : ubuntu-latest
2227 steps :
6368 name : modern-node-modules-${{ hashFiles('**/package-lock.json') }}
6469 path : node_modules
6570
66- # This job is used to run tests on modern Node.js versions
67- # 1. Use default Node.js
68- # 2. Install latest dependencies
69- # 3. Cache node_modules
70- build-modern-node :
71- if : ${{ inputs.use-matrix == true }}
72- runs-on : ubuntu-latest
73- needs : node-modules-cache
74- steps :
75- - uses : actions/checkout@v4
76-
77- - name : Use Node.js ${{ vars.DEFAULT_NODE_VERSION }}
78- uses : actions/setup-node@v4
79- with :
80- node-version : ${{ vars.DEFAULT_NODE_VERSION }}
81-
82- - name : Restore modern node_modules cache
83- id : node_modules_cache
84- uses : actions/cache@v4
85- with :
86- path : node_modules
87- key : ${{ runner.os }}-modern-node-modules-${{ hashFiles('**/package-lock.json') }}
88-
8971 - name : Build package
9072 run : npm run build
9173
9476 with :
9577 path : |
9678 tslib
79+ tses
9780 lib
9881 es
9982 es-legacy
@@ -106,12 +89,12 @@ jobs:
10689 name : ${{ runner.os }}-modern-build-output-${{ github.sha }}
10790 path : |
10891 tslib
92+ tses
10993 lib
11094 es
11195 es-legacy
11296 umd
113-
114- build-legacy-node :
97+ node-modules-legacy-cache :
11598 if : ${{ inputs.use-matrix == true }}
11699 runs-on : ubuntu-latest
117100 steps :
@@ -137,14 +120,37 @@ jobs:
137120 if : steps.node_modules_cache.outputs.cache-hit != 'true'
138121 run : npm install --legacy-peer-deps --ignore-scripts --no-package-lock
139122
140- # Run tests on multiple matrix Node.js versions
141- run-jest-lib-modern :
123+ # Run ts- tests on default Node.js version
124+ run-jest-ts :
142125 if : ${{ inputs.use-matrix == true }}
143126 runs-on : ubuntu-latest
144- needs : build-modern-node
127+ needs : install-and-build
128+ steps :
129+ - uses : actions/checkout@v4
130+
131+ - name : Use Node.js ${{ vars.DEFAULT_NODE_VERSION }}
132+ uses : actions/setup-node@v4
133+ with :
134+ node-version : ${{ vars.DEFAULT_NODE_VERSION }}
135+
136+ - name : Restore modern node_modules cache
137+ uses : actions/cache@v4
138+ with :
139+ path : |
140+ node_modules
141+ key : ${{ runner.os }}-modern-node-modules-${{ hashFiles('**/package-lock.json') }}
142+
143+ - name : Run jest tests from source codes
144+ run : npm test
145+
146+ # Run Node.js CJS unit tests on multiple modern node versions
147+ run-jest-cjs :
148+ if : ${{ inputs.use-matrix == true }}
149+ runs-on : ubuntu-latest
150+ needs : install-and-build
145151 strategy :
146152 matrix :
147- node-version : [16.x, 17.x, 18.x, 19.x, 20.x, 21.x, 22.x, 23.x]
153+ node-version : [16.x, 17.x, 18.x, 19.x, 20.x, 21.x, 22.x, 23.x, 24.x ]
148154 steps :
149155 - uses : actions/checkout@v4
150156
@@ -165,20 +171,21 @@ jobs:
165171 with :
166172 path : |
167173 tslib
174+ tses
168175 lib
169176 es
170177 es-legacy
171178 umd
172179 key : ${{ runner.os }}-modern-build-output-${{ github.sha }}
173180
174- - name : Run jest tests from lib directory
175- run : npm run task:jest:lib
181+ - name : Run jest tests from tslib directory
182+ run : npm run task:jest-cjs
176183
177- # Run legacy tests on multiple matrix Node.js versions
178- run-jest-lib -legacy :
184+ # Run CJS unit tests on multiple legacy node versions
185+ run-jest-cjs -legacy :
179186 if : ${{ inputs.use-matrix == true }}
180187 runs-on : ubuntu-latest
181- needs : [build-modern-node, build- legacy-node ]
188+ needs : [install-and-build, node-modules- legacy-cache ]
182189 strategy :
183190 matrix :
184191 node-version : [7.x, 8.x, 9.x, 10.x, 11.x, 12.x, 13.x, 14.x, 15.x]
@@ -202,27 +209,31 @@ jobs:
202209 with :
203210 path : |
204211 tslib
212+ tses
205213 lib
206214 es
207215 es-legacy
208216 umd
209217 key : ${{ runner.os }}-modern-build-output-${{ github.sha }}
210218
211- - name : Run jest tests from lib directory
212- run : npm run task:jest:lib
219+ - name : Run jest tests from tslib directory
220+ run : npm run task:jest-cjs
213221
214- # Run ts- tests on default Node.js version
215- run-jest-ts :
222+ # Run ESM unit tests on node versions that support Node.js ESM
223+ run-jest-esm :
216224 if : ${{ inputs.use-matrix == true }}
217225 runs-on : ubuntu-latest
218- needs : build-modern-node
226+ needs : install-and-build
227+ strategy :
228+ matrix :
229+ node-version : [16.x, 17.x, 18.x, 19.x, 20.x, 21.x, 22.x, 23.x, 24.x]
219230 steps :
220231 - uses : actions/checkout@v4
221232
222- - name : Use Node.js ${{ vars.DEFAULT_NODE_VERSION }}
233+ - name : Use Node.js ${{ matrix.node-version }}
223234 uses : actions/setup-node@v4
224235 with :
225- node-version : ${{ vars.DEFAULT_NODE_VERSION }}
236+ node-version : ${{ matrix.node-version }}
226237
227238 - name : Restore modern node_modules cache
228239 uses : actions/cache@v4
@@ -231,13 +242,25 @@ jobs:
231242 node_modules
232243 key : ${{ runner.os }}-modern-node-modules-${{ hashFiles('**/package-lock.json') }}
233244
234- - name : Run jest tests from source codes
235- run : npm test
245+ - name : Restore modern build output cache
246+ uses : actions/cache@v4
247+ with :
248+ path : |
249+ tslib
250+ tses
251+ lib
252+ es
253+ es-legacy
254+ umd
255+ key : ${{ runner.os }}-modern-build-output-${{ github.sha }}
256+
257+ - name : Run jest tests from tses directory
258+ run : npm run task:jest-esm
236259
237- run-e2e-tests :
260+ # Run e2e tests
261+ run-e2e :
238262 if : ${{ inputs.use-matrix == true }}
239263 runs-on : ubuntu-latest
240- # needs: build-modern-node
241264 steps :
242265 - uses : actions/checkout@v4
243266
@@ -273,7 +296,7 @@ jobs:
273296 name : ${{ runner.os }}-modern-build-output-${{ github.sha }}
274297
275298 - name : Build package
276- # if: steps.download_build_output.outcome != 'success'
299+ if : steps.download_build_output.outcome != 'success'
277300 run : npm run build
278301
279302 - name : Run e2e tests
0 commit comments