Skip to content

Commit 17e931d

Browse files
authored
[Buildkite] Use Go version defined in .go-version (#1419)
Update Buildkite pipelines to use everywhere the same source of truth about which Go version to use (.go-version file)
1 parent c114a7b commit 17e931d

File tree

5 files changed

+52
-20
lines changed

5 files changed

+52
-20
lines changed

.buildkite/hooks/pre-command

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ function retry {
2222
return 0
2323
}
2424

25+
export GO_VERSION=$(cat .go-version)
26+
2527
GCP_SERVICE_ACCOUNT_SECRET_PATH=secret/ci/elastic-elastic-package/gcp-service-account
2628
AWS_SERVICE_ACCOUNT_SECRET_PATH=kv/ci-shared/platform-ingest/aws_account_auth
2729
GITHUB_TOKEN_VAULT_PATH=kv/ci-shared/platform-ingest/github_token

.buildkite/pipeline.package-storage-publish.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
env:
22
SETUP_GVM_VERSION: 'v0.5.0' # https://github.com/andrewkroh/gvm/issues/44#issuecomment-1013231151
3+
LINUX_AGENT_IMAGE: "golang:${GO_VERSION}"
34

45
steps:
56
- label: ":go: Build package"
@@ -8,7 +9,7 @@ steps:
89
- "make install"
910
- "cd test/packages/package-storage/package_storage_candidate; elastic-package build -v --zip"
1011
agents:
11-
image: "golang:1.20.3"
12+
image: "${LINUX_AGENT_IMAGE}"
1213
cpu: "8"
1314
memory: "4G"
1415
artifact_paths:

.buildkite/pipeline.test-with-integrations-repo.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
env:
22
SETUP_GVM_VERSION: 'v0.5.0' # https://github.com/andrewkroh/gvm/issues/44#issuecomment-1013231151
3-
GOLANG_VERSION: "1.20.3"
3+
LINUX_AGENT_IMAGE: "golang:${GO_VERSION}"
44
GH_CLI_VERSION: "2.29.0"
55
JQ_VERSION: "1.6"
66

@@ -9,7 +9,7 @@ steps:
99
key: check-static
1010
command: "make check-static"
1111
agents:
12-
image: "golang:${GOLANG_VERSION}"
12+
image: "${LINUX_AGENT_IMAGE}"
1313
cpu: "8"
1414
memory: "4G"
1515
- label: ":go: :linux: Run unit tests"
@@ -19,7 +19,7 @@ steps:
1919
- "build/test-results/*.xml"
2020
- "build/test-coverage/*.xml"
2121
agents:
22-
image: "golang:${GOLANG_VERSION}"
22+
image: "${LINUX_AGENT_IMAGE}"
2323
cpu: "8"
2424
memory: "4G"
2525
- label: ":hammer: Create PR in integrations"

.buildkite/pipeline.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@ env:
55
ELASTIC_PACKAGE_COMPOSE_DISABLE_PULL_PROGRESS_INFORMATION: "true"
66
KIND_VERSION: 'v0.20.0'
77
K8S_VERSION: 'v1.27.3'
8+
LINUX_AGENT_IMAGE: "golang:${GO_VERSION}"
9+
WINDOWS_AGENT_IMAGE: "family/ci-windows-2022"
810

911
steps:
1012
- label: ":go: Run check-static"
1113
key: check-static
1214
command: "make check-static"
1315
agents:
14-
image: "golang:1.20.3"
16+
image: "${LINUX_AGENT_IMAGE}"
1517
cpu: "8"
1618
memory: "4G"
1719

@@ -22,7 +24,7 @@ steps:
2224
- "build/test-results/*.xml"
2325
- "build/test-coverage/*.xml"
2426
agents:
25-
image: "golang:1.20.3"
27+
image: "${LINUX_AGENT_IMAGE}"
2628
cpu: "8"
2729
memory: "4G"
2830

@@ -31,7 +33,9 @@ steps:
3133
command: ".buildkite/scripts/unit_tests_windows.ps1"
3234
agents:
3335
provider: "gcp"
34-
image: "family/ci-windows-2022"
36+
image: "${WINDOWS_AGENT_IMAGE}"
37+
artifact_paths:
38+
- "TEST-unit.xml"
3539

3640
- wait: ~
3741
continue_on_failure: true
@@ -52,7 +56,7 @@ steps:
5256
- label: ":junit: Junit annotate"
5357
plugins:
5458
- junit-annotate#v2.4.1:
55-
artifacts: "build/test-results/*.xml"
59+
artifacts: "*.xml"
5660
agents:
5761
provider: "gcp" # junit plugin requires docker
5862

Lines changed: 37 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,49 @@
1-
echo "--- Fixing CRLF in git checkout"
1+
$ErrorActionPreference = "Stop" # set -e
2+
23
# Forcing to checkout again all the files with a correct autocrlf.
34
# Doing this here because we cannot set git clone options before.
4-
git config core.autocrlf input
5-
git rm --quiet --cached -r .
6-
git reset --quiet --hard
5+
function fixCRLF {
6+
Write-Host "-- Fixing CRLF in git checkout --"
7+
git config core.autocrlf input
8+
git rm --quiet --cached -r .
9+
git reset --quiet --hard
10+
}
11+
12+
function withGolang($version) {
13+
Write-Host "-- Install golang $version --"
14+
choco install -y golang --version $version
15+
$env:ChocolateyInstall = Convert-Path "$((Get-Command choco).Path)\..\.."
16+
Import-Module "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1"
17+
refreshenv
18+
go version
19+
go env
20+
}
721

8-
echo "--- Installing golang"
9-
choco install -y golang --version 1.20.3
22+
function installGoDependencies {
23+
$installPackages = @(
24+
"github.com/elastic/go-licenser"
25+
"golang.org/x/tools/cmd/goimports"
26+
"github.com/jstemmer/go-junit-report/v2"
27+
"gotest.tools/gotestsum"
28+
)
29+
foreach ($pkg in $installPackages) {
30+
go install "$pkg@latest"
31+
}
32+
}
1033

11-
echo "--- Updating session environment"
12-
# refreshenv requires to have chocolatey profile installed
13-
$env:ChocolateyInstall = Convert-Path "$((Get-Command choco).Path)\..\.."
14-
Import-Module "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1"
34+
fixCRLF
35+
withGolang $env:GO_VERSION
1536

16-
refreshenv
1737

1838
echo "--- Downloading Go modules"
1939
go version
2040
go mod download -x
2141

2242
echo "--- Running unit tests"
2343
go version
24-
go test ./...
44+
$ErrorActionPreference = "Continue" # set +e
45+
go run gotest.tools/gotestsum --junitfile "$(PWD)/TEST-unit.xml" -- -count=1 ./...
46+
$EXITCODE=$LASTEXITCODE
47+
$ErrorActionPreference = "Stop"
48+
49+
Exit $EXITCODE

0 commit comments

Comments
 (0)