Skip to content

Commit

Permalink
Use .go-version to specify the Go version for all CI builds (#4303) (#…
Browse files Browse the repository at this point in the history
…4307)

Having a simple file that requires no parsing to retrieve the Go version
provides us a standard portable way to know what Go version to use for builds.
It's basically the least common denominator for builds accross CI systems
(Jenkins, AppVeyor, Travis) and operating systems.

Also changed AppVeyor to invalidate the cached Go version only when the
.go-version file changes instead of when the .appveyor.yml changes.
  • Loading branch information
andrewkroh authored and ruflin committed May 13, 2017
1 parent b28a790 commit b5c6071
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 22 deletions.
12 changes: 8 additions & 4 deletions .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ os: Windows Server 2012 R2

# Environment variables
environment:
GOROOT: c:\go1.7.4
GOPATH: c:\gopath
GVM_DL: https://github.com/andrewkroh/gvm/releases/download/v0.0.1/gvm-windows-amd64.exe
PYWIN_DL: https://beats-files.s3.amazonaws.com/deps/pywin32-220.win32-py2.7.exe
matrix:
- PROJ: github.com\elastic\beats\metricbeat
Expand All @@ -24,14 +24,18 @@ clone_folder: c:\gopath\src\github.com\elastic\beats
cache:
- C:\ProgramData\chocolatey\bin -> .appveyor.yml
- C:\ProgramData\chocolatey\lib -> .appveyor.yml
- C:\go1.7.4 -> .appveyor.yml
- C:\Users\appveyor\.gvm -> .go-version
- C:\Windows\System32\gvm.exe -> .appveyor.yml
- C:\tools\mingw64 -> .appveyor.yml
- C:\pywin_inst.exe -> .appveyor.yml

# Scripts that run after cloning repository
install:
- ps: c:\gopath\src\github.com\elastic\beats\libbeat\scripts\install-go.ps1 -version 1.7.4
- set PATH=%GOROOT%\bin;%PATH%
- ps: >-
if(!(Test-Path "C:\Windows\System32\gvm.exe")) {
wget "$env:GVM_DL" -Outfile C:\Windows\System32\gvm.exe
}
- ps: gvm --format=powershell $(Get-Content .go-version) | Invoke-Expression
# AppVeyor installed mingw is 32-bit only.
- ps: >-
if(!(Test-Path "C:\tools\mingw64\bin\gcc.exe")) {
Expand Down
1 change: 1 addition & 0 deletions .go-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.7.4
34 changes: 17 additions & 17 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,73 +12,73 @@ env:
global:
# Cross-compile for amd64 only to speed up testing.
- GOX_FLAGS="-arch amd64"
- DOCKER_COMPOSE_VERSION: 1.9.0
- &go_version 1.7.4
- DOCKER_COMPOSE_VERSION=1.9.0
- GO_VERSION="$(cat .go-version)"

matrix:
include:
# General checks
- os: linux
env: TARGETS="check"
go: *go_version
go: $GO_VERSION

# Filebeat
- os: linux
env: TARGETS="-C filebeat testsuite"
go: *go_version
go: $GO_VERSION
- os: osx
env: TARGETS="TEST_ENVIRONMENT=0 -C filebeat testsuite"
go: *go_version
go: $GO_VERSION

# Heartbeat
- os: linux
env: TARGETS="-C heartbeat testsuite"
go: *go_version
go: $GO_VERSION
- os: osx
env: TARGETS="TEST_ENVIRONMENT=0 -C heartbeat testsuite"
go: *go_version
go: $GO_VERSION

# Libbeat
- os: linux
env: TARGETS="-C libbeat testsuite"
go: *go_version
go: $GO_VERSION
- os: linux
env: TARGETS="-C libbeat crosscompile"
go: *go_version
go: $GO_VERSION

# Metricbeat
- os: linux
env: TARGETS="-C metricbeat testsuite"
go: *go_version
go: $GO_VERSION
- os: osx
env: TARGETS="TEST_ENVIRONMENT=0 -C metricbeat testsuite"
go: *go_version
go: $GO_VERSION
- os: linux
env: TARGETS="-C metricbeat crosscompile"
go: *go_version
go: $GO_VERSION

# Packetbeat
- os: linux
env: TARGETS="-C packetbeat testsuite"
go: *go_version
go: $GO_VERSION

# Winlogbeat
- os: linux
env: TARGETS="-C winlogbeat crosscompile"
go: *go_version
go: $GO_VERSION

# Dashboards
- os: linux
env: TARGETS="-C libbeat/dashboards"
go: *go_version
go: $GO_VERSION

# Generators
- os: linux
env: TARGETS="-C generator/metricbeat test"
go: *go_version
go: $GO_VERSION
- os: linux
env: TARGETS="-C generator/beat test"
go: *go_version
go: $GO_VERSION

addons:
apt:
Expand Down
2 changes: 1 addition & 1 deletion dev-tools/common.bash
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ err()
# Read the project's Go version and return it in the GO_VERSION variable.
# On failure it will exit.
get_go_version() {
GO_VERSION=$(awk '/^:go-version:/{print $NF}' "${_sdir}/../libbeat/docs/version.asciidoc")
GO_VERSION=$(cat "${_sdir}/../.go-version")
if [ -z "$GO_VERSION" ]; then
err "Failed to detect the project's Go version"
exit 1
Expand Down

0 comments on commit b5c6071

Please sign in to comment.