Skip to content

Commit d519d4b

Browse files
authored
test: separate the unit-test and test-all-versions jobs in the main Test workflow (#3162)
1 parent ecd2dcf commit d519d4b

File tree

1 file changed

+47
-16
lines changed

1 file changed

+47
-16
lines changed

.github/workflows/test.yml

Lines changed: 47 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ jobs:
5454

5555
unit-test:
5656
needs: compile
57+
runs-on: ubuntu-latest
5758
strategy:
5859
fail-fast: false
5960
matrix:
@@ -64,8 +65,9 @@ jobs:
6465
- "20"
6566
- "22"
6667
- "24"
67-
runs-on: ubuntu-latest
68-
services:
68+
# `&foo` syntax is a YAML anchor. See:
69+
# https://docs.github.com/en/actions/reference/workflows-and-actions/reusing-workflow-configurations#yaml-anchors-and-aliases
70+
services: &test_services
6971
memcached:
7072
image: memcached:1.6.39-alpine
7173
ports:
@@ -147,7 +149,7 @@ jobs:
147149
env:
148150
RABBITMQ_DEFAULT_USER: username
149151
RABBITMQ_DEFAULT_PASS: password
150-
env:
152+
env: &test_env
151153
RUN_CASSANDRA_TESTS: 1
152154
RUN_MEMCACHED_TESTS: 1
153155
RUN_MONGODB_TESTS: 1
@@ -218,6 +220,45 @@ jobs:
218220
run: npm run test:browser:ci:affected
219221
- name: Unit tests (Nodejs - Delta)
220222
run: npm run test:ci:affected
223+
224+
test-all-versions:
225+
needs: compile
226+
runs-on: ubuntu-latest
227+
strategy:
228+
fail-fast: false
229+
matrix:
230+
node:
231+
- "18"
232+
- "20"
233+
- "22"
234+
- "24"
235+
services: *test_services
236+
env: *test_env
237+
steps:
238+
- uses: actions/checkout@v5
239+
with:
240+
fetch-depth: 0
241+
- uses: actions/setup-node@v5
242+
with:
243+
node-version: ${{ matrix.node }}
244+
- run: npm ci
245+
- name: Download Build Artifacts
246+
uses: actions/download-artifact@v5
247+
with:
248+
name: compile-cache-${{ github.run_number }}
249+
path: .nx
250+
# Note: see comment in the compile job
251+
- name: Set base and head commits
252+
run: |
253+
if [ "${{github.event_name}}" == "push" ]; then
254+
echo "NX_BASE=origin/main~1" >> "$GITHUB_ENV"
255+
echo "NX_HEAD=origin/main" >> "$GITHUB_ENV"
256+
else
257+
echo "NX_BASE=origin/main" >> "$GITHUB_ENV"
258+
echo "NX_HEAD=HEAD" >> "$GITHUB_ENV"
259+
fi
260+
- name: Compile (Delta)
261+
run: npm run compile:ci:affected
221262
- name: Test All Versions (Delta)
222263
run: npm run test-all-versions:ci:affected
223264
- name: Upload Test Artifacts
@@ -232,9 +273,9 @@ jobs:
232273
packages/*/.nyc_output/**
233274
LICENSE
234275
235-
test-coverage-report:
276+
coverage-report:
277+
needs: test-all-versions
236278
runs-on: ubuntu-latest
237-
needs: unit-test
238279
steps:
239280
- name: Checkout
240281
uses: actions/checkout@v5
@@ -245,27 +286,17 @@ jobs:
245286
node-version: 18
246287
- name: Install
247288
run: npm ci --ignore-scripts
248-
# NOTE: keep this in sync with the node versions from `unit-test` job
289+
# Note: Keep this in sync with the node versions from `test-all-versions` job.
249290
- name: Download Test Artifacts (18)
250291
uses: actions/download-artifact@v5
251292
with:
252293
name: tests-coverage-cache-${{ github.run_number }}-18
253294
path: .
254-
- name: Download Test Artifacts (18.19.0)
255-
uses: actions/download-artifact@v5
256-
with:
257-
name: tests-coverage-cache-${{ github.run_number }}-18.19.0
258-
path: .
259295
- name: Download Test Artifacts (20)
260296
uses: actions/download-artifact@v5
261297
with:
262298
name: tests-coverage-cache-${{ github.run_number }}-20
263299
path: .
264-
- name: Download Test Artifacts (20.6.0)
265-
uses: actions/download-artifact@v5
266-
with:
267-
name: tests-coverage-cache-${{ github.run_number }}-20.6.0
268-
path: .
269300
- name: Download Test Artifacts (22)
270301
uses: actions/download-artifact@v5
271302
with:

0 commit comments

Comments
 (0)