Repository navigation
171 lines (164 loc) · 6.62 KB
/
Copy pathnodejs.yml
File metadata and controls
171 lines (164 loc) · 6.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
name: Node CI
on:
push:
pull_request:
workflow_dispatch:
# The publish workflow runs exactly these checks before it publishes.
workflow_call:
permissions:
contents: read
env:
# The oldest Node.js version the package supports. It must equal engines.node in package.json
# (packaging/package.test.js checks that), and the minimum-node job below smoke-tests the packed package on it.
MINIMUM_NODE_VERSION: '10.0.0'
# The oldest Node.js version with native ES module support, for the ESM entry point (dist/index.mjs).
MINIMUM_ESM_NODE_VERSION: '12.17.0'
# F2: Node.js 13.0 and 13.1 read "exports" but not its conditions. They load the package through the array fallback
# in exports["."] (the CommonJS entry); without it, require() fails there.
EXPORTS_FALLBACK_NODE_VERSION: '13.0.0'
# Node.js 13.2 to 13.6 have ES modules but not the "import" condition, so 13.7 is the oldest 13.x release on which
# the ES module entry works.
MINIMUM_ESM_NODE_13_VERSION: '13.7.0'
jobs:
test:
name: Test on Node ${{ matrix.node-version }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
# Every Node.js LTS line that is still supported: https://nodejs.org/en/about/previous-releases
node-version: [22, 24, 26]
steps:
- uses: actions/checkout@v7
with:
show-progress: false
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v7
with:
node-version: ${{ matrix.node-version }}
cache: npm
- name: Install dependencies
run: npm ci
- name: Build
run: npm run build
- name: Run the specs and the packaging checks
run: npm test
- name: Run the type tests
run: npm run test:types --if-present
# Type-checks and runs the code examples of README.md, docs/GUIDE.md, MIGRATION.md and CHANGELOG.md against the built package, and checks links.
- name: Check the code examples in the documentation
run: npm run test:docs
# F4: README, MIGRATION and CHANGELOG promise TypeScript 3.6 or newer. Type-checks the built typings with exactly that
# version (spec-types/min-ts/check.js installs it on the fly with npx), so a .d.ts change that needs newer
# TypeScript fails CI and is never published.
types-min-ts:
name: Typings on the oldest supported TypeScript
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
show-progress: false
- name: Use the development Node.js version
uses: actions/setup-node@v7
with:
node-version-file: package.json
cache: npm
- name: Install dependencies
run: npm ci
- name: Build and type-check the typings with the oldest supported TypeScript
run: npm run test:types:min-ts
compatibility:
name: Test runner compatibility on Node ${{ matrix.node-version }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node-version: [22, 24, 26]
steps:
- uses: actions/checkout@v7
with:
show-progress: false
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v7
with:
node-version: ${{ matrix.node-version }}
cache: npm
cache-dependency-path: |
package-lock.json
compatibility-checks/package-lock.json
- name: Install dependencies
run: npm ci
- name: Install the compatibility check dependencies
run: npm ci
working-directory: compatibility-checks
# The pretest script packs the repository like npm publish does and installs that tarball,
# so ava, jest, mocha, node:test and vitest run against the package as it would be published.
- name: Run the compatibility checks against the packed package
run: npm test
working-directory: compatibility-checks
minimum-node:
name: Packed package on the oldest supported Node versions
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
show-progress: false
- name: Use the development Node.js version
uses: actions/setup-node@v7
with:
node-version-file: package.json
cache: npm
- name: Install dependencies
run: npm ci
- name: Pack the package like npm publish does
run: |
consumer="$RUNNER_TEMP/consumer"
mkdir -p "$consumer/node_modules/@fluffy-spoon/substitute"
npm pack --pack-destination "$RUNNER_TEMP"
tar -xzf "$RUNNER_TEMP"/fluffy-spoon-substitute-*.tgz -C "$consumer/node_modules/@fluffy-spoon/substitute" --strip-components=1
cp packaging/smoke/* "$consumer/"
- name: Use Node.js ${{ env.MINIMUM_NODE_VERSION }}
uses: actions/setup-node@v7
with:
node-version: ${{ env.MINIMUM_NODE_VERSION }}
# G:PK-2: engines.node must be a version the package really runs on.
# R3TD-5: deep-imports.js checks, on every version below, that the deep imports work or fail as
# packaging/smoke/deep-import-support.js (and CONTRIBUTING.md and MIGRATION.md) say.
- name: CommonJS smoke test on Node ${{ env.MINIMUM_NODE_VERSION }}
working-directory: ${{ runner.temp }}/consumer
run: |
node --version
node require.js
node deep-imports.js
- name: Use Node.js ${{ env.MINIMUM_ESM_NODE_VERSION }}
uses: actions/setup-node@v7
with:
node-version: ${{ env.MINIMUM_ESM_NODE_VERSION }}
- name: CommonJS and ES module smoke test on Node ${{ env.MINIMUM_ESM_NODE_VERSION }}
working-directory: ${{ runner.temp }}/consumer
run: |
node --version
node require.js
node import.mjs
node deep-imports.js
- name: Use Node.js ${{ env.EXPORTS_FALLBACK_NODE_VERSION }}
uses: actions/setup-node@v7
with:
node-version: ${{ env.EXPORTS_FALLBACK_NODE_VERSION }}
- name: CommonJS smoke test on Node ${{ env.EXPORTS_FALLBACK_NODE_VERSION }} (exports without conditions)
working-directory: ${{ runner.temp }}/consumer
run: |
node --version
node require.js
node deep-imports.js
- name: Use Node.js ${{ env.MINIMUM_ESM_NODE_13_VERSION }}
uses: actions/setup-node@v7
with:
node-version: ${{ env.MINIMUM_ESM_NODE_13_VERSION }}
- name: CommonJS and ES module smoke test on Node ${{ env.MINIMUM_ESM_NODE_13_VERSION }}
working-directory: ${{ runner.temp }}/consumer
run: |
node --version
node require.js
node import.mjs
node deep-imports.js