Skip to content

Commit 15b0b49

Browse files
nirbheekamyspark
authored and
GStreamer Marge Bot
committed
ci: Add scripts to retry windows builds on spurious errors
Similar to cerbero, we run meson commands inside a powershell script that will examine the output for spurious errors and re-run that particular command. https://gitlab.freedesktop.org/slomo/gstreamer/-/jobs/65265526 https://gitlab.freedesktop.org/slomo/gstreamer/-/jobs/65265524 https://gitlab.freedesktop.org/nirbheek/gstreamer/-/jobs/65331410 https://gitlab.freedesktop.org/jcowgill/gstreamer/-/jobs/65489856 rust-lang/rust#127883 (comment) Co-Authored-by: L. E. Segovia <[email protected]> Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7680>
1 parent 339e6e0 commit 15b0b49

File tree

2 files changed

+65
-5
lines changed

2 files changed

+65
-5
lines changed

.gitlab-ci.yml

+7-5
Original file line numberDiff line numberDiff line change
@@ -527,8 +527,8 @@ build vs2022 amd64:
527527
extends: '.build windows'
528528
script:
529529
- !reference [".build windows", "script"]
530-
- meson setup --vsenv build $env:MESON_ARGS $env:GTK_ARGS
531-
- meson compile -C build --jobs $env:FDO_CI_CONCURRENT
530+
- .\ci\run_retry.ps1 meson setup --vsenv build $env:MESON_ARGS $env:GTK_ARGS
531+
- .\ci\run_retry.ps1 meson compile -C build --jobs $env:FDO_CI_CONCURRENT
532532
- .\gst-env.py gst-inspect-1.0.exe --version
533533
- .\gst-env.py gst-inspect-1.0.exe
534534
- mkdir destdir
@@ -543,7 +543,7 @@ build vs2022 amd64 full-static:
543543
script:
544544
- !reference [".build windows", "script"]
545545
- cmd.exe /C "meson setup --vsenv build --default-library=static $env:MESON_ARGS"
546-
- meson compile -C build --jobs $env:FDO_CI_CONCURRENT
546+
- .\ci\run_retry.ps1 meson compile -C build --jobs $env:FDO_CI_CONCURRENT
547547
- .\gst-env.py gst-inspect-1.0.exe --version
548548
- .\gst-env.py gst-inspect-1.0.exe
549549
variables:
@@ -561,8 +561,10 @@ build vs2022 amd64 full-static:
561561
# Setting up a cross build with MSVC is still non-trivial because
562562
# the --vsenv argument cannot be used to set it up
563563
- echo $env:MESON_CROSS_ARGS
564-
- cmd.exe /C "C:\BuildTools\Common7\Tools\VsDevCmd.bat -host_arch=amd64 -arch=$env:ARCH && meson setup build $env:MESON_ARGS $env:GTK_ARGS $env:MESON_CROSS_ARGS"
565-
- cmd.exe /C "C:\BuildTools\Common7\Tools\VsDevCmd.bat -host_arch=amd64 -arch=$env:ARCH && meson compile -C build --jobs $env:FDO_CI_CONCURRENT"
564+
- $env:JOB="meson setup build $env:MESON_ARGS $env:GTK_ARGS $env:MESON_CROSS_ARGS"
565+
- cmd.exe /C """C:\BuildTools\VC\Auxiliary\Build\vcvarsamd64_$env:ARCH.bat"" && powershell.exe -ExecutionPolicy Bypass -File .\ci\run_retry.ps1"
566+
- $env:JOB="meson compile -C build --jobs $env:FDO_CI_CONCURRENT"
567+
- cmd.exe /C """C:\BuildTools\VC\Auxiliary\Build\vcvarsamd64_$env:ARCH.bat"" && powershell.exe -ExecutionPolicy Bypass -File .\ci\run_retry.ps1"
566568

567569
build vs2022 x86:
568570
extends: '.build windows cross'

ci/run_retry.ps1

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Set error action preference to stop on errors
2+
$ErrorActionPreference = "Stop"
3+
4+
# Define error patterns to catch
5+
$ERRORS = @(
6+
'fatal error C1060: compiler is out of heap space'
7+
'cc1plus.exe: out of memory allocating'
8+
'cl : Command line error D8027 : cannot execute'
9+
'Access is denied (os error 5)'
10+
'LINK : fatal error LNK1104: cannot open file'
11+
'PermissionError: [Errno 13] Permission denied:'
12+
'c1: fatal error C1356: unable to find mspdbcore.dll'
13+
)
14+
$RETRIES = 3
15+
$LOGFILE = [System.IO.Path]::GetTempPath() + "logfile.txt"
16+
17+
while ($true) {
18+
$spurious_error = ""
19+
20+
# Execute command and capture output to log file while displaying it
21+
if ($env:JOB) {
22+
# Bypass argument parsing -- https://github.com/PowerShell/PowerShell/issues/19451
23+
& iex $env:JOB | Tee-Object -FilePath $LOGFILE *>&1
24+
} else {
25+
& $args[0] $args[1..($args.Count-1)] | Tee-Object -FilePath $LOGFILE *>&1
26+
}
27+
$ret = $LASTEXITCODE
28+
29+
if ($ret -eq 0) {
30+
break
31+
}
32+
33+
# Read log file and check for known errors
34+
foreach ($line in Get-Content $LOGFILE) {
35+
foreach ($e in $ERRORS) {
36+
if ($line -match [regex]::Escape($e)) {
37+
$spurious_error = $line
38+
break
39+
}
40+
}
41+
if ($spurious_error) {
42+
break
43+
}
44+
}
45+
46+
# Clean up log file
47+
if (Test-Path $LOGFILE) {
48+
Remove-Item -Force $LOGFILE
49+
}
50+
51+
# Exit if no spurious error found or no retries left
52+
if ([string]::IsNullOrEmpty($spurious_error) -or $RETRIES -eq 0) {
53+
exit $ret
54+
}
55+
56+
$RETRIES--
57+
Write-Host "`nRetrying, caught spurious failure: $spurious_error`n"
58+
}

0 commit comments

Comments
 (0)