1
0
Fork 0

simplify windows setup

run gc on pre-checkout
setup buildkite build path in k8s
This commit is contained in:
Mikhail Goncharov 2023-08-28 17:32:20 +00:00
parent 12e76518e2
commit 576f8c9ec3
6 changed files with 15 additions and 57 deletions

View file

@ -98,9 +98,7 @@ RUN git config --system core.longpaths true & `
# handle for debugging of files beeing locked by some processes. # handle for debugging of files beeing locked by some processes.
RUN choco install -y handle 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 unlock_path.ps1 c:\scripts\
COPY pre-checkout.sh c:\scripts\
COPY pre-checkout.bat c:\buildkite-agent\hooks\ COPY pre-checkout.bat c:\buildkite-agent\hooks\
COPY post-checkout.bat c:\buildkite-agent\hooks\
CMD ["powershell", "C:\\scripts\\start_agent.ps1"] CMD ["powershell", "C:\\scripts\\start_agent.ps1"]

View file

@ -1,2 +0,0 @@
echo "post-checkout"
powershell c:\scripts\post-checkout.ps1

View file

@ -1,21 +0,0 @@
# 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
}

View file

@ -1,26 +0,0 @@
# $env:BUILDKITE_BUILD_CHECKOUT_PATH="$env:BUILDKITE_BUILD_PATH/src"
echo "BUILDKITE_BUILD_CHECKOUT_PATH: $env:BUILDKITE_BUILD_CHECKOUT_PATH"
echo "BUILDKITE_BUILD_PATH: $env:BUILDKITE_BUILD_PATH"
echo "unlocking git"
taskkill /F /IM git.exe
rm -Force "$env:BUILDKITE_BUILD_CHECKOUT_PATH/.git/index.lock"
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 -Recurse -Force -ErrorAction Ignore $env:BUILDKITE_BUILD_CHECKOUT_PATH
}
}

View file

@ -3,7 +3,7 @@
echo "BUILDKITE_BUILD_CHECKOUT_PATH: $BUILDKITE_BUILD_CHECKOUT_PATH" echo "BUILDKITE_BUILD_CHECKOUT_PATH: $BUILDKITE_BUILD_CHECKOUT_PATH"
echo "BUILDKITE_BUILD_PATH: $BUILDKITE_BUILD_PATH" echo "BUILDKITE_BUILD_PATH: $BUILDKITE_BUILD_PATH"
echo "unlocking git" echo "unlocking git"
pkill -f git.exe taskkill -F -IM git.exe
rm -f "$BUILDKITE_BUILD_CHECKOUT_PATH/.git/index.lock" rm -f "$BUILDKITE_BUILD_CHECKOUT_PATH/.git/index.lock"
echo 'running processes (before)' echo 'running processes (before)'
ps aux | grep "$BUILDKITE_BUILD_CHECKOUT_PATH" ps aux | grep "$BUILDKITE_BUILD_CHECKOUT_PATH"
@ -22,5 +22,15 @@ if [ -d "$BUILDKITE_BUILD_CHECKOUT_PATH" ]; then
echo "Remote URL does not match. Deleting and recreating the directory." echo "Remote URL does not match. Deleting and recreating the directory."
cd /c/ cd /c/
rm -rf "$BUILDKITE_BUILD_CHECKOUT_PATH" rm -rf "$BUILDKITE_BUILD_CHECKOUT_PATH"
rm /c/ws/git_gc_counter
else
# Run git gc from time to time to prevent repo from growing.
echo -n "x" >> /c/ws/git_gc_counter
echo "GC counter $(wc -c < /c/ws/git_gc_counter)/10"
if [ "$(wc -c < /c/ws/git_gc_counter)" -gt 10 ]; then
echo "Running 'git gc'..."
git gc
rm /c/ws/git_gc_counter
fi
fi fi
fi fi

View file

@ -1,11 +1,10 @@
# TODO: remove after migrating scripts to LLVM repo.
git clone https://github.com/google/llvm-premerge-checks.git c:\llvm-premerge-checks git clone https://github.com/google/llvm-premerge-checks.git c:\llvm-premerge-checks
New-Item c:\ws -Force -ItemType Directory $env:BUILDKITE_BUILD_CHECKOUT_PATH = "$env:BUILDKITE_BUILD_PATH\src"
$env:BUILDKITE_BUILD_PATH = "c:\ws"
$env:BUILDKITE_BUILD_CHECKOUT_PATH = "c:\ws\src"
# Install Buildkite agent. # Install Buildkite agent.
iex ((New-Object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/buildkite/agent/master/install.ps1')) iex ((New-Object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/buildkite/agent/master/install.ps1'))
$env:SCCACHE_DIR="C:\ws\sccache" $env:SCCACHE_DIR="$env:BUILDKITE_BUILD_PATH\sccache"
$env:SCCACHE_IDLE_TIMEOUT="0" $env:SCCACHE_IDLE_TIMEOUT="0"
Remove-Item -Recurse -Force -ErrorAction Ignore $env:SCCACHE_DIR Remove-Item -Recurse -Force -ErrorAction Ignore $env:SCCACHE_DIR
sccache --start-server sccache --start-server