Skip to content

YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context

ci(windows): Remove + recopy ONNX DLLs to defeat 0-byte stubs preserved by rust-cache

Louis Beaumont3a7ede8aab20
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 3a01bc719..1a640690e 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -162,21 +162,21 @@ jobs:
if (-not (Test-Path $dst)) {
New-Item -ItemType Directory -Path $dst -Force | Out-Null
}
+ # Always remove + re-copy. Prior cancelled runs could leave
+ # 0-byte stubs that Swatinem/rust-cache preserves across runs;
+ # once cached, every subsequent test binary fails ORT load.
+ # See e2e-test.yml for the same fix in the e2e-windows job.
Get-ChildItem -Path $src -Filter "onnxruntime*.dll" | ForEach-Object {
$dest = Join-Path $dst $_.Name
- try {
- if ((Test-Path $dest) -and ((Resolve-Path $_.FullName).Path -eq (Resolve-Path $dest).Path)) {
- Write-Host "skip self-copy: $($_.Name)"
- } else {
- Copy-Item -Path $_.FullName -Destination $dest -Force
- }
- } catch [System.IO.IOException] {
- if ($_.Exception.Message -match 'with itself') {
- Write-Host "skip self-overwrite: $($_.Name)"
- } else { throw }
+ if (Test-Path $dest) { Remove-Item -Path $dest -Force }
+ [System.IO.File]::Copy($_.FullName, $dest, $true)
+ }
+ Get-ChildItem -Path $dst -Filter "onnxruntime*.dll" | ForEach-Object {
+ if ($_.Length -eq 0) {
+ throw "Staged DLL is 0 bytes: $($_.Name) — source likely corrupt"
}
+ Write-Host "$($_.Name) $($_.Length) bytes"
}
- Get-ChildItem -Path $dst -Filter "onnxruntime*.dll" | Select-Object Name, Length
# Add the ONNX lib dir to PATH for ALL cargo-test steps below.
# The DLL staging step above does put onnxruntime*.dll next to the
diff --git a/.github/workflows/e2e-test.yml b/.github/workflows/e2e-test.yml
index 312436010..fa422458a 100644
--- a/.github/workflows/e2e-test.yml
+++ b/.github/workflows/e2e-test.yml
@@ -158,29 +158,33 @@ jobs:
if (-not (Test-Path $dst)) {
New-Item -ItemType Directory -Path $dst -Force | Out-Null
}
- # Skip the file if it's already present at $dst with identical
- # content. The Rust cache + the ONNX cache restore can both put
- # the same DLL into target/debug across cached runs, and
- # Copy-Item -Force fails ("Cannot overwrite the item with
- # itself") instead of being a no-op when source and destination
- # resolve to the same path. Per-file copy with try/catch lets us
- # treat self-overwrite as success while still surfacing real
- # copy failures (permission, disk full, etc.).
+ # Always remove any existing onnxruntime*.dll at the destination
+ # before copying. Why this is necessary: prior cancelled runs
+ # could have left 0-byte stubs at target/debug/onnxruntime*.dll
+ # which Swatinem/rust-cache then preserves across runs — once
+ # cached, every subsequent run inherits the stubs and the test
+ # binary fails to load ORT. Force-copy alone wasn't enough
+ # because the earlier per-file try/catch (with Resolve-Path
+ # comparison) was firing the self-overwrite catch on every
+ # copy under cause-unknown PowerShell path normalization,
+ # silently no-op'ing the actual copy.
+ # Use [System.IO.File]::Copy directly — fewer PowerShell
+ # wrapper quirks than Copy-Item.
Get-ChildItem -Path $src -Filter "onnxruntime*.dll" | ForEach-Object {
$dest = Join-Path $dst $_.Name
- try {
- if ((Test-Path $dest) -and ((Resolve-Path $_.FullName).Path -eq (Resolve-Path $dest).Path)) {
- Write-Host "skip self-copy: $($_.Name)"
- } else {
- Copy-Item -Path $_.FullName -Destination $dest -Force
- }
- } catch [System.IO.IOException] {
- if ($_.Exception.Message -match 'with itself') {
- Write-Host "skip self-overwrite: $($_.Name)"
- } else { throw }
+ if (Test-Path $dest) { Remove-Item -Path $dest -Force }
+ [System.IO.File]::Copy($_.FullName, $dest, $true)
+ }
+ # Verify each DLL is non-zero. If any is 0 bytes the test
+ # binary will exit STATUS_DLL_NOT_FOUND (0xc0000135) at load
+ # time — fail here loudly instead of debugging from the
+ # downstream symptom.
+ Get-ChildItem -Path $dst -Filter "onnxruntime*.dll" | ForEach-Object {
+ if ($_.Length -eq 0) {
+ throw "Staged DLL is 0 bytes: $($_.Name) — source likely corrupt"
}
+ Write-Host "$($_.Name) $($_.Length) bytes"
}
- Get-ChildItem -Path $dst -Filter "onnxruntime*.dll" | Select-Object Name, Length
- name: Run E2E Tests
shell: pwsh