-
Notifications
You must be signed in to change notification settings - Fork 13
/
Makefile
51 lines (40 loc) · 2.06 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
WORKDIR := $(shell pwd)
NATIVEOS := $(shell go version | awk -F '[ /]' '{print $$4}')
NATIVEARCH := $(shell go version | awk -F '[ /]' '{print $$5}')
INTEGRATION := nagios
GO_FILES := ./src/
GOFLAGS = -mod=readonly
BINARY_NAME = nri-$(INTEGRATION)
all: build
build: clean test compile
build-container:
docker build -t nri-nagios .
clean:
@echo "=== $(INTEGRATION) === [ clean ]: Removing binaries and coverage file..."
@rm -rfv bin coverage.xml
compile:
@echo "=== $(INTEGRATION) === [ compile ]: Building $(BINARY_NAME)..."
@go build -o bin/$(BINARY_NAME) $(GO_FILES)
test:
@echo "=== $(INTEGRATION) === [ test ]: running unit tests..."
@go test -race ./... -count=1
integration-test:
@echo "=== $(INTEGRATION) === [ test ]: running integration tests..."
@chmod 0600 tests/testdata/*
@docker compose -f tests/docker-compose.yml pull
@go test -v -tags=integration ./tests/. || (ret=$$?; docker compose -f tests/docker-compose.yml down && exit $$ret)
@docker compose -f tests/docker-compose.yml down
install: compile
@echo "=== $(INTEGRATION) === [ install ]: installing bin/$(BINARY_NAME)..."
@sudo install -D --mode=755 --owner=root --strip $(ROOT)bin/$(BINARY_NAME) $(INTEGRATIONS_DIR)/bin/$(BINARY_NAME)
@sudo install -D --mode=644 --owner=root $(ROOT)$(INTEGRATION)-config.yml.sample $(CONFIG_DIR)/$(INTEGRATION)-config.yml.sample
# 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))
# Include thematic Makefiles
include $(CURDIR)/build/ci.mk
include $(CURDIR)/build/release.mk
.PHONY: all build clean tools tools-update deps install compile test integration-test rt-update-changelog