Skip to content

Commit 1a74531

Browse files
committed
ci: retry flaky tests on Windows Node.js 24
Assisted-by: openai:gpt-5.5 Signed-off-by: Kamat, Trivikram <16024985+trivikr@users.noreply.github.com>
1 parent df5ded9 commit 1a74531

3 files changed

Lines changed: 41 additions & 2 deletions

File tree

scripts/platform-shell.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,13 @@ const { writeFileSync } = require('node:fs')
55
const { resolve } = require('node:path')
66

77
if (platform() === 'win32') {
8+
const shouldRetryTests = process.env.GITHUB_ACTIONS === 'true' && process.versions.node.split('.')[0] === '24'
9+
const scriptShell = shouldRetryTests
10+
? resolve(__dirname, 'retry-test-shell.cmd')
11+
: 'C:\\windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe'
12+
813
writeFileSync(
9-
resolve(__dirname, '.npmrc'),
10-
'script-shell = "C:\\windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe"\n'
14+
resolve(__dirname, shouldRetryTests ? '..' : '.', '.npmrc'),
15+
`script-shell = "${scriptShell}"\n`
1116
)
1217
}

scripts/retry-test-shell.cmd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
@echo off
2+
powershell.exe -NoLogo -NoProfile -ExecutionPolicy Bypass -File "%~dp0retry-test-shell.ps1" %*

scripts/retry-test-shell.ps1

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
$testScripts = @(
2+
'test:cache',
3+
'test:cache-interceptor',
4+
'test:cache-tests',
5+
'test:cookies',
6+
'test:eventsource',
7+
'test:fetch',
8+
'test:infra',
9+
'test:interceptors',
10+
'test:jest',
11+
'test:node-fetch',
12+
'test:node-test',
13+
'test:subresource-integrity',
14+
'test:unit',
15+
'test:websocket',
16+
'test:wpt'
17+
)
18+
19+
$command = $args[-1]
20+
$shouldRetry = $testScripts -contains $env:npm_lifecycle_event
21+
22+
cmd.exe /d /s /c $command
23+
$exitCode = $LASTEXITCODE
24+
25+
if ($exitCode -eq 0 -or -not $shouldRetry) {
26+
exit $exitCode
27+
}
28+
29+
Write-Host "Command failed with exit code $exitCode. Retrying once on Windows with Node.js 24."
30+
31+
cmd.exe /d /s /c $command
32+
exit $LASTEXITCODE

0 commit comments

Comments
 (0)