1
0
Fork 0

Enable windows builds back

Now we run a pre-commit hook that tries to kill any process that locked
a file in target directory.

Updated timeout interval on windows from 120 to 90 minutes.

Fixes #243
This commit is contained in:
Mikhail Goncharov 2020-10-07 10:08:13 +02:00
parent 5cd16dde45
commit ea943424f3
5 changed files with 40 additions and 3 deletions

View file

@ -4,5 +4,8 @@
ARG agent_windows_version=latest
FROM gcr.io/llvm-premerge-checks/agent-windows-vs2019:${agent_windows_version}
RUN choco install -y handle --checksum 524E61547C8E26608CDA1B11B6E9471616CCCC48530F6E7EC9131EABF839357E
COPY start_agent.ps1 C:\scripts\
COPY pre-checkout.bat c:\buildkite-agent\hooks\
COPY unlock_path.ps1 c:\scripts
CMD "powershell C:\scripts\start_agent.ps1"

View file

@ -0,0 +1,2 @@
handle -nobanner %BUILDKITE_BUILD_CHECKOUT_PATH%
powershell c:\scripts\unlock_path.ps1 %BUILDKITE_BUILD_CHECKOUT_PATH%

View file

@ -0,0 +1,34 @@
# Based ob https://dandraka.com/2019/08/13/find-and-kill-processes-that-lock-a-file-or-directory/
$path = $args[0]
$handleOutput = & handle -a $path
if ($handleOutput -match "no matching handles found") {
Write-Host "Nothing to kill, exiting"
exit
}
$pidList = New-Object System.Collections.ArrayList
$lines = $handleOutput -split "`n"
foreach($line in $lines) {
# sample line:
# chrome.exe pid: 11392 type: File 5BC: C:\Windows\Fonts\timesbd.ttf
# regex to get pid and process name: (.*)\b(?:.*)(?:pid: )(\d*)
$matches = $null
$line -match "(.*)\b(?:.*)(?:pid: )(\d*)" | Out-Null
if (-not $matches) { continue }
if ($matches.Count -eq 0) { continue }
$pidName = $matches[1]
$pidStr = $matches[2]
if ($pidList -notcontains $pidStr) {
Write-Host "Will kill process $pidStr $pidName"
$pidList.Add($pidStr) | Out-Null
}
}
foreach($pidStr in $pidList) {
$pidInt = [int]::Parse($pidStr)
Stop-Process -Id $pidInt -Force
Write-Host "Killed process $pidInt"
}
Write-Host "Finished"

View file

@ -91,8 +91,6 @@ def generic_linux(projects: str, check_diff: bool) -> List:
def generic_windows(projects: str) -> List:
# TODO: windows builds are temporary disabled #243
return []
if os.getenv('ph_skip_windows') is not None:
return []
scripts_refspec = os.getenv("ph_scripts_refspec", "master")
@ -138,7 +136,7 @@ def generic_windows(projects: str) -> List:
],
'artifact_paths': ['artifacts/**/*', '*_result.json'],
'agents': win_agents,
'timeout_in_minutes': 120,
'timeout_in_minutes': 90,
'retry': {'automatic': [
{'exit_status': -1, 'limit': 2}, # Agent lost
{'exit_status': 255, 'limit': 2}, # Forced agent shutdown