Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 28 additions & 11 deletions .buildkite/scripts/run-tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,36 @@ function fixCRLF {
git reset --quiet --hard
}

function ensureBinPath {
$workDir = if ($env:WORKSPACE) { $env:WORKSPACE } else { $PWD.Path }
$binDir = Join-Path $workDir "bin"
if (-not (Test-Path $binDir)) { New-Item -ItemType Directory -Path $binDir | Out-Null }
$env:PATH = "$binDir;$env:PATH"
return $binDir
}

function withGolang($version) {
Write-Host "--- Install golang"
$latest_1_25_versions = @('1.25.8')
# not all latest Golang versions of 1.25.x are available since 1.26.0 is released
if ($version -in $latest_1_25_versions) {
Write-Host "$version not available in cholocatey, using 1.25.7"
# latest Golang version available for 1.25.x
$version = '1.25.7'
Write-Host "--- Install golang (GVM)"
$binDir = ensureBinPath
$gvmExe = Join-Path $binDir "gvm-windows-amd64.exe"
$gvmUrl = "https://github.com/andrewkroh/gvm/releases/download/$env:SETUP_GVM_VERSION/gvm-windows-amd64.exe"

Write-Host "Installing GVM tool"
$maxTries = 5
for ($i = 1; $i -le $maxTries; $i++) {
try {
Invoke-WebRequest -Uri $gvmUrl -OutFile $gvmExe -UseBasicParsing
break
} catch {
if ($i -eq $maxTries) { throw }
Start-Sleep -Seconds 3
}
}
choco install -y golang --version $version
$env:ChocolateyInstall = Convert-Path "$((Get-Command choco).Path)\..\.."
Import-Module "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1"
refreshenv

Write-Host "Installing Go version $version"
# GVM with --format=powershell prints env-setting code; Invoke-Expression runs it in this session so Go is on PATH
& $gvmExe --format=powershell $version | Invoke-Expression
$env:PATH = "$(go env GOPATH)\bin;$env:PATH"
go version
go env
}
Expand Down