renamed windows container
This commit is contained in:
parent
91536475c7
commit
0e00301500
11 changed files with 103 additions and 8 deletions
|
@ -1,2 +0,0 @@
|
|||
echo "post-checkout"
|
||||
powershell c:\llvm-premerge-checks\scripts\windows\post-checkout.ps1
|
|
@ -1,5 +0,0 @@
|
|||
echo "pre-checkout: update scripts"
|
||||
cd c:\llvm-premerge-checks
|
||||
git pull
|
||||
git rev-parse HEAD
|
||||
powershell c:\llvm-premerge-checks\scripts\windows\pre-checkout.ps1
|
|
@ -97,7 +97,10 @@ RUN git config --system core.longpaths true & `
|
|||
|
||||
# handle for debugging of files beeing locked by some processes.
|
||||
RUN choco install -y handle
|
||||
COPY start_agent.ps1 C:\scripts\
|
||||
COPY start_agent.ps1 c:\scripts\
|
||||
COPY pre-checkout.ps1 c:\scripts\
|
||||
COPY post-checkout.ps1 c:\scripts\
|
||||
COPY unlock_path.ps1 c:\scripts\
|
||||
COPY pre-checkout.bat c:\buildkite-agent\hooks\
|
||||
COPY post-checkout.bat c:\buildkite-agent\hooks\
|
||||
CMD ["powershell", "C:\\scripts\\start_agent.ps1"]
|
2
containers/buildkite-windows/post-checkout.bat
Normal file
2
containers/buildkite-windows/post-checkout.bat
Normal file
|
@ -0,0 +1,2 @@
|
|||
echo "post-checkout"
|
||||
powershell c:\scripts\post-checkout.ps1
|
21
containers/buildkite-windows/post-checkout.ps1
Normal file
21
containers/buildkite-windows/post-checkout.ps1
Normal file
|
@ -0,0 +1,21 @@
|
|||
# Copyright 2021 Google LLC
|
||||
|
||||
# Licensed under the the Apache License v2.0 with LLVM Exceptions (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
|
||||
# https://llvm.org/LICENSE.txt
|
||||
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# As git gc takes non-trivial time on windows, run it only 5% of the time.
|
||||
if (( Get-Random -Maximum 100 ) -lt 10 ) {
|
||||
echo "running git gc"
|
||||
pwd
|
||||
git gc
|
||||
}
|
||||
|
2
containers/buildkite-windows/pre-checkout.bat
Normal file
2
containers/buildkite-windows/pre-checkout.bat
Normal file
|
@ -0,0 +1,2 @@
|
|||
REM TODO: use powershell shell for hooks directly
|
||||
powershell c:\scripts\pre-checkout.ps1
|
27
containers/buildkite-windows/pre-checkout.ps1
Normal file
27
containers/buildkite-windows/pre-checkout.ps1
Normal file
|
@ -0,0 +1,27 @@
|
|||
$env:BUILDKITE_BUILD_CHECKOUT_PATH="$env:BUILDKITE_BUILD_PATH/src"
|
||||
|
||||
echo "unlocking git"
|
||||
taskkill /F /IM git.exe
|
||||
rm -Force "$env:BUILDKITE_BUILD_CHECKOUT_PATH/.git/index.lock"
|
||||
echo "BUILDKITE_BUILD_CHECKOUT_PATH: $env:BUILDKITE_BUILD_CHECKOUT_PATH"
|
||||
echo "BUILDKITE_BUILD_PATH: $env:BUILDKITE_BUILD_PATH"
|
||||
echo 'running processes (before)'
|
||||
Get-Process | Where-Object {$_.Path -like "$env:BUILDKITE_BUILD_CHECKOUT_PATH*"} | Select-Object -ExpandProperty Path
|
||||
echo "unlocking $env:BUILDKITE_BUILD_CHECKOUT_PATH"
|
||||
handle -nobanner $env:BUILDKITE_BUILD_CHECKOUT_PATH
|
||||
c:\scripts\unlock_path.ps1 $env:BUILDKITE_BUILD_CHECKOUT_PATH
|
||||
echo 'running processes (after)'
|
||||
Get-Process | Where-Object {$_.Path -like "$env:BUILDKITE_BUILD_CHECKOUT_PATH*"} | Select-Object -ExpandProperty Path
|
||||
|
||||
echo "BUILDKITE_REPO: $env:BUILDKITE_REPO"
|
||||
if (Test-Path -Path $env:BUILDKITE_BUILD_CHECKOUT_PATH) {
|
||||
Set-Location -Path $env:BUILDKITE_BUILD_CHECKOUT_PATH
|
||||
$remoteUrl = git remote get-url origin
|
||||
echo "current remote URL: $remoteUrl"
|
||||
if ($remoteUrl -ne $env:BUILDKITE_REPO) {
|
||||
Write-Host "Remote URL does not match. Deleting and recreating the directory."
|
||||
Set-Location -Path "C:\"
|
||||
Remove-Item -Path $env:BUILDKITE_BUILD_CHECKOUT_PATH -Recurse -Force
|
||||
}
|
||||
}
|
||||
|
47
containers/buildkite-windows/unlock_path.ps1
Normal file
47
containers/buildkite-windows/unlock_path.ps1
Normal file
|
@ -0,0 +1,47 @@
|
|||
# Copyright 2021 Google LLC
|
||||
|
||||
# Licensed under the the Apache License v2.0 with LLVM Exceptions (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
|
||||
# https://llvm.org/LICENSE.txt
|
||||
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# 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
|
||||
Write-Host "Unlocking path" $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"
|
Loading…
Reference in a new issue