From ccec94a4dd6a5feb9664f004072f78d7c36eca7e Mon Sep 17 00:00:00 2001 From: Julien Dessaux Date: Mon, 26 Aug 2024 16:45:28 +0200 Subject: chore(gonf): added makefile --- GNUmakefile | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 GNUmakefile (limited to 'GNUmakefile') diff --git a/GNUmakefile b/GNUmakefile new file mode 100644 index 0000000..b89e297 --- /dev/null +++ b/GNUmakefile @@ -0,0 +1,51 @@ +SHELL := bash +.SHELLFLAGS := -eu -o pipefail -c +.ONESHELL: +.DELETE_ON_ERROR: +MAKEFLAGS += --warn-undefined-variables +MAKEFLAGS += --no-builtin-rules +.DEFAULT_GOAL := help + +##### Utils #################################################################### +.PHONY: confirm +confirm: + @echo -n 'Are you sure? [y/N] ' && read ans && [ $${ans:-N} = y ] + +.PHONY: help +help: + @grep -E '^[a-zA-Z\/_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}' | sort + +.PHONY: no-dirty +no-dirty: + git diff --exit-code + +##### Quality ################################################################## +.PHONY: check +check: ## run all code checks + go mod verify + go vet ./... + go test -race -buildvcs -vet=off ./... + +.PHONY: tidy +tidy: ## tidy up the code + go fmt ./... + go mod tidy -v + +##### Development ############################################################## +.PHONY: build +build: ## build gonf + CGO_ENABLED=0 go build -ldflags "-s -w -extldflags \"-static\"" ./cmd/gonf/ + +.PHONY: test +test: ## run all tests + go test -v -race -buildvcs ./... + +.PHONY: test/cover +test/cover: ## Run all tests and generate coverage profile + go test -v -race -buildvcs -coverprofile=./coverage.out ./... + go tool cover -html=./coverage.out + +##### Operations ############################################################### +.PHONY: push +push: tidy no-dirty check ## push changes to git remote + git push git master -- cgit v1.2.3