-
Notifications
You must be signed in to change notification settings - Fork 18
/
Makefile
71 lines (55 loc) · 1.99 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
BIN_DIR = ./bin
TEST_COVERAGE_DIR := $(BIN_DIR)/test-coverage
BINARY_NAME ?= $(BIN_DIR)/k8s-metadata-injection
DOCKER_IMAGE_NAME ?= newrelic/k8s-metadata-injection
# This default tag is used during e2e test execution in the ci
DOCKER_IMAGE_TAG ?= local-dev
GOLANGCILINT_VERSION = 1.43.0
# required for enabling Go modules inside $GOPATH
export GO111MODULE=on
# GOOS and GOARCH will likely come from env
GOOS ?=
GOARCH ?=
CGO_ENABLED ?= 0
ifneq ($(strip $(GOOS)), )
BINARY_NAME := $(BINARY_NAME)-$(GOOS)
endif
ifneq ($(strip $(GOARCH)), )
BINARY_NAME := $(BINARY_NAME)-$(GOARCH)
endif
.PHONY: all
all: build
.PHONY: build
build: test compile
compile:
@echo "=== $(INTEGRATION) === [ compile ]: Building $(INTEGRATION)..."
go mod download
CGO_ENABLED=$(CGO_ENABLED) go build -o $(BINARY_NAME) ./cmd/server
.PHONY: compile-multiarch
compile-multiarch:
$(MAKE) compile GOOS=linux GOARCH=amd64
$(MAKE) compile GOOS=linux GOARCH=arm64
$(MAKE) compile GOOS=linux GOARCH=arm
.PHONY: build-container
build-container:
docker build -t $(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_TAG) $$DOCKERARGS .
.PHONY: test
test:
@echo "[test] Running unit tests"
@mkdir -p $(TEST_COVERAGE_DIR)
@go test ./... -count=1 -coverprofile=$(TEST_COVERAGE_DIR)/coverage.out -covermode=count
.PHONY: e2e-test
e2e-test:
@echo "[test] Running e2e tests"
./e2e-tests/tests.sh
.PHONY: benchmark-test
benchmark-test:
@echo "[test] Running benchmark tests"
@go test -run=^Benchmark* -bench .
# rt-update-changelog runs the release-toolkit run.sh script by piping it into bash to update the CHANGELOG.md.
# It also passes down to the script all the flags added to the make target. To check all the accepted flags,
# see: https://github.com/newrelic/release-toolkit/blob/main/contrib/ohi-release-notes/run.sh
# e.g. `make rt-update-changelog -- -v`
rt-update-changelog:
curl "https://raw.githubusercontent.com/newrelic/release-toolkit/v1/contrib/ohi-release-notes/run.sh" | bash -s -- $(filter-out $@,$(MAKECMDGOALS))
.PHONY: compile rt-update-changelog