|
16 | 16 | default: false |
17 | 17 |
|
18 | 18 | jobs: |
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 }} |
| 19 | + node-modules-cache: |
25 | 20 | runs-on: ubuntu-latest |
26 | 21 | steps: |
27 | 22 | - uses: actions/checkout@v4 |
|
52 | 47 | node_modules |
53 | 48 | key: ${{ runner.os }}-modern-node-modules-${{ hashFiles('**/package-lock.json') }} |
54 | 49 |
|
| 50 | + # This job is used to run tests on modern Node.js versions |
| 51 | + # 1. Use default Node.js |
| 52 | + # 2. Install latest dependencies |
| 53 | + # 3. Cache node_modules |
| 54 | + build-modern-node: |
| 55 | + if: ${{ inputs.use-matrix == true }} |
| 56 | + runs-on: ubuntu-latest |
| 57 | + needs: node-modules-cache |
| 58 | + steps: |
| 59 | + - uses: actions/checkout@v4 |
| 60 | + |
| 61 | + - name: Use Node.js ${{ vars.DEFAULT_NODE_VERSION }} |
| 62 | + uses: actions/setup-node@v4 |
| 63 | + with: |
| 64 | + node-version: ${{ vars.DEFAULT_NODE_VERSION }} |
| 65 | + |
| 66 | + - name: Restore modern node_modules cache |
| 67 | + id: node_modules_cache |
| 68 | + uses: actions/cache@v4 |
| 69 | + with: |
| 70 | + path: node_modules |
| 71 | + key: ${{ runner.os }}-modern-node-modules-${{ hashFiles('**/package-lock.json') }} |
| 72 | + |
55 | 73 | - name: Build package |
56 | 74 | run: npm run build |
57 | 75 |
|
|
83 | 101 | with: |
84 | 102 | path: node_modules |
85 | 103 | key: ${{ runner.os }}-legacy-node-modules-${{ hashFiles('**/package-lock.json') }}-${{ hashFiles('**/package-legacy-node.json') }} |
86 | | - lookup-only: true |
87 | 104 |
|
88 | 105 | - name: Downgrade package.json legacy dependencies |
89 | 106 | if: steps.node_modules_cache.outputs.cache-hit != 'true' |
@@ -116,8 +133,6 @@ jobs: |
116 | 133 | uses: actions/setup-node@v4 |
117 | 134 | with: |
118 | 135 | node-version: ${{ matrix.node-version }} |
119 | | - cache: 'npm' |
120 | | - cache-dependency-path: '**/package-lock.json' |
121 | 136 |
|
122 | 137 | - name: Restore modern node_modules cache |
123 | 138 | uses: actions/cache@v4 |
@@ -155,8 +170,6 @@ jobs: |
155 | 170 | uses: actions/setup-node@v4 |
156 | 171 | with: |
157 | 172 | node-version: ${{ matrix.node-version }} |
158 | | - cache: 'npm' |
159 | | - cache-dependency-path: '**/package-lock.json' |
160 | 173 |
|
161 | 174 | - name: Restore legacy node_modules cache |
162 | 175 | uses: actions/cache@v4 |
@@ -191,8 +204,6 @@ jobs: |
191 | 204 | uses: actions/setup-node@v4 |
192 | 205 | with: |
193 | 206 | node-version: ${{ vars.DEFAULT_NODE_VERSION }} |
194 | | - cache: 'npm' |
195 | | - cache-dependency-path: '**/package-lock.json' |
196 | 207 |
|
197 | 208 | - name: Restore modern node_modules cache |
198 | 209 | uses: actions/cache@v4 |
@@ -235,18 +246,21 @@ jobs: |
235 | 246 | run-jest-single: |
236 | 247 | if: ${{ inputs.use-matrix == false }} |
237 | 248 | runs-on: ubuntu-latest |
| 249 | + needs: node-modules-cache |
238 | 250 | steps: |
239 | 251 | - uses: actions/checkout@v4 |
240 | 252 |
|
241 | 253 | - name: Use Node.js ${{ inputs.node-version }} |
242 | 254 | uses: actions/setup-node@v4 |
243 | 255 | with: |
244 | 256 | node-version: ${{ inputs.node-version || vars.DEFAULT_NODE_VERSION }} |
245 | | - cache: 'npm' |
246 | | - cache-dependency-path: '**/package-lock.json' |
247 | 257 |
|
248 | | - - name: Install dependencies |
249 | | - run: npm ci |
| 258 | + - name: Restore modern node_modules cache |
| 259 | + uses: actions/cache@v4 |
| 260 | + with: |
| 261 | + path: | |
| 262 | + node_modules |
| 263 | + key: ${{ runner.os }}-modern-node-modules-${{ hashFiles('**/package-lock.json') }} |
250 | 264 |
|
251 | 265 | - name: Run modern jest tests |
252 | 266 | run: npm test |
0 commit comments