-
Notifications
You must be signed in to change notification settings - Fork 10
/
Makefile
71 lines (53 loc) · 2.16 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
# Copyright 2019 New Relic Corporation. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
NATIVEOS := $(shell go version | awk -F '[ /]' '{print $$4}')
NATIVEARCH := $(shell go version | awk -F '[ /]' '{print $$5}')
TOOLS_DIR := ./bin/dev-tools
INTEGRATION = nri-kube-events
GOFLAGS = -mod=readonly
DOCKER_IMAGE_NAME ?= newrelic/nri-kube-events
BUILD_TARGET ?= bin/$(INTEGRATION)
# GOOS and GOARCH will likely come from env
GOOS ?=
GOARCH ?=
CGO_ENABLED ?= 0
BUILD_DATE := $(shell date)
TAG ?= dev
COMMIT ?= $(shell git rev-parse HEAD || echo "unknown")
LDFLAGS ?= -ldflags="-X 'main.integrationVersion=$(TAG)' -X 'main.gitCommit=$(COMMIT)' -X 'main.buildDate=$(BUILD_DATE)' "
ifneq ($(strip $(GOOS)), )
BUILD_TARGET := $(BUILD_TARGET)-$(GOOS)
endif
ifneq ($(strip $(GOARCH)), )
BUILD_TARGET := $(BUILD_TARGET)-$(GOARCH)
endif
all: build
build: clean test compile
clean:
@echo "=== $(INTEGRATION) === [ clean ]: Removing binaries and coverage file..."
@rm -rfv bin
fmt:
@echo "=== $(INTEGRATION) === [ fmt ]: Running Gofmt...."
@go fmt ./...
compile:
@echo "=== $(INTEGRATION) === [ compile ]: Building $(INTEGRATION)..."
CGO_ENABLED=$(CGO_ENABLED) go build $(LDFLAGS) -o $(BUILD_TARGET) ./cmd/nri-kube-events
compile-multiarch:
$(MAKE) compile GOOS=linux GOARCH=amd64
$(MAKE) compile GOOS=linux GOARCH=arm
$(MAKE) compile GOOS=linux GOARCH=arm64
test: test-unit
test-unit:
@echo "=== $(INTEGRATION) === [ test ]: Running unit tests..."
@go test -v -race ./...
test-integration:
@echo "=== $(INTEGRATION) === [ test ]: Running integration tests..."
@go test -v -tags integration ./test/integration
docker:
$(MAKE) compile GOOS=linux GOARCH=amd64
DOCKER_BUILDKIT=1 docker build . -t $(DOCKER_IMAGE_NAME)
docker-multiarch: compile-multiarch
@docker buildx build . -t $(DOCKER_IMAGE_NAME)
buildThirdPartyNotice:
@go list -m -json all | go-licence-detector -rules ./assets/licence/rules.json -noticeTemplate ./assets/licence/THIRD_PARTY_NOTICES.md.tmpl -noticeOut THIRD_PARTY_NOTICES.md -includeIndirect -overrides ./assets/licence/overrides
.PHONY: all build clean fmt compile compile-multiarch test test-unit docker docker-multiarch buildThirdPartyNotice