Skip to content

Commit

Permalink
Integration tests cleanup: Remove-ItemWithRetry (#2040)
Browse files Browse the repository at this point in the history
  • Loading branch information
IhateTrains authored Jul 5, 2024
1 parent 8b88175 commit 158af47
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion .github/workflows/integration_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,26 @@ jobs:
- name: "Cleanup"
if: always()
run: |
Get-ChildItem -Path $Env:GITHUB_WORKSPACE -Recurse -Force | Remove-Item -force -recurse
function Remove-ItemWithRetry {
param (
[string]$Path,
[int]$Retries = 5,
[int]$Delay = 2000
)
for ($i = 0; $i -lt $Retries; $i++) {
try {
Remove-Item -Path $Path -Force -Recurse
Write-Host "Successfully deleted $Path"
return
} catch {
Write-Host "Attempt $($i+1) failed: $_"
Start-Sleep -Milliseconds $Delay
}
}
throw "Failed to delete $Path after $Retries attempts"
}
Get-ChildItem -Path $Env:GITHUB_WORKSPACE -Recurse -Force | ForEach-Object {
Remove-ItemWithRetry -Path $_.FullName
}

0 comments on commit 158af47

Please sign in to comment.