ci: fix Windows job flakiness caused by dirty workspace#3694
Open
ci: fix Windows job flakiness caused by dirty workspace#3694
Conversation
|
✨ Fix all issues with BitsAI or with Cursor
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #3694 +/- ##
==========================================
- Coverage 62.40% 62.30% -0.11%
==========================================
Files 142 142
Lines 13586 13586
Branches 1775 1775
==========================================
- Hits 8479 8465 -14
- Misses 4301 4314 +13
- Partials 806 807 +1 see 3 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
The cmd.exe "for /d" loop used to clean the workspace skips directory entries during deletion (enumerates and deletes in the same pass), leaving artifact output dirs from previous runs. When git clone then fails because the workspace isn't empty, $PSNativeCommandUseErrorActionPreference = $true is silently ignored on Windows PowerShell 5.1 (requires PS 7.3+), so the script continues without source code and phpize.bat fails with exit 10. Fixes: - Replace cmd.exe cleanup loop with PowerShell-native Get-ChildItem | Remove-Item which handles each entry independently and tolerates locked files - Add WARNING log line if any items could not be removed (aids debugging) - Remove $PSNativeCommandUseErrorActionPreference (no-op on PS 5.1) - Add explicit $LASTEXITCODE checks after git clone, checkout, and submodule init Applied to both generate-package.php (compile extension windows) and generate-tracer.php (windows test_c).
… cleanup PowerShell 5.1's Remove-Item -Recurse throws "mismatch between the tag specified in the request and the tag present in the reparse point" when the workspace contains Windows junction points (created by switch-php, e.g. /php <<===>> /php-nts) or NTFS symlinks (from core.symlinks=true git clone). This caused the entire cleanup to fail silently, leaving the full previous repo tree in place and making git clone fail again. Fix: navigate to the parent directory and run cmd.exe "rd /s /q" on the whole workspace directory. cmd.exe rd removes junction entries without following them into their targets, avoiding the reparse point issue entirely. The directory is then recreated empty before returning.
f068d19 to
b7d680b
Compare
php_ddtrace.dll (and other workspace files) are locked with "Access is denied" when a Docker container from a previous job run is still alive with the workspace volume mounted. This causes rd /s /q to fail and git clone to fail again. Fix: force-remove all running containers (docker rm -f $(docker ps -aq)) before the rd /s /q workspace cleanup, releasing all file handles.
7f0beb4 to
181b7e6
Compare
181b7e6 to
c286608
Compare
…leanup Applies the same GIT_STRATEGY: none + manual clone pattern to the verify windows job, saving/restoring the packages/ artifact around the workspace cleanup to avoid git checkout failures on locked/junction files.
394ad5e to
b0d2cde
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes Windows CI job flakiness caused by leftover files from previous runs on persistent Windows runners.
Root causes fixed:
x64/Release/php_ddtrace.dll/.pdb: NTFS junction points/reparse points that PS 5.1Remove-Item -Recurseand git checkout can't remove, causinggit checkoutto fail with "Invalid argument"run-tests.phpand PHP test files: held open with "Permission Denied" by previous job's processesphp_ddtrace.dllopen across jobsSolution:
windows_git_setup()function ingenerate-common.phpused by all three affected Windows jobscmd.exe rd /s /qfrom the parent directory (handles junction points that PS 5.1 can't)git clone+git checkoutwith$LASTEXITCODEguards (PS 5.1 ignores$PSNativeCommandUseErrorActionPreference)GIT_STRATEGY: noneto skip GitLab's built-in checkoutJobs fixed:
compile extension windows(generate-package.php)windows test_c(generate-tracer.php)verify windows(generate-package.php) — uses a variantwindows_git_setup_with_packages()that saves/restores thepackages/artifact around the workspace wipe