Skip to content

Sync changes to BES proto #13509

Sync changes to BES proto

Sync changes to BES proto #13509

name: "Build Windows executor"
on:
pull_request:
branches:
- master
jobs:
build:
name: Build + Test Windows executor
runs-on: windows-2025
if: "!contains(github.event.head_commit.message, 'ci skip')"
steps:
# Setup DevDrive for CoW testing.
# Inspired by https://github.com/samypr100/setup-dev-drive/
- name: Setup DevDrive for CoW testing
shell: pwsh
run: |
# Create VHD on writable location for CoW testing
$vhdPath = "C:\buildbuddy-devdrive.vhdx"
$driveSize = 20GB
$driveFormat = "ReFS"
Write-Host "Creating VHD for CoW testing at $vhdPath"
try {
# Create VHD file
Write-Host "Creating VHD ($driveSize bytes)..."
$vhd = New-VHD -Path $vhdPath -SizeBytes $driveSize -Dynamic
Write-Host "✓ VHD created successfully"
# Mount VHD and get disk info
Write-Host "Mounting VHD..."
$disk = $vhd | Mount-VHD -Passthru
Write-Host "✓ VHD mounted, Disk Number: $($disk.DiskNumber)"
# Initialize disk
Write-Host "Initializing disk..."
$init = $disk | Initialize-Disk -PartitionStyle GPT -PassThru
Write-Host "✓ Disk initialized with GPT partition style"
# Create partition with maximum size and assign the next available drive letter
Write-Host "Creating partition..."
$partition = $init | New-Partition -UseMaximumSize -AssignDriveLetter
if (-not $partition.DriveLetter) {
throw "Failed to assign drive letter to DevDrive partition"
}
$driveLetter = $partition.DriveLetter
Write-Host "✓ Partition created with drive letter: ${driveLetter}:"
# Format as ReFS (without -DevDrive parameter)
Write-Host "Formatting as $driveFormat..."
$volume = $partition | Format-Volume -FileSystem $driveFormat -Force -Confirm:$false
Write-Host "✓ Volume formatted as $driveFormat"
# Enable DevDrive support system-wide
Write-Host "Enabling DevDrive support..."
fsutil devdrv enable | Out-Host
# Set drive as trusted
Write-Host "Setting ${driveLetter}: as trusted..."
fsutil devdrv trust "${driveLetter}:" | Out-Host
# Verify configuration
Write-Host "Drive status verification:"
fsutil devdrv query "${driveLetter}:" | Out-Host
# Test write access
$testFile = "${driveLetter}:\devdrive-test.txt"
"DevDrive test file" | Out-File -FilePath $testFile -Encoding utf8
if (Test-Path $testFile) {
Write-Host "✓ Drive write test successful"
Remove-Item $testFile -Force
}
# Export environment variables
echo "DEVDRIVE_PATH=${driveLetter}:" >> $env:GITHUB_ENV
echo "DEVDRIVE_VHD_PATH=$vhdPath" >> $env:GITHUB_ENV
Write-Host "🎉 CoW drive setup completed successfully at ${driveLetter}:"
} catch {
Write-Error "❌ CoW drive setup failed: $($_.Exception.Message)"
Write-Host "Error details: $($_.ScriptStackTrace)"
exit 1
}
- name: Checkout
uses: actions/checkout@v4
- name: Restore caches
id: cache-restore
uses: ./.github/actions/cache-restore
# This step would list out all files under $vs2022Path for debugging purposes.
# Uncomment if GitHub released a new Windows image and you need to find the new path of cl.exe.
# TODO(sluongng): Make buildbuddy-toolchains detect the path automatically.
#
# - name: "Find CL"
# shell: pwsh # Use PowerShell for better cross-platform compatibility
# run: |
# $vs2022Path = "C:\Program Files\Microsoft Visual Studio\2022\Enterprise"
# if (Test-Path $vs2022Path) {
# Write-Host "Listing files in: $vs2022Path"
# Get-ChildItem -Path $vs2022Path -Recurse -File -Filter cl.exe -ErrorAction SilentlyContinue | ForEach-Object {
# Write-Host $_.FullName
# } | Out-File -FilePath vs2022_files.txt -Encoding utf8
# Write-Host "File list saved to vs2022_files.txt"
# } else {
# Write-Host "Error: Directory not found: $vs2022Path"
# }
# exit 1
- name: Build & test
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GO_REPOSITORY_USE_HOST_CACHE: 1
GOMODCACHE: "C:/go-mod-cache"
# Because "startup" options could not be assigned to different configs in .bazelrc, we are adding them directly here.
# These options follow the best practices in https://bazel.build/configure/windows. Specifically:
# - Set output_user_root to the shortest path possible to avoid Windows path length limitations.
# Without this, actions with longer path input files would fail randomly with irrelevant errors.
#
# - Enable windows symlink helps reduce disk usage.
# Without this, files will be fully copied instead.
run: |
$authArgs = @()
$apiKey = '${{ secrets.BUILDBUDDY_ORG_API_KEY }}'
if ($apiKey) {
$authArgs = @("--remote_header=x-buildbuddy-api-key=$apiKey")
}
bazelisk --output_user_root=C:/0 `
--windows_enable_symlinks `
build `
--config=untrusted-ci-windows `
@authArgs `
-- `
//enterprise/server/cmd/executor:executor
bazelisk --output_user_root=C:/0 `
--windows_enable_symlinks `
test `
--config=untrusted-ci-windows `
--test_tag_filters=-performance `
@authArgs `
-- `
//enterprise/server/remote_execution/workspace:workspace_test `
//enterprise/server/util/procstats:procstats_test `
//server/util/fastcopy:fastcopy_test
# Uncomment the following line to run the fastcopy benchmark test.
# - name: Run fastcopy Go benchmarks (NTFS vs DevDrive)
# shell: pwsh
# run: |
# $authArgs = @()
# $apiKey = '${{ secrets.BUILDBUDDY_ORG_API_KEY }}'
# if ($apiKey) {
# $authArgs = @("--remote_header=x-buildbuddy-api-key=$apiKey")
# }
# # Run dedicated benchmark test target that embeds bench args, per repo pattern.
# bazelisk --output_user_root=C:/0 `
# --windows_enable_symlinks `
# test `
# --config=untrusted-ci-windows `
# --test_tag_filters=performance `
# --test_output=all `
# @authArgs `
# -- `
# //server/util/fastcopy:fastcopy_benchmark_test
- name: Save caches
uses: ./.github/actions/cache-save
if: always()
with:
repo-cache-dir: ${{ steps.cache-restore.outputs.repo-cache-dir }}
go-mod-cache-dir: ${{ steps.cache-restore.outputs.go-mod-cache-dir }}
yarn-cache-dir: ${{ steps.cache-restore.outputs.yarn-cache-dir }}