|
| 1 | +# PowerShell script for Windows Presubmit |
| 2 | +$ErrorActionPreference = 'Stop' |
| 3 | + |
| 4 | +Write-Host '--- Environment Info ---' |
| 5 | +Write-Host "Host Name: $env:COMPUTERNAME" |
| 6 | +Write-Host "User Name: $env:USERNAME" |
| 7 | +Write-Host "Current Directory: $(Get-Location)" |
| 8 | + |
| 9 | +# Change directory to the repository root |
| 10 | +Set-Location "$PSScriptRoot\..\.." |
| 11 | +Write-Host "New Directory: $(Get-Location)" |
| 12 | + |
| 13 | +$PYTHON_EXE = 'python' |
| 14 | +if (Get-Command 'python3.11' -ErrorAction SilentlyContinue) { |
| 15 | + $PYTHON_EXE = 'python3.11' |
| 16 | +} |
| 17 | +else { |
| 18 | + if (Test-Path 'C:\Python311\python.exe') { |
| 19 | + $PYTHON_EXE = 'C:\Python311\python.exe' |
| 20 | + } |
| 21 | +} |
| 22 | + |
| 23 | +Write-Host '--- Python Version ---' |
| 24 | +& $PYTHON_EXE --version |
| 25 | + |
| 26 | +# Ensure Bazel is available |
| 27 | +Write-Host '--- Bazel Version ---' |
| 28 | +& bazel version |
| 29 | + |
| 30 | +# Build all targets |
| 31 | +Write-Host '--- Bazel Build ---' |
| 32 | +& bazel build --config=windows //... |
| 33 | + |
| 34 | +if ($LASTEXITCODE -ne 0) { |
| 35 | + Write-Host 'Build failed!' |
| 36 | + exit 1 |
| 37 | +} |
| 38 | + |
| 39 | +# Run all tests |
| 40 | +Write-Host '--- Bazel Test ---' |
| 41 | +& bazel test --config=windows --test_output=errors //... |
| 42 | + |
| 43 | +if ($LASTEXITCODE -ne 0) { |
| 44 | + Write-Host 'Tests failed!' |
| 45 | + exit 1 |
| 46 | +} |
| 47 | + |
| 48 | +Write-Host '--- Success ---' |
| 49 | +Write-Host 'Build and tests passed successfully.' |
0 commit comments