gocustomurls/Makefile

54 lines
1.2 KiB
Makefile
Raw Normal View History

2024-05-06 07:27:16 +00:00
# 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)/artifacts
BINARY = $(BIN_DIR)/gocustomurls
2024-06-23 13:43:33 +00:00
COVERAGE_DIR = $(CURDIR)/coverage
2024-05-06 07:27:16 +00:00
CURRENT_DIR = $(shell pwd)
CUR_TAG = $(shell git tag | sort -g | tail -1 | cut -c 2-)
VERSION_NUMBER ?= 0.0.0
ifneq ($(CI_COMMIT_TAG),)
VERSION_NUMBER := $(CI_COMMIT_TAG:v%=%)
else
VERSION_NUMBER := ${CUR_TAG}
endif
.PHONY: clean
clean:
go clean
.PHONY: dep
dep:
go mod tidy
.PHONY: fmt
fmt:
go fmt ./...
.PHONY: lint
lint:
golangci-lint run --timeout 3m --verbose
.PHONY: build
build:
2024-06-23 13:43:33 +00:00
go build -o $(BINARY)
.PHONY: build-debug
build-debug:
mkdir -p $(BIN_DIR)
go build -cover -o $(BINARY) .
.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: coverage-full
go tool cover -html=./coverage/coverage.out -o ./coverage/coverage.html
2024-06-23 16:33:34 +00:00
# open ./coverage/coverage.html