Skip to content

Commit 7321451

Browse files
authored
ci: fix test coverage for codecov (#4520)
* chore: coverage for sqlite conditionally * improve * add preparation step for code coverage * step by step see how to get coverage working * activate more tests in hope that they pass too * activate more tests * activate jest and cache-interceptor tests * activate cache-tests * activate wpt to see if it fails * improve?! * remove test:sqlite * fix id * more expressiv title * more expressiv
1 parent 1c15cd4 commit 7321451

File tree

4 files changed

+45
-45
lines changed

4 files changed

+45
-45
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ jobs:
5454
run: npm run lint
5555

5656
test:
57-
name: Test with Node.js ${{ matrix.node-version }} on ${{ matrix.runs-on }}
57+
name: Test ${{ matrix.node-version == '24' && matrix.runs-on == 'ubuntu-latest' && 'and Coverage ' || ''}}with Node.js ${{ matrix.node-version }} on ${{ matrix.runs-on }}
5858
strategy:
5959
fail-fast: false
6060
max-parallel: 0

.github/workflows/nodejs.yml

Lines changed: 37 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ permissions:
2323

2424
jobs:
2525
test:
26-
name: Test with Node.js ${{ inputs.node-version }} on ${{ inputs.runs-on }}
26+
name: Test ${{ inputs.codecov == true && 'and Coverage ' || '' }}with Node.js ${{ inputs.node-version }} on ${{ inputs.runs-on }}
2727
timeout-minutes: 20
2828
runs-on: ${{ inputs.runs-on }}
2929
steps:
@@ -78,6 +78,22 @@ jobs:
7878
NODE_V8_COVERAGE: ${{ inputs.codecov == true && './coverage/tmp' || '' }}
7979
UNDICI_NO_WASM_SIMD: ${{ inputs['no-wasm-simd'] }}
8080

81+
- name: Test node-test
82+
run: npm run test:node-test
83+
id: test-node-test
84+
env:
85+
CI: true
86+
NODE_V8_COVERAGE: ${{ inputs.codecov == true && './coverage/tmp' || '' }}
87+
UNDICI_NO_WASM_SIMD: ${{ inputs['no-wasm-simd'] }}
88+
89+
- name: Test fetch
90+
run: npm run test:fetch
91+
id: test-fetch
92+
env:
93+
CI: true
94+
NODE_V8_COVERAGE: ${{ inputs.codecov == true && './coverage/tmp' || '' }}
95+
UNDICI_NO_WASM_SIMD: ${{ inputs['no-wasm-simd'] }}
96+
8197
- name: Test node-fetch
8298
run: npm run test:node-fetch
8399
id: test-node-fetch
@@ -94,33 +110,34 @@ jobs:
94110
NODE_V8_COVERAGE: ${{ inputs.codecov == true && './coverage/tmp' || '' }}
95111
UNDICI_NO_WASM_SIMD: ${{ inputs['no-wasm-simd'] }}
96112

97-
- name: Test cache-interceptor
113+
- name: Test cache-interceptor ${{ inputs.node-version != '20' && 'with' || 'without' }} sqlite
98114
run: npm run test:cache-interceptor
99115
id: test-cache-interceptor
100116
env:
101117
CI: true
118+
NODE_OPTIONS: ${{ inputs.node-version != '20' && '--experimental-sqlite' || '' }}
102119
NODE_V8_COVERAGE: ${{ inputs.codecov == true && './coverage/tmp' || '' }}
103120
UNDICI_NO_WASM_SIMD: ${{ inputs['no-wasm-simd'] }}
104-
105-
- name: Test interceptors
106-
run: npm run test:interceptors
107-
id: test-interceptors
121+
122+
- name: Test cache-tests
123+
run: npm run test:cache-tests
124+
id: test-cache-tests
108125
env:
109126
CI: true
110127
NODE_V8_COVERAGE: ${{ inputs.codecov == true && './coverage/tmp' || '' }}
111128
UNDICI_NO_WASM_SIMD: ${{ inputs['no-wasm-simd'] }}
112129

113-
- name: Test fetch
114-
run: npm run test:fetch
115-
id: test-fetch
130+
- name: Test cookies
131+
run: npm run test:cookies
132+
id: test-cookies
116133
env:
117134
CI: true
118135
NODE_V8_COVERAGE: ${{ inputs.codecov == true && './coverage/tmp' || '' }}
119136
UNDICI_NO_WASM_SIMD: ${{ inputs['no-wasm-simd'] }}
120-
121-
- name: Test cookies
122-
run: npm run test:cookies
123-
id: test-cookies
137+
138+
- name: Test interceptors
139+
run: npm run test:interceptors
140+
id: test-interceptors
124141
env:
125142
CI: true
126143
NODE_V8_COVERAGE: ${{ inputs.codecov == true && './coverage/tmp' || '' }}
@@ -140,6 +157,7 @@ jobs:
140157
env:
141158
CI: true
142159
NODE_V8_COVERAGE: ${{ inputs.codecov == true && './coverage/tmp' || '' }}
160+
UNDICI_NO_WASM_SIMD: ${{ inputs['no-wasm-simd'] }}
143161

144162
- name: Test subresource-integrity
145163
run: npm run test:subresource-integrity
@@ -157,38 +175,13 @@ jobs:
157175
NODE_V8_COVERAGE: ${{ inputs.codecov == true && './coverage/tmp' || '' }}
158176
UNDICI_NO_WASM_SIMD: ${{ inputs['no-wasm-simd'] }}
159177

160-
- name: Test node-test
161-
run: npm run test:node-test
162-
id: test-node-test
163-
env:
164-
CI: true
165-
NODE_V8_COVERAGE: ${{ inputs.codecov == true && './coverage/tmp' || '' }}
166-
UNDICI_NO_WASM_SIMD: ${{ inputs['no-wasm-simd'] }}
167-
168-
- name: Test cache-tests
169-
run: npm run test:cache-tests
170-
id: test-cache-tests
171-
env:
172-
CI: true
173-
NODE_V8_COVERAGE: ${{ inputs.codecov == true && './coverage/tmp' || '' }}
174-
UNDICI_NO_WASM_SIMD: ${{ inputs['no-wasm-simd'] }}
175-
176178
- name: Test jest
177179
run: npm run test:jest
178180
id: test-jest
179181
env:
180182
CI: true
181183
NODE_V8_COVERAGE: ''
182184
UNDICI_NO_WASM_SIMD: ${{ inputs['no-wasm-simd'] }}
183-
184-
- name: Test sqlite
185-
if: inputs.node-version != '20'
186-
run: npm run test:sqlite
187-
id: test-sqlite
188-
env:
189-
CI: true
190-
NODE_V8_COVERAGE: ${{ inputs.codecov == true && './coverage/tmp' || '' }}
191-
UNDICI_NO_WASM_SIMD: ${{ inputs['no-wasm-simd'] }}
192185

193186
- name: Test wpt
194187
run: npm run test:wpt
@@ -198,7 +191,12 @@ jobs:
198191
NODE_V8_COVERAGE: ${{ inputs.codecov == true && './coverage/tmp' || '' }}
199192
UNDICI_NO_WASM_SIMD: ${{ inputs['no-wasm-simd'] }}
200193

201-
- name: Coverage Report
194+
- name: Coverage summary
195+
if: inputs.codecov == true
196+
run: npm run coverage:report:ci
197+
id: prepare-coverage-report
198+
199+
- name: Upload coverage report to Codecov
202200
if: inputs.codecov == true
203201
uses: codecov/codecov-action@fdcc8476540edceab3de004e990f80d881c6cc00 # v5.5.0
204202
with:

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@
7373
"test:javascript:without-intl": "npm run test:javascript:no-jest",
7474
"test:busboy": "borp -p \"test/busboy/*.js\"",
7575
"test:cache": "borp -p \"test/cache/*.js\"",
76-
"test:sqlite": "cross-env NODE_OPTIONS=--experimental-sqlite borp -p \"test/cache-interceptor/*.js\"",
7776
"test:cache-interceptor": "borp -p \"test/cache-interceptor/*.js\"",
77+
"test:cache-interceptor:sqlite": "cross-env NODE_OPTIONS=--experimental-sqlite npm run test:cache-interceptor",
7878
"test:cookies": "borp -p \"test/cookie/*.js\"",
7979
"test:eventsource": "npm run build:node && borp --expose-gc -p \"test/eventsource/*.js\"",
8080
"test:fuzzing": "node test/fuzzing/fuzzing.test.js",

test/cache-interceptor/cache-tests.mjs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,11 @@ for (let i = 0; i < testEnvironments.length; i++) {
135135
const port = PORT + i
136136

137137
const promise = new Promise((resolve) => {
138-
const process = fork(join(import.meta.dirname, 'cache-tests-worker.mjs'), {
138+
const cacheTestsWorkerProcess = fork(join(import.meta.dirname, 'cache-tests-worker.mjs'), {
139139
stdio: 'pipe',
140140
env: {
141+
NODE_OPTIONS: process.env.NODE_OPTIONS,
142+
NODE_V8_COVERAGE: process.env.NODE_V8_COVERAGE,
141143
TEST_ENVIRONMENT: JSON.stringify(environment),
142144
BASE_URL: `${PROTOCOL}://localhost:${port}`,
143145
CI: CLI_OPTIONS.values.ci ? 'true' : undefined,
@@ -148,15 +150,15 @@ for (let i = 0; i < testEnvironments.length; i++) {
148150
})
149151

150152
const stdout = []
151-
process.stdout.on('data', chunk => {
153+
cacheTestsWorkerProcess.stdout.on('data', chunk => {
152154
stdout.push(chunk)
153155
})
154156

155-
process.stderr.on('error', chunk => {
157+
cacheTestsWorkerProcess.stderr.on('error', chunk => {
156158
stdout.push(chunk)
157159
})
158160

159-
process.on('close', code => {
161+
cacheTestsWorkerProcess.on('close', code => {
160162
resolve([code, stdout])
161163
})
162164
})

0 commit comments

Comments
 (0)