From e6be14fd71cba65dde140fedd8bd7e9324b08914 Mon Sep 17 00:00:00 2001 From: Jaime Soriano Pastor Date: Sat, 11 Jan 2020 18:46:19 +0100 Subject: [PATCH] Cherry-pick #15140 to 7.5: Fix mage package on generated beats (#15383) Mage package calls some targets by name (instead of by reference), and then these targets need to be defined in the main magefile. Add mage package to the test suite so we earlier detect these issues. (cherry picked from commit 315837bca963871d435d3cd039b681e495d08152) --- .travis.yml | 4 ++-- generator/beat/{beat}/magefile.go | 11 +++++++++++ generator/common/Makefile | 7 +++++++ generator/metricbeat/{beat}/magefile.go | 11 +++++++++++ 4 files changed, 31 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8bf2f8c2feb..13f55f579a3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -142,11 +142,11 @@ jobs: # Generators - os: linux - env: TARGETS="-C generator/metricbeat test" + env: TARGETS="-C generator/metricbeat test test-package" go: $TRAVIS_GO_VERSION stage: test - os: linux - env: TARGETS="-C generator/beat test" + env: TARGETS="-C generator/beat test test-package" go: $TRAVIS_GO_VERSION stage: test diff --git a/generator/beat/{beat}/magefile.go b/generator/beat/{beat}/magefile.go index d6321d26f3b..ede1bbf8ba4 100644 --- a/generator/beat/{beat}/magefile.go +++ b/generator/beat/{beat}/magefile.go @@ -77,3 +77,14 @@ func Build() error { func CrossBuild() error { return build.CrossBuild() } + +// BuildGoDaemon builds the go-daemon binary (use crossBuildGoDaemon). +func BuildGoDaemon() error { + return build.BuildGoDaemon() +} + +// GolangCrossBuild build the Beat binary inside of the golang-builder. +// Do not use directly, use crossBuild instead. +func GolangCrossBuild() error { + return build.GolangCrossBuild() +} diff --git a/generator/common/Makefile b/generator/common/Makefile index e880b412e32..5cd08aab8dc 100644 --- a/generator/common/Makefile +++ b/generator/common/Makefile @@ -24,6 +24,13 @@ test: prepare-test $(MAKE) || exit 1 ; \ $(MAKE) unit +.PHONY: test-package +test-package: test + cd ${BEAT_PATH} ; \ + export GOPATH=${PWD}/build ; \ + export PATH=$${GOPATH}/bin:$${PATH}; \ + mage package + .PHONY: prepare-test prepare-test:: python-env # Makes sure to use current version of beats for testing diff --git a/generator/metricbeat/{beat}/magefile.go b/generator/metricbeat/{beat}/magefile.go index a52bb547c1b..649cae97b76 100644 --- a/generator/metricbeat/{beat}/magefile.go +++ b/generator/metricbeat/{beat}/magefile.go @@ -112,3 +112,14 @@ func Build() error { func CrossBuild() error { return build.CrossBuild() } + +// BuildGoDaemon builds the go-daemon binary (use crossBuildGoDaemon). +func BuildGoDaemon() error { + return build.BuildGoDaemon() +} + +// GolangCrossBuild build the Beat binary inside of the golang-builder. +// Do not use directly, use crossBuild instead. +func GolangCrossBuild() error { + return build.GolangCrossBuild() +}