diff --git a/.gitlab/generate-common.php b/.gitlab/generate-common.php index 009673d1e9..24850a6293 100644 --- a/.gitlab/generate-common.php +++ b/.gitlab/generate-common.php @@ -45,6 +45,60 @@ function dockerhub_login() { + # Kill leftover containers — a previous run may still hold php_ddtrace.dll open. + $containers = docker ps -aq 2>$null + if ($containers) { docker rm -f $containers 2>$null } + + # Use cmd.exe rd from the parent dir: handles junctions/symlinks that PS5.1 Remove-Item can't. + Write-Host "Performing workspace cleanup..." + $workspace = $PWD.Path + Push-Location .. + cmd /c "rd /s /q ""$workspace""" + if (-not (Test-Path $workspace)) { + New-Item -ItemType Directory -Path $workspace -Force | Out-Null + } + Pop-Location + $remaining = Get-ChildItem -Path . -Force -ErrorAction SilentlyContinue + if ($remaining) { Write-Host "WARNING: could not remove: $($remaining.Name -join ', ')" } + Write-Host "Cleanup complete." + + # PS 5.1 ignores $PSNativeCommandUseErrorActionPreference — use $LASTEXITCODE checks instead. + $ErrorActionPreference = 'Stop' + + # Manual git clone with proper config + Write-Host "Cloning repository..." + git config --global core.longpaths true + git config --global core.symlinks true + git clone --branch $env:CI_COMMIT_REF_NAME $env:CI_REPOSITORY_URL . + if ($LASTEXITCODE -ne 0) { + Write-Host "ERROR: git clone failed. Remaining workspace contents:" + Get-ChildItem -Force | Select-Object Name + exit $LASTEXITCODE + } + git checkout $env:CI_COMMIT_SHA + if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } + + # Initialize submodules + Write-Host "Initializing submodules..." + git submodule update --init --recursive + if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } + Write-Host "Git setup complete." + + # Preserve artifact packages before workspace cleanup, then restore after clone. + Move-Item packages $env:TEMP\dd-artifacts-packages -Force -ErrorAction SilentlyContinue + + if (Test-Path "$env:TEMP\dd-artifacts-packages") { + Move-Item $env:TEMP\dd-artifacts-packages packages -Force + } + default: retry: diff --git a/.gitlab/generate-package.php b/.gitlab/generate-package.php index 63a6c1da76..6fb5b1aaf8 100644 --- a/.gitlab/generate-package.php +++ b/.gitlab/generate-package.php @@ -506,28 +506,7 @@ GIT_STRATEGY: none CONTAINER_NAME: ${CI_JOB_NAME_SLUG}-${CI_JOB_ID} script: | - # Aggressive Git cleanup - Write-Host "Performing aggressive workspace cleanup with cmd.exe..." - cmd /c "if exist .git rmdir /s /q .git" 2>$null - cmd /c "for /d %d in (*) do @rmdir /s /q ""%d""" 2>$null - cmd /c "del /f /s /q *" 2>$null - Write-Host "Cleanup complete." - - # Make sure we actually fail if a command fails - $ErrorActionPreference = 'Stop' - $PSNativeCommandUseErrorActionPreference = $true - - # Manual git clone with proper config - Write-Host "Cloning repository..." - git config --global core.longpaths true - git config --global core.symlinks true - git clone --branch $env:CI_COMMIT_REF_NAME $env:CI_REPOSITORY_URL . - git checkout $env:CI_COMMIT_SHA - - # Initialize submodules - Write-Host "Initializing submodules..." - git submodule update --init --recursive - Write-Host "Git setup complete." + mkdir extensions_x86_64 mkdir extensions_x86_64_debugsymbols @@ -1107,19 +1086,16 @@ stage: verify tags: [ "windows-v2:2019"] variables: - GIT_CONFIG_COUNT: 2 - GIT_CONFIG_KEY_0: core.longpaths - GIT_CONFIG_VALUE_0: true - GIT_CONFIG_KEY_1: core.symlinks - GIT_CONFIG_VALUE_1: true + GIT_STRATEGY: none needs: - job: "package extension windows" artifacts: true - job: datadog-setup.php artifacts: true - before_script: - - mkdir build - - move packages build + before_script: | + + mkdir build + move packages build script: - Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')) # chocolatey install - .\dockerfiles\verify_packages\verify_windows.ps1 diff --git a/.gitlab/generate-tracer.php b/.gitlab/generate-tracer.php index acefb64738..1969953aea 100644 --- a/.gitlab/generate-tracer.php +++ b/.gitlab/generate-tracer.php @@ -122,28 +122,7 @@ function before_script_steps($with_docker_auth = false) { GIT_STRATEGY: none IMAGE: "registry.ddbuild.io/images/mirror/datadog/dd-trace-ci:php-${PHP_MAJOR_MINOR}_windows" script: | - # Agressive Git cleanup - Write-Host "Performing aggressive workspace cleanup with cmd.exe..." - cmd /c "if exist .git rmdir /s /q .git" 2>$null - cmd /c "for /d %d in (*) do @rmdir /s /q ""%d""" 2>$null - cmd /c "del /f /s /q *" 2>$null - Write-Host "Cleanup complete." - - # Make sure we actually fail if a command fails - $ErrorActionPreference = 'Stop' - $PSNativeCommandUseErrorActionPreference = $true - - # Manual git clone with proper config - Write-Host "Cloning repository..." - git config --global core.longpaths true - git config --global core.symlinks true - git clone --branch $env:CI_COMMIT_REF_NAME $env:CI_REPOSITORY_URL . - git checkout $env:CI_COMMIT_SHA - - # Initialize submodules - Write-Host "Initializing submodules..." - git submodule update --init --recursive - Write-Host "Git setup complete." + mkdir dumps