-
Notifications
You must be signed in to change notification settings - Fork 17
/
Makefile
57 lines (45 loc) · 1.93 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# Don't assume PATH settings
export PATH := $(PATH):$(GOPATH)/bin
INTEGRATION := newrelic-pcf-nozzle
BINARY_NAME = nr-fh-nozzle
GO_FILES := ./...
GO_INTEGRATION_FILE := ./tests/...
#Release version must be mayor.minor.patch for tile generator
RELEASE_TAG ?= 2.10.0
TEST_DEPS = github.com/axw/gocov/gocov github.com/AlekSi/gocov-xml
all: release
build: clean deps test-deps compile test integration-test
clean:
@echo "=== $(INTEGRATION) === [ clean ]: removing binaries and coverage file..."
@rm -rfv dist product release coverage.xml
deps:
@echo "=== $(INTEGRATION) === [ deps ]: downloading dependencies..."
@go mod tidy
test-deps:
@echo "=== $(INTEGRATION) === [ test-deps ]: installing testing dependencies..."
@go get -v $(TEST_DEPS)
test:
@echo "=== $(INTEGRATION) === [ test ]: running unit tests..."
@go clean -testcache
@gocov test $(GO_FILES) | gocov-xml > coverage.xml
integration-test: compile
@echo "=== $(INTEGRATION) === [ integration test ]: running integration tests..."
@go clean -testcache
@go test $(GO_INTEGRATION_FILE) -tags=integration -v
compile:
@echo "=== $(INTEGRATION) === [ compile ]: building $(BINARY_NAME)..."
@mkdir -p dist
@go build -ldflags "-X main.Version=$(RELEASE_TAG)" -o dist/$(BINARY_NAME)
compile-linux: clean deps
@echo "=== $(INTEGRATION) === [ compile ]: building $(BINARY_NAME)..."
@mkdir -p dist
@env GOARCH=amd64 GOOS=linux go build -ldflags "-X main.Version=$(RELEASE_TAG)" -o dist/$(BINARY_NAME)
release: build compile-linux
@echo "=== $(INTEGRATION) === [ release ]: generating release..."
@tile build $(RELEASE_TAG)
@tar -czvf dist/$(BINARY_NAME).tar.gz dist/$(BINARY_NAME)
push: compile-linux
@echo "=== $(INTEGRATION) === [ push ]: pushing to test environment..."
@cf login -a $(CF_API_URL) --skip-ssl-validation -u $(CF_USER) -p $(CF_PASSWORD) -o nr-firehose-nozzle-org
@cf push
.PHONY: all build clean compile test-deps test release integration-test push compile-linux