.PHONY: gomod
gomod:
	@go mod download
	@go mod tidy

.PHONY: test
test: gomod
	@go run golang.org/x/tools/cmd/goimports@latest -l .
	@go run gotest.tools/gotestsum@latest --junitfile=.gitlab/report.xml --format=testname --rerun-fails=2 --packages="./..." -- -coverprofile=.gitlab/coverage.profile -covermode count ./... || TEST_EXIT_CODE=$$?; \
		go run github.com/boumenot/gocover-cobertura@latest < .gitlab/coverage.profile > .gitlab/coverage.xml; \
		go tool cover -func .gitlab/coverage.profile | grep "total:"; \
		exit $${TEST_EXIT_CODE:-0}

.PHONY: benchmark
benchmark: gomod
	@go run .gitlab/scripts/benchmetric/benchmetric.go > .gitlab/metrics.txt