Skip to content

Commit

Permalink
Fix mage package on generated beats (elastic#15140)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jsoriano committed Jan 8, 2020
1 parent 7c562d9 commit 315837b
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 4 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,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

Expand Down
4 changes: 2 additions & 2 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -424,14 +424,14 @@ pipeline {
stage('Generators Metricbeat Linux'){
steps {
withBeatsEnv(){
makeTarget("Generators Metricbeat Linux", "-C generator/metricbeat test")
makeTarget("Generators Metricbeat Linux", "-C generator/metricbeat test test-package")
}
}
}
stage('Generators Beat Linux'){
steps {
withBeatsEnv(){
makeTarget("Generators Beat Linux", "-C generator/beat test")
makeTarget("Generators Beat Linux", "-C generator/beat test test-package")
}
}
}
Expand Down
11 changes: 11 additions & 0 deletions generator/beat/{beat}/magefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,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()
}
6 changes: 6 additions & 0 deletions generator/common/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ test: prepare-test
$(MAKE) || exit 1 ; \
$(MAKE) unit

.PHONY: test-package
test-package: test
cd ${BEAT_PATH} ; \
export PATH=$${GOPATH}/bin:$${PATH}; \
mage package

.PHONY: prepare-test
prepare-test:: ${GOPATH}/bin/mage
rm -fr ${BEAT_PATH}
Expand Down
11 changes: 11 additions & 0 deletions generator/metricbeat/{beat}/magefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,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()
}

0 comments on commit 315837b

Please sign in to comment.