Skip to content

Commit

Permalink
Remove Makefile which ruins builds from vendor (elastic#17013)
Browse files Browse the repository at this point in the history
## What does this PR do?

This PR adds the option to remove files from the vendor folder during `mage update`.

## Why is it important?

`yacc` is triggered from time to time when `mage vendor` copies files in a particular order. It leads to build failures unexpectedly.
  • Loading branch information
kvch authored Mar 17, 2020
1 parent 0a2b3f4 commit 9370128
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
13 changes: 12 additions & 1 deletion dev-tools/mage/gomod.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ var (
},
},
}
filesToRemove = []string{
filepath.Join("vendor", "github.com", "yuin", "gopher-lua", "parse", "Makefile"),
}
)

// Vendor cleans up go.mod and copies the files not carried over from modules cache.
Expand Down Expand Up @@ -75,7 +78,7 @@ func Vendor() error {

// copy packages which require the whole tree
for _, p := range copyAll {
path, err := gotool.ListModuleVendorDir(p.name)
path, err := gotool.ListModuleCacheDir(p.name)
if err != nil {
return err
}
Expand All @@ -90,5 +93,13 @@ func Vendor() error {
}
}
}

for _, p := range filesToRemove {
p = filepath.Join(repo.RootDir, p)
err = os.RemoveAll(p)
if err != nil {
return err
}
}
return nil
}
12 changes: 3 additions & 9 deletions libbeat/scripts/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -134,20 +134,14 @@ include $(ES_BEATS)/dev-tools/make/mage.mk

.DEFAULT_GOAL := ${BEAT_NAME}

${BEAT_NAME}: $(GOFILES_ALL) update-yacc-vendor ## @build build the beat application
${BEAT_NAME}: $(GOFILES_ALL) ## @build build the beat application
go build $(GOBUILD_FLAGS)

# Create test coverage binary
${BEAT_NAME}.test: $(GOFILES_ALL) update-yacc-vendor
${BEAT_NAME}.test: $(GOFILES_ALL)
@go build -o /dev/null
@go test $(RACE) -c -coverpkg ${GOPACKAGES_COMMA_SEP}

# Avoid running yacc to generate a parser for dependency.
.PHONY: update-yacc-vendor
update-yacc-vendor:
touch -c ../vendor/github.com/yuin/gopher-lua/parse/parser.go.y
touch -c ../vendor/github.com/yuin/gopher-lua/parse/parser.go

.PHONY: crosscompile
crosscompile: ## @build Cross-compile beat for the OS'es specified in GOX_OS variable. The binaries are placed in the build/bin directory.
crosscompile: $(GOFILES)
Expand Down Expand Up @@ -200,7 +194,7 @@ ci: ## @build Shortcut for continuous integration. This should always run befor

# Preparation for tests
.PHONY: prepare-tests
prepare-tests: update-yacc-vendor
prepare-tests:
mkdir -p ${COVERAGE_DIR}
# gotestcover is needed to fetch coverage for multiple packages
go ${INSTALL_CMD} ${COVERAGE_TOOL_REPO}
Expand Down
4 changes: 0 additions & 4 deletions vendor/github.com/yuin/gopher-lua/parse/Makefile

This file was deleted.

0 comments on commit 9370128

Please sign in to comment.