From 795ceab02eaa44a54391c74f34e2c94b63fbb669 Mon Sep 17 00:00:00 2001 From: Andrew Kroh Date: Sat, 13 May 2017 10:40:28 -0400 Subject: [PATCH] Use .go-version to specify the Go version for all CI builds (#4303) 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. --- .appveyor.yml | 5 ++--- .go-version | 1 + .travis.yml | 34 +++++++++++++++++----------------- dev-tools/common.bash | 2 +- 4 files changed, 21 insertions(+), 21 deletions(-) create mode 100644 .go-version diff --git a/.appveyor.yml b/.appveyor.yml index 8fd0575e1c05..a322e8648b33 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -7,7 +7,6 @@ os: Windows Server 2012 R2 # Environment variables environment: GOPATH: c:\gopath - GVM_GO_VERSION: 1.8.1 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: @@ -25,7 +24,7 @@ clone_folder: c:\gopath\src\github.com\elastic\beats cache: - C:\ProgramData\chocolatey\bin -> .appveyor.yml - C:\ProgramData\chocolatey\lib -> .appveyor.yml -- C:\Users\appveyor\.gvm -> .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 @@ -36,7 +35,7 @@ install: if(!(Test-Path "C:\Windows\System32\gvm.exe")) { wget "$env:GVM_DL" -Outfile C:\Windows\System32\gvm.exe } - - ps: gvm --format=powershell "$env:GVM_GO_VERSION" | Invoke-Expression + - ps: gvm --format=powershell $(Get-Content .go-version) | Invoke-Expression # AppVeyor installed mingw is 32-bit only so install 64-bit version. - ps: >- if(!(Test-Path "C:\tools\mingw64\bin\gcc.exe")) { diff --git a/.go-version b/.go-version new file mode 100644 index 000000000000..a8fdfda1c782 --- /dev/null +++ b/.go-version @@ -0,0 +1 @@ +1.8.1 diff --git a/.travis.yml b/.travis.yml index 8c374475f4c2..3882dfedebf9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,73 +12,73 @@ env: global: # Cross-compile for amd64 only to speed up testing. - GOX_FLAGS="-arch amd64" - - DOCKER_COMPOSE_VERSION: 1.11.1 - - &go_version 1.8.1 + - DOCKER_COMPOSE_VERSION=1.11.1 + - 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 dev-tools/cmd/import_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: diff --git a/dev-tools/common.bash b/dev-tools/common.bash index 64bf8cf4eedd..aff8ba6b6626 100644 --- a/dev-tools/common.bash +++ b/dev-tools/common.bash @@ -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