Skip to content

Commit 7f0beb4

Browse files
committed
ci: trim verbose comments in Windows workspace cleanup scripts
1 parent 57a2663 commit 7f0beb4

2 files changed

Lines changed: 6 additions & 22 deletions

File tree

.gitlab/generate-package.php

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -506,17 +506,11 @@
506506
GIT_STRATEGY: none
507507
CONTAINER_NAME: ${CI_JOB_NAME_SLUG}-${CI_JOB_ID}
508508
script: |
509-
# Force-remove all running Docker containers before touching the workspace.
510-
# A container from a previous job run may still be alive with the workspace volume mounted,
511-
# holding an open handle on php_ddtrace.dll — which makes rd /s /q fail with "Access is denied".
509+
# Kill leftover containers — a previous run may still hold php_ddtrace.dll open.
512510
$containers = docker ps -aq 2>$null
513511
if ($containers) { docker rm -f $containers 2>$null }
514512

515-
# Reliable workspace cleanup: navigate to parent and use cmd.exe "rd /s /q" on the whole
516-
# workspace directory. cmd.exe rd correctly handles Windows junction points (removes the
517-
# junction entry without following it into its target), unlike PowerShell's Remove-Item
518-
# -Recurse which throws reparse point mismatch errors on PS 5.1 when the workspace
519-
# contains junctions (e.g. created by switch-php) or NTFS symlinks (from core.symlinks clone).
513+
# Use cmd.exe rd from the parent dir: handles junctions/symlinks that PS5.1 Remove-Item can't.
520514
Write-Host "Performing workspace cleanup..."
521515
$workspace = $PWD.Path
522516
Push-Location ..
@@ -529,10 +523,8 @@
529523
if ($remaining) { Write-Host "WARNING: could not remove: $($remaining.Name -join ', ')" }
530524
Write-Host "Cleanup complete."
531525

532-
# Fail fast on PowerShell cmdlet errors (works on PS 5.1+).
526+
# PS 5.1 ignores $PSNativeCommandUseErrorActionPreference — use $LASTEXITCODE checks instead.
533527
$ErrorActionPreference = 'Stop'
534-
# Note: $PSNativeCommandUseErrorActionPreference requires PS 7.3+ and is silently ignored on PS 5.1
535-
# (Windows Server 2019 default). Use explicit $LASTEXITCODE checks for native commands instead.
536528

537529
# Manual git clone with proper config
538530
Write-Host "Cloning repository..."

.gitlab/generate-tracer.php

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -122,17 +122,11 @@ function before_script_steps($with_docker_auth = false) {
122122
GIT_STRATEGY: none
123123
IMAGE: "registry.ddbuild.io/images/mirror/datadog/dd-trace-ci:php-${PHP_MAJOR_MINOR}_windows"
124124
script: |
125-
# Force-remove all running Docker containers before touching the workspace.
126-
# A container from a previous job run may still be alive with the workspace volume mounted,
127-
# holding an open handle on php_ddtrace.dll — which makes rd /s /q fail with "Access is denied".
125+
# Kill leftover containers — a previous run may still hold php_ddtrace.dll open.
128126
$containers = docker ps -aq 2>$null
129127
if ($containers) { docker rm -f $containers 2>$null }
130128

131-
# Reliable workspace cleanup: navigate to parent and use cmd.exe "rd /s /q" on the whole
132-
# workspace directory. cmd.exe rd correctly handles Windows junction points (removes the
133-
# junction entry without following it into its target), unlike PowerShell's Remove-Item
134-
# -Recurse which throws reparse point mismatch errors on PS 5.1 when the workspace
135-
# contains junctions (e.g. created by switch-php) or NTFS symlinks (from core.symlinks clone).
129+
# Use cmd.exe rd from the parent dir: handles junctions/symlinks that PS5.1 Remove-Item can't.
136130
Write-Host "Performing workspace cleanup..."
137131
$workspace = $PWD.Path
138132
Push-Location ..
@@ -145,10 +139,8 @@ function before_script_steps($with_docker_auth = false) {
145139
if ($remaining) { Write-Host "WARNING: could not remove: $($remaining.Name -join ', ')" }
146140
Write-Host "Cleanup complete."
147141

148-
# Fail fast on PowerShell cmdlet errors (works on PS 5.1+).
142+
# PS 5.1 ignores $PSNativeCommandUseErrorActionPreference — use $LASTEXITCODE checks instead.
149143
$ErrorActionPreference = 'Stop'
150-
# Note: $PSNativeCommandUseErrorActionPreference requires PS 7.3+ and is silently ignored on PS 5.1
151-
# (Windows Server 2019 default). Use explicit $LASTEXITCODE checks for native commands instead.
152144

153145
# Manual git clone with proper config
154146
Write-Host "Cloning repository..."

0 commit comments

Comments
 (0)