# Inspired from https://dustinspecker.com/posts/go-combined-unit-integration-code-coverage/ and https://netdevops.me/2023/test-coverage-for-go-integration-tests/ BIN_DIR = $(CURDIR)/bin COVERAGE_DIR = $(CURDIR)/coverage BINARY = $(BIN_DIR)/gosimplenpm .PHONY: clean clean: go clean .PHONY: dep dep: go mod tidy .PHONY: fmt fmt: go fmt ./... .PHONY: lint lint: golangci-lint run coverage-unit: go test ./... -short -covermode=count -coverprofile=./coverage/unit.out go tool cover -func=./coverage/unit.out coverage-integration: go test ./... -run Integration -covermode=count -coverprofile=./coverage/integration.out go tool cover -func=./coverage/integration.out .PHONY: build-debug build-debug: mkdir -p $(BIN_DIR) go build -o $(BINARY) -cover main.go .PHONY: test test: build-debug rm -rf $(COVERAGE_DIR) mkdir -p $(COVERAGE_DIR) go test -cover ./... -args -test.gocoverdir="$(COVERAGE_DIR)" .PHONY: coverage-full coverage-full: test go tool covdata textfmt -i=$(COVERAGE_DIR) -o $(COVERAGE_DIR)/coverage.out go tool cover -func=$(COVERAGE_DIR)/coverage.out .PHONY: coverage-html coverage-html: go tool cover -html=./coverage/coverage.out -o ./coverage/coverage.html open ./coverage/coverage.html .PHONY: lint-all lint-all: golangci-lint run --enable-all