-
Notifications
You must be signed in to change notification settings - Fork 16
/
Makefile
48 lines (39 loc) · 1.74 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
WORKDIR := $(shell pwd)
TARGET := target
TARGET_DIR = $(WORKDIR)/$(TARGET)
NATIVEOS := $(shell go version | awk -F '[ /]' '{print $$4}')
NATIVEARCH := $(shell go version | awk -F '[ /]' '{print $$5}')
INTEGRATION := jmx
BINARY_NAME = nri-$(INTEGRATION)
GO_PKGS := $(shell go list ./... | grep -v "/vendor/")
GO_FILES := ./src/
GOFLAGS = -mod=readonly
GOLANGCI_LINT = github.com/golangci/golangci-lint/cmd/golangci-lint
all: build
build: clean validate test compile
clean:
@echo "=== $(INTEGRATION) === [ clean ]: Removing binaries and coverage file..."
@rm -rfv bin coverage.xml $(TARGET)
validate:
@printf "=== $(INTEGRATION) === [ validate ]: running golangci-lint & semgrep... "
@go run $(GOFLAGS) $(GOLANGCI_LINT) run --verbose
@[ -f .semgrep.yml ] && semgrep_config=".semgrep.yml" || semgrep_config="p/golang" ; \
docker run --rm -v "${PWD}:/src:ro" --workdir /src returntocorp/semgrep -c "$$semgrep_config"
compile:
@echo "=== $(INTEGRATION) === [ compile ]: Building $(BINARY_NAME)..."
@go build -o bin/$(BINARY_NAME) ./src
test:
@echo "=== $(INTEGRATION) === [ test ]: Running unit tests..."
@go test -race ./... -count=1
integration-test:
@echo "=== $(INTEGRATION) === [ test ]: running integration tests..."
@if [ "$(NRJMX_VERSION)" = "" ]; then \
echo "Error: missing required env-var: NRJMX_VERSION\n" ;\
exit 1 ;\
fi
@docker compose -f test/integration/docker-compose.yml up -d --build
@go test -v -tags=integration ./test/integration/. -count=1 ; (ret=$$?; docker compose -f test/integration/docker-compose.yml down && exit $$ret)
# Include thematic Makefiles
include $(CURDIR)/build/ci.mk
include $(CURDIR)/build/release.mk
.PHONY: all build clean validate compile test integration-test check-version