################################################################################ # This file is AUTOGENERATED with # # Edit Makefile.maker.yaml instead. # ################################################################################ MAKEFLAGS=--warn-undefined-variables # /bin/sh is dash on Debian which does not support all features of ash/bash # to fix that we use /bin/bash only on Debian to not break Alpine ifneq (,$(wildcard /etc/os-release)) # check file existence ifneq ($(shell grep -c debian /etc/os-release),0) SHELL := /bin/bash endif endif default: FORCE @echo 'There is nothing to build, use `make check` for running the test suite or `make help` for a list of available targets.' generate: generated.go %: %.in | util/render_template.go @echo ./util/render_template.go < $< > $@ @./util/render_template.go < $< > $@.new && mv $@.new $@ || (rm $@.new; false) GO_BUILDFLAGS = GO_LDFLAGS = GO_TESTENV = # which packages to test with "go test" GO_TESTPKGS := $(shell go list -f '{{if or .TestGoFiles .XTestGoFiles}}{{.ImportPath}}{{end}}' ./...) # which packages to measure coverage for GO_COVERPKGS := $(shell go list ./... | grep -Ev '/util') # to get around weird Makefile syntax restrictions, we need variables containing nothing, a space and comma null := space := $(null) $(null) comma := , check: FORCE static-check build/cover.html @printf "\e[1;32m>> All checks successful.\e[0m\n" prepare-static-check: FORCE @if ! hash golangci-lint 2>/dev/null; then printf "\e[1;36m>> Installing golangci-lint (this may take a while)...\e[0m\n"; go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest; fi static-check: FORCE prepare-static-check @printf "\e[1;36m>> golangci-lint\e[0m\n" @golangci-lint run build/cover.out: FORCE | build @printf "\e[1;36m>> go test\e[0m\n" @env $(GO_TESTENV) go test $(GO_BUILDFLAGS) -ldflags '-s -w $(GO_LDFLAGS)' -shuffle=on -p 1 -coverprofile=$@ -covermode=count -coverpkg=$(subst $(space),$(comma),$(GO_COVERPKGS)) $(GO_TESTPKGS) build/cover.html: build/cover.out @printf "\e[1;36m>> go tool cover > build/cover.html\e[0m\n" @go tool cover -html $< -o $@ build: @mkdir $@ tidy-deps: FORCE go mod tidy go mod verify clean: FORCE git clean -dxf build vars: FORCE @printf "GO_BUILDFLAGS=$(GO_BUILDFLAGS)\n" @printf "GO_COVERPKGS=$(GO_COVERPKGS)\n" @printf "GO_LDFLAGS=$(GO_LDFLAGS)\n" @printf "GO_TESTENV=$(GO_TESTENV)\n" @printf "GO_TESTPKGS=$(GO_TESTPKGS)\n" help: FORCE @printf "\n" @printf "\e[1mUsage:\e[0m\n" @printf " make \e[36m\e[0m\n" @printf "\n" @printf "\e[1mGeneral\e[0m\n" @printf " \e[36mvars\e[0m Display values of relevant Makefile variables.\n" @printf " \e[36mhelp\e[0m Display this help.\n" @printf "\n" @printf "\e[1mTest\e[0m\n" @printf " \e[36mcheck\e[0m Run the test suite (unit tests and golangci-lint).\n" @printf " \e[36mprepare-static-check\e[0m Install golangci-lint. This is used in CI, you should probably install golangci-lint using your package manager.\n" @printf " \e[36mstatic-check\e[0m Run golangci-lint.\n" @printf " \e[36mbuild/cover.out\e[0m Run tests and generate coverage report.\n" @printf " \e[36mbuild/cover.html\e[0m Generate an HTML file with source code annotations from the coverage report.\n" @printf "\n" @printf "\e[1mDevelopment\e[0m\n" @printf " \e[36mtidy-deps\e[0m Run go mod tidy and go mod verify.\n" @printf " \e[36mclean\e[0m Run git clean.\n" .PHONY: FORCE