Skip to content

Commit a64cbd3

Browse files
authored
Use Microsoft build of Go in CI (#2069)
1 parent a44d96f commit a64cbd3

File tree

2 files changed

+940
-9
lines changed

2 files changed

+940
-9
lines changed

.github/actions/setup-go/action.yml

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ description: Setup Go
33

44
inputs:
55
go-version:
6-
description: Go version range to set up.
7-
default: '>=1.25.0'
6+
description: Go version to set up in go-install.ps1 format
7+
default: 'go1.25'
88
create:
99
description: Create the cache
1010
default: 'false'
@@ -18,19 +18,42 @@ runs:
1818
steps:
1919
- name: Install Go
2020
id: install-go
21-
uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0
22-
with:
23-
go-version: ${{ inputs.go-version }}
24-
cache: false
21+
shell: pwsh
22+
run: |
23+
# https://github.com/microsoft/go-infra/blob/main/goinstallscript/powershell/go-install.ps1
24+
${{ github.action_path }}/go-install.ps1 -Version ${{ inputs.go-version }} -GitHubActionsPath
25+
26+
$goVersionOutput = go version
27+
Write-Host $goVersionOutput
28+
# Extract version like "1.23.4" from "go version go1.23.4 windows/amd64"
29+
if ($goVersionOutput -match 'go version go([\d\.]+)') {
30+
$exactVersion = $matches[1]
31+
"go-version=$exactVersion" >> $env:GITHUB_OUTPUT
32+
Write-Host "Exact Go version: $exactVersion"
33+
} else {
34+
Write-Error "Failed to parse Go version from: $goVersionOutput"
35+
exit 1
36+
}
37+
38+
- name: Verify Microsoft Go
39+
shell: pwsh
40+
run: |
41+
$goPath = (Get-Command go).Source
42+
Write-Host "Go executable path: $goPath"
43+
if ($goPath -notlike "*microsoft-go*") {
44+
Write-Error "Go installation is not from microsoft-go. Path: $goPath"
45+
exit 1
46+
}
47+
Write-Host "✓ Verified: Microsoft Go is active"
2548
2649
# Avoid hardcoding the cache keys more than once.
2750
- name: Get cache info
2851
shell: bash
2952
id: cache-info
3053
env:
31-
MODULES_KEY: go-modules-${{ runner.os }}-${{ steps.install-go.outputs.go-version }}-${{ hashFiles('**/go.sum', '**/.custom-gcl.yml') }}
32-
LINT_KEY: golangci-lint-${{ runner.os }}-${{ steps.install-go.outputs.go-version }}-${{ hashFiles('**/go.sum', '**/.custom-gcl.yml') }}
33-
BUILD_KEY: go-build-cache-${{ runner.os }}-${{ steps.install-go.outputs.go-version }}
54+
MODULES_KEY: go-modules-${{ runner.os }}-msft-${{ steps.install-go.outputs.go-version }}-${{ hashFiles('**/go.sum', '**/.custom-gcl.yml') }}
55+
LINT_KEY: golangci-lint-${{ runner.os }}-msft-${{ steps.install-go.outputs.go-version }}-${{ hashFiles('**/go.sum', '**/.custom-gcl.yml') }}
56+
BUILD_KEY: go-build-cache-${{ runner.os }}-msft-${{ steps.install-go.outputs.go-version }}
3457
run: |
3558
echo "modules-key=$MODULES_KEY" >> $GITHUB_OUTPUT
3659
echo "lint-key=$LINT_KEY" >> $GITHUB_OUTPUT

0 commit comments

Comments
 (0)