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
i f n e q ( $( CI_COMMIT_TAG ) , )
VERSION_NUMBER := $( CI_COMMIT_TAG:v%= %)
e l s e
VERSION_NUMBER := ${ CUR_TAG }
e n d i f
.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 -integration
coverage-integration :
go test ./... -run Integration -covermode= count -coverprofile= $( COVERAGE_DIR) /integration.out
go tool cover -func= $( COVERAGE_DIR) /integration.out
.PHONY : coverage -html
coverage-html : coverage -full
go tool cover -html= ./coverage/coverage.out -o ./coverage/coverage.html
# open ./coverage/coverage.html