Skip to content

Commit b27c124

Browse files
committed
ci: Re-introduce tests for Node.js 14.6 and later
1 parent c33d480 commit b27c124

File tree

2 files changed

+79
-26
lines changed

2 files changed

+79
-26
lines changed

.github/workflows/nodejs.yml

Lines changed: 58 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,14 @@ on:
1010
jobs:
1111
test:
1212
runs-on: ${{ matrix.os }}
13-
1413
strategy:
1514
matrix:
1615
os: [ubuntu-latest, windows-latest, macos-latest]
1716
node-version: [18, 20, latest]
18-
1917
steps:
2018
- uses: actions/checkout@v4
2119
with: { submodules: true }
22-
- name: Use Node.js ${{ matrix.node-version }}
23-
uses: actions/setup-node@v4
20+
- uses: actions/setup-node@v4
2421
with:
2522
node-version: ${{ matrix.node-version }}
2623
- run: npm ci
@@ -37,3 +34,60 @@ jobs:
3734
with: { node-version: 20 }
3835
- run: npm ci
3936
- run: npm run lint
37+
38+
node-16:
39+
runs-on: ubuntu-latest
40+
strategy:
41+
matrix:
42+
node-version: ['16.0.0', '16']
43+
steps:
44+
- uses: actions/checkout@v4
45+
with: { submodules: true }
46+
- uses: actions/setup-node@v4
47+
with:
48+
node-version: ${{ matrix.node-version }}
49+
- run: npm ci
50+
- run: npm install --no-save rollup@3
51+
- run: npm test
52+
- run: npm run test:dist
53+
54+
node-14-build:
55+
runs-on: ubuntu-latest
56+
strategy:
57+
matrix:
58+
node-version: ['14.18.0']
59+
steps:
60+
- uses: actions/checkout@v4
61+
with: { submodules: true }
62+
- uses: actions/setup-node@v4
63+
with:
64+
node-version: ${{ matrix.node-version }}
65+
- run: npm install --global npm@7
66+
- run: npm ci
67+
- run: npm install --no-save rollup@2
68+
- run: npm run test:dist
69+
- uses: actions/upload-artifact@v4
70+
with:
71+
name: yaml-node14
72+
path: dist/
73+
node-14-run:
74+
needs: node-14-build
75+
runs-on: ubuntu-latest
76+
strategy:
77+
matrix:
78+
node-version: ['14.6.0', '14', '15.0.0']
79+
steps:
80+
- uses: actions/checkout@v4
81+
with: { submodules: true }
82+
- uses: actions/setup-node@v4
83+
with:
84+
node-version: ${{ matrix.node-version }}
85+
- run: npm install --global npm@7
86+
- run: npm ci
87+
- uses: actions/download-artifact@v4
88+
with:
89+
name: yaml-node14
90+
path: dist/
91+
- run: npx jest --config config/jest.config.js
92+
env:
93+
TEST: dist

config/jest.config.js

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,28 +19,27 @@ const transform = {
1919
'[/\\\\]tests[/\\\\].*\\.(m?js|ts)$': babel
2020
}
2121

22-
// The npm script name is significant.
23-
switch (process.env.npm_lifecycle_event) {
24-
case 'test:dist':
25-
console.log('Testing build output from dist/')
26-
moduleNameMapper = {
27-
'^yaml$': '<rootDir>/dist/index.js',
28-
'^yaml/cli$': '<rootDir>/dist/cli.mjs',
29-
'^yaml/util$': '<rootDir>/dist/util.js',
30-
'^../src/test-events.ts$': '<rootDir>/dist/test-events.js'
31-
}
32-
transform['[/\\\\]dist[/\\\\].*\\.mjs$'] = babel
33-
break
34-
35-
case 'test':
36-
default:
37-
process.env.TRACE_LEVEL = 'log'
38-
moduleNameMapper = {
39-
'^yaml$': '<rootDir>/src/index.ts',
40-
'^yaml/cli$': '<rootDir>/src/cli.ts',
41-
'^yaml/util$': '<rootDir>/src/util.ts'
42-
}
43-
transform['[/\\\\]src[/\\\\].*\\.ts$'] = babel
22+
// npm_lifecycle_event is the npm script name.
23+
if (
24+
process.env.TEST === 'dist' ||
25+
process.env.npm_lifecycle_event === 'test:dist'
26+
) {
27+
console.log('Testing build output from dist/')
28+
moduleNameMapper = {
29+
'^yaml$': '<rootDir>/dist/index.js',
30+
'^yaml/cli$': '<rootDir>/dist/cli.mjs',
31+
'^yaml/util$': '<rootDir>/dist/util.js',
32+
'^../src/test-events.ts$': '<rootDir>/dist/test-events.js'
33+
}
34+
transform['[/\\\\]dist[/\\\\].*\\.mjs$'] = babel
35+
} else {
36+
process.env.TRACE_LEVEL = 'log'
37+
moduleNameMapper = {
38+
'^yaml$': '<rootDir>/src/index.ts',
39+
'^yaml/cli$': '<rootDir>/src/cli.ts',
40+
'^yaml/util$': '<rootDir>/src/util.ts'
41+
}
42+
transform['[/\\\\]src[/\\\\].*\\.ts$'] = babel
4443
}
4544

4645
module.exports = {

0 commit comments

Comments
 (0)