diff --git a/.travis.yml b/.travis.yml index a06aca007924..5beb1351d0b5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -166,6 +166,11 @@ jobs: env: TARGETS="TEST_ENVIRONMENT=0 -C x-pack/functionbeat testsuite" go: $TRAVIS_GO_VERSION stage: test + - os: linux + before_install: .ci/scripts/travis_has_changes.sh x-pack/functionbeat libbeat || travis_terminate 0 + env: TARGETS="-C x-pack/functionbeat test-gcp-functions" + go: 1.13.1 + stage: test # Docker Log Driver - os: linux diff --git a/Jenkinsfile b/Jenkinsfile index 3533e905ee23..a867093e503b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -432,6 +432,9 @@ pipeline { stage('Functionbeat x-pack'){ steps { mageTarget("Functionbeat x-pack Linux", "x-pack/functionbeat", "update build test") + withEnv(["GO_VERSION=1.13.1"]){ + makeTarget("Functionbeat x-pack Linux", "-C x-pack/functionbeat test-gcp-functions") + } } } stage('Functionbeat Mac OS X x-pack'){ diff --git a/x-pack/functionbeat/Makefile b/x-pack/functionbeat/Makefile index fc92d913b7e5..fe15d9fe5c49 100644 --- a/x-pack/functionbeat/Makefile +++ b/x-pack/functionbeat/Makefile @@ -9,3 +9,6 @@ ES_BEATS?=../../ # include $(ES_BEATS)/dev-tools/make/xpack.mk +.PHONY: test-gcp-functions +test-gcp-functions: mage + mage testGCPFunctions diff --git a/x-pack/functionbeat/magefile.go b/x-pack/functionbeat/magefile.go index 107173de0ff3..d4554e4da1a2 100644 --- a/x-pack/functionbeat/magefile.go +++ b/x-pack/functionbeat/magefile.go @@ -185,6 +185,29 @@ func BuildPkgForFunctions() error { return nil } +// TestGCPFunctions are used by the CI to test if the GCP functions can be built with +// the selected Go version. +// The version is 1.13.1 (Ref: https://cloud.google.com/functions/docs/concepts/go-runtime) +func TestGCPFunctions() error { + for _, f := range []string{"pubsub", "storage"} { + params := devtools.DefaultBuildArgs() + inputFiles := filepath.Join("provider", "gcp", f, f+".go") + params.InputFiles = []string{inputFiles} + params.Name = f + params.CGO = false + params.Env = map[string]string{ + "GOOS": "linux", + "GOARCH": "amd64", + } + + err := devtools.Build(params) + if err != nil { + return fmt.Errorf("error while building %s for GCP: %+v", f, err) + } + } + return nil +} + // BuildSystemTestBinary build a binary for testing that is instrumented for // testing and measuring code coverage. The binary is only instrumented for // coverage when TEST_COVERAGE=true (default is false). diff --git a/x-pack/functionbeat/manager/gcp/template_builder.go b/x-pack/functionbeat/manager/gcp/template_builder.go index 76a34d6e2347..c6f1292ce154 100644 --- a/x-pack/functionbeat/manager/gcp/template_builder.go +++ b/x-pack/functionbeat/manager/gcp/template_builder.go @@ -21,7 +21,7 @@ import ( ) const ( - runtime = "go111" // Golang 1.11 + runtime = "go113" // Golang 1.13 archiveURL = "gs://%s/%s" // path to the function archive locationTemplate = "projects/%s/locations/%s" // full name of the location functionName = locationTemplate + "/functions/%s" // full name of the functions