@@ -16,147 +16,179 @@ on:
1616 default : false
1717
1818jobs :
19- # Run tests on single specified Node.js version
20- run-tests-single :
21- if : ${{ inputs.use-matrix == false }}
19+ # This job is used to run tests on modern Node.js versions
20+ # 1. Use default Node.js
21+ # 2. Install latest dependencies
22+ # 3. Cache node_modules
23+ build-modern-node :
24+ if : ${{ inputs.use-matrix == true }}
2225 runs-on : ubuntu-latest
2326 steps :
2427 - uses : actions/checkout@v4
2528
26- - name : Use Node.js ${{ inputs.node-version }}
29+ - name : Use Node.js ${{ vars.DEFAULT_NODE_VERSION }}
2730 uses : actions/setup-node@v4
2831 with :
29- node-version : ${{ inputs.node-version || vars.DEFAULT_NODE_VERSION }}
32+ node-version : ${{ vars.DEFAULT_NODE_VERSION }}
3033 cache : ' npm'
3134
35+ - name : Try to restore modern node_modules cache
36+ id : node_modules_cache
37+ uses : actions/cache@v4
38+ with :
39+ path : node_modules
40+ key : ${{ runner.os }}-modern-node-modules-${{ hashFiles('**/package-lock.json') }}
41+
3242 - name : Install dependencies
43+ if : steps.node_modules_cache.outputs.cache-hit != 'true'
3344 run : npm ci
3445
35- - name : Run modern jest tests
36- run : npm run task:jest
37-
38- # Run tests on multiple matrix Node.js versions
39- run-tests-modern-nodes :
40- if : ${{ inputs.use-matrix == true }}
41- runs-on : ubuntu-latest
42- needs : build-modern
43- strategy :
44- matrix :
45- node-version : [16.x, 17.x, 18.x, 19.x, 20.x, 21.x, 22.x, 23.x]
46- steps :
47- - uses : actions/checkout@v4
48-
49- - name : Restore cache
46+ - name : Cache modern node_modules
47+ if : steps.node_modules_cache.outputs.cache-hit != 'true'
5048 uses : actions/cache@v4
5149 with :
5250 path : |
5351 node_modules
54- key : ${{ runner.os }}-build-modern-${{ github.sha }}
52+ key : ${{ runner.os }}-modern-node-modules-${{ hashFiles('**/package-lock.json') }}
53+
54+ # - name: Try to restore playwright browsers cache
55+ # id: cache-playwright
56+ # uses: actions/cache@v4
57+ # with:
58+ # path: ~/.cache/ms-playwright
59+ # key: ${{ runner.os }}-playwright-${{ hashFiles('**/package-lock.json') }}
60+
61+ # - name: Install Playwright browsers
62+ # if: steps.cache-playwright.outputs.cache-hit != 'true'
63+ # run: npx playwright install
64+
65+ # - name: Cache Playwright browsers
66+ # if: steps.cache-playwright.outputs.cache-hit != 'true'
67+ # uses: actions/cache@v4
68+ # with:
69+ # path: ~/.cache/ms-playwright
70+ # key: ${{ runner.os }}-playwright-${{ hashFiles('**/package-lock.json') }}
5571
56- - name : Use Node.js ${{ matrix.node-version }}
57- uses : actions/setup-node@v4
58- with :
59- node-version : ${{ matrix.node-version }}
72+ - name : Build package
73+ run : npm run build
6074
61- - name : Run modern jest tests
62- run : npm run task:jest
75+ - name : Cache modern package build output
76+ uses : actions/cache@v4
77+ with :
78+ path : |
79+ tslib
80+ lib
81+ es
82+ es-legacy
83+ umd
84+ key : ${{ runner.os }}-modern-build-output-${{ github.sha }}
6385
64- # Run e2e tests
65- run-e2e-tests :
86+ build-legacy-node :
6687 if : ${{ inputs.use-matrix == true }}
6788 runs-on : ubuntu-latest
68- needs : build-modern
6989 steps :
7090 - uses : actions/checkout@v4
7191
72- - name : Restore cache
73- uses : actions/cache@v4
74- with :
75- path : |
76- node_modules
77- key : ${{ runner.os }}-build-modern-${{ github.sha }}
78-
7992 - name : Use Node.js ${{ vars.DEFAULT_NODE_VERSION }}
8093 uses : actions/setup-node@v4
8194 with :
8295 node-version : ${{ vars.DEFAULT_NODE_VERSION }}
8396
84- - name : Install Playwright dependencies
85- run : npx playwright install-deps webkit
97+ - name : Try to restore legacy node_modules cache
98+ id : node_modules_cache
99+ uses : actions/cache@v4
100+ with :
101+ path : node_modules
102+ key : ${{ runner.os }}-legacy-node-modules-${{ hashFiles('**/package-lock.json') }}-${{ hashFiles('package-legacy-node.json') }}
103+ lookup-only : true
86104
87- - name : Install playwright browsers
88- run : npx playwright install
105+ - name : Downgrade package.json legacy dependencies
106+ if : steps.node_modules_cache.outputs.cache-hit != 'true'
107+ run : npm run prepare-legacy-node
89108
90- - name : Build package
91- run : npm run build
109+ - name : Install dependencies
110+ if : steps.node_modules_cache.outputs.cache-hit != 'true'
111+ run : npm install --legacy-peer-deps --ignore-scripts --no-package-lock
92112
93- - name : Run e2e tests
94- run : npm run e2e
113+ - name : Cache legacy node_modules
114+ if : steps.node_modules_cache.outputs.cache-hit != 'true'
115+ uses : actions/cache@v4
116+ with :
117+ path : |
118+ node_modules
119+ key : ${{ runner.os }}-legacy-node-modules-${{ hashFiles('**/package-lock.json') }}-${{ hashFiles('package-legacy-node.json') }}
95120
96- # Run legacy tests on multiple matrix Node.js versions
97- run-tests-legacy-node14-15 :
121+ # Run tests on multiple matrix Node.js versions
122+ run-modern-jest-nodes :
98123 if : ${{ inputs.use-matrix == true }}
99124 runs-on : ubuntu-latest
100- needs : build-node14-15
125+ needs : build-modern-node
101126 strategy :
102127 matrix :
103- node-version : [14 .x, 15 .x]
128+ node-version : [16 .x, 17.x, 18.x, 19.x, 20.x, 21.x, 22.x, 23 .x]
104129 steps :
105130 - uses : actions/checkout@v4
106131
107- - name : Restore cache
108- uses : actions/cache@v4
109- with :
110- path : |
111- node_modules
112- tslib
113- lib
114- key : ${{ runner.os }}-build-node14-15-${{ github.sha }}
115-
116132 - name : Use Node.js ${{ matrix.node-version }}
117133 uses : actions/setup-node@v4
118134 with :
119135 node-version : ${{ matrix.node-version }}
136+ cache : ' npm'
120137
121- - name : Run legacy jest tests
122- run : npm run task:jest:legacy
138+ - name : Restore modern node_modules cache
139+ uses : actions/cache@v4
140+ with :
141+ path : |
142+ node_modules
143+ key : ${{ runner.os }}-modern-node-modules-${{ hashFiles('**/package-lock.json') }}
144+
145+ - name : Run modern jest tests
146+ run : npm run task:jest
123147
124148 # Run legacy tests on multiple matrix Node.js versions
125- run-tests- legacy-node7-13 :
149+ run-legacy-jest-tests :
126150 if : ${{ inputs.use-matrix == true }}
127151 runs-on : ubuntu-latest
128- needs : build-node7-13
152+ needs : build-legacy-node
129153 strategy :
130154 matrix :
131- node-version : [7.x, 8.x, 9.x, 10.x, 11.x, 12.x, 13.x]
155+ node-version : [7.x, 8.x, 9.x, 10.x, 11.x, 12.x, 13.x, 14.x, 15.x ]
132156 steps :
133157 - uses : actions/checkout@v4
134158
135- - name : Restore cache
159+ - name : Use Node.js ${{ matrix.node-version }}
160+ uses : actions/setup-node@v4
161+ with :
162+ node-version : ${{ matrix.node-version }}
163+ cache : ' npm'
164+
165+ - name : Restore legacy node_modules cache
136166 uses : actions/cache@v4
137167 with :
138168 path : |
139169 node_modules
140- tslib
141- lib
142- key : ${{ runner.os }}-build-node7-13-${{ github.sha }}
170+ key : ${{ runner.os }}-legacy-node-modules-${{ hashFiles('**/package-lock.json') }}-${{ hashFiles('package-legacy-node.json') }}
143171
144- - name : Use Node.js ${{ matrix.node-version }}
145- uses : actions/setup-node @v4
172+ - name : Restore modern build output cache
173+ uses : actions/cache @v4
146174 with :
147- node-version : ${{ matrix.node-version }}
175+ path : |
176+ tslib
177+ lib
178+ es
179+ es-legacy
180+ umd
181+ key : ${{ runner.os }}-modern-build-output-${{ github.sha }}
148182
149183 - name : Run legacy jest tests
150184 run : npm run task:jest:legacy
151185
152- # This job is used to run tests on legacy Node.js versions
153- # 1. Use default Node.js
154- # 2. Install older versions of jest and ts-jest
155- # 3. Build the project
156- # 4. Cache node_modules and tslib
157- build-node7-13 :
186+ run-e2e-tests :
158187 if : ${{ inputs.use-matrix == true }}
159188 runs-on : ubuntu-latest
189+ # Use Playwright container for E2E tests, which has all dependencies and all browsers installed
190+ container : mcr.microsoft.com/playwright:v1.40.0-focal
191+ needs : build-modern-node
160192 steps :
161193 - uses : actions/checkout@v4
162194
@@ -166,81 +198,42 @@ jobs:
166198 node-version : ${{ vars.DEFAULT_NODE_VERSION }}
167199 cache : ' npm'
168200
169- - name : Downgrade legacy dependencies
170- run : npm run prepare-legacy-node7-13
171-
172- - name : Install dependencies
173- run : npm install --legacy-peer-deps --ignore-scripts --no-package-lock
174-
175- - name : Build lib
176- run : npm run build:lib
177-
178- - name : Cache build output
201+ - name : Restore modern node_modules cache
179202 uses : actions/cache@v4
180203 with :
181204 path : |
182205 node_modules
183- tslib
184- lib
185- key : ${{ runner.os }}-build-node7-13-${{ github.sha }}
206+ key : ${{ runner.os }}-modern-node-modules-${{ hashFiles('**/package-lock.json') }}
186207
187- # This job is used to run tests on legacy Node.js versions
188- # 1. Use default Node.js
189- # 2. Install older versions of jest and ts-jest
190- # 3. Build the project
191- # 4. Cache node_modules and tslib
192- build-node14-15 :
193- if : ${{ inputs.use-matrix == true }}
194- runs-on : ubuntu-latest
195- steps :
196- - uses : actions/checkout@v4
197-
198- - name : Use Node.js ${{ vars.DEFAULT_NODE_VERSION }}
199- uses : actions/setup-node@v4
200- with :
201- node-version : ${{ vars.DEFAULT_NODE_VERSION }}
202- cache : ' npm'
203-
204- - name : Downgrade legacy dependencies
205- run : npm run prepare-legacy-node14-15
206-
207- - name : Install dependencies
208- run : npm install --legacy-peer-deps --ignore-scripts --no-package-lock
209-
210- - name : Build lib
211- run : npm run build:lib
212-
213- - name : Cache build output
208+ - name : Restore modern build output cache
214209 uses : actions/cache@v4
215210 with :
216211 path : |
217- node_modules
218212 tslib
219213 lib
220- key : ${{ runner.os }}-build-node14-15-${{ github.sha }}
214+ es
215+ es-legacy
216+ umd
217+ key : ${{ runner.os }}-modern-build-output-${{ github.sha }}
221218
222- # This job is used to run tests on modern Node.js versions
223- # 1. Use default Node.js
224- # 2. Install latest dependencies
225- # 3. Cache node_modules
226- build-modern :
227- if : ${{ inputs.use-matrix == true }}
219+ - name : Run e2e tests
220+ run : npm run e2e
221+
222+ # Run tests on single specified Node.js version
223+ run-jest-single :
224+ if : ${{ inputs.use-matrix == false }}
228225 runs-on : ubuntu-latest
229226 steps :
230227 - uses : actions/checkout@v4
231228
232- - name : Use Node.js ${{ vars.DEFAULT_NODE_VERSION }}
229+ - name : Use Node.js ${{ inputs.node-version }}
233230 uses : actions/setup-node@v4
234231 with :
235- node-version : ${{ vars.DEFAULT_NODE_VERSION }}
232+ node-version : ${{ inputs.node-version || vars.DEFAULT_NODE_VERSION }}
236233 cache : ' npm'
237234
238235 - name : Install dependencies
239236 run : npm ci
240237
241- - name : Cache build output
242- uses : actions/cache@v4
243- with :
244- path : |
245- node_modules
246- key : ${{ runner.os }}-build-modern-${{ github.sha }}
238+ - name : Run modern jest tests
239+ run : npm test
0 commit comments