Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions .gitlab/generate-common.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,60 @@ function dockerhub_login() {
<?php
}

function windows_git_setup() {
?>
# 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."
<?php
}

function windows_git_setup_with_packages() {
?>
# Preserve artifact packages before workspace cleanup, then restore after clone.
Move-Item packages $env:TEMP\dd-artifacts-packages -Force -ErrorAction SilentlyContinue
<?php windows_git_setup() ?>
if (Test-Path "$env:TEMP\dd-artifacts-packages") {
Move-Item $env:TEMP\dd-artifacts-packages packages -Force
}
<?php
}

?>
default:
retry:
Expand Down
36 changes: 6 additions & 30 deletions .gitlab/generate-package.php
Original file line number Diff line number Diff line change
Expand Up @@ -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."
<?php windows_git_setup() ?>

mkdir extensions_x86_64
mkdir extensions_x86_64_debugsymbols
Expand Down Expand Up @@ -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: |
<?php windows_git_setup_with_packages() ?>
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
Expand Down
23 changes: 1 addition & 22 deletions .gitlab/generate-tracer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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."
<?php windows_git_setup() ?>

mkdir dumps

Expand Down
Loading