Enable make clean

Enable the clean target in the Makefile to clean the artifacts generated
during the build and coverage tests.  Add the bin dir to .gitignore.

Before this change the makefile had a clean target that performed
'git clean -dx' in a source directory, which is a dangerous operation in
a development environment since it will discard any uncommitted source
code changes that a developer has made; it also did not clean up the
actual build/test artifacts since they were not generated into the
directoried being cleaned.

Change-Id: I23fd5f44c8ce1cf6f539c0e05ae91c667a34e044
This commit is contained in:
Gary Smith
2019-12-16 17:47:32 +00:00
parent 6ac3c23958
commit c3c4e3b205
2 changed files with 8 additions and 3 deletions

3
.gitignore vendored
View File

@@ -1,3 +1,6 @@
# Coverage File
coverage.out
tools/bin
# Generated binaries
bin

View File

@@ -20,6 +20,8 @@ DOCKER_IMAGE_TAG ?= dev
DOCKER_IMAGE ?= $(DOCKER_REGISTRY)/$(DOCKER_IMAGE_PREFIX)/$(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_TAG)
DOCKER_TARGET_STAGE ?= release
COVERAGE_OUTPUT := coverage.out
TESTFLAGS ?=
# Override the value of the version variable in main.go
@@ -56,13 +58,13 @@ test:
go test $(RECURSIVE_DIRS) -v $(TESTFLAGS)
.PHONY: cover
cover: TESTFLAGS += -coverprofile=coverage.out
cover: TESTFLAGS += -coverprofile=$(COVERAGE_OUTPUT)
cover: test
go tool cover -html=coverage.out
go tool cover -html=$(COVERAGE_OUTPUT)
.PHONY: clean
clean:
git clean -dx $(DIRS)
rm -rf $(BUILD_DIR) $(COVERAGE_OUTPUT)
# The golang-unit zuul job calls the env target, so create one
.PHONY: env