.PHONY: help
help: ## Display available commands.
	@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)

# Style and cleanup commands.

.PHONY: style
style: ## Run all code formatters, linters and analysers. Must always be run before GIT commit or push commands!
	# Format go source code.
	go get golang.org/x/tools/cmd/goimports
	goimports -w .
	# Analyse source code by running set of tools to report errors, bugs and smells.
	go get github.com/golangci/golangci-lint/cmd/golangci-lint
	golangci-lint run --config configs/.golangci.yml
	# Prune unused packages and dependencies from go.mod file.
	go mod tidy -v
	# Remove object files left behind by other operations.
	go clean ./...

# Test commands.

.PHONY: test
test: ## Run test suite.
	gotest -v -race -bench -benchmem -timeout=120s -count=1 -cover -coverprofile=test/coverage.out ./...

.PHONY: test-fast
test-fast: ## Run fast test suite.
	gotest -race -short -failfast -count=1 ./...

.PHONY: test-html
test-html: ## Run test suite and create coverage report in HTML format.
	make test
	go tool cover -html=test/coverage.out -o test/coverage.html
