summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulien Dessaux2024-08-26 16:45:28 +0200
committerJulien Dessaux2024-08-26 16:45:41 +0200
commitccec94a4dd6a5feb9664f004072f78d7c36eca7e (patch)
treea20d987e3273073a7d2ff069130cae67df009399
parentchore(gonf): updated dependencies (diff)
downloadgonf-ccec94a4dd6a5feb9664f004072f78d7c36eca7e.tar.gz
gonf-ccec94a4dd6a5feb9664f004072f78d7c36eca7e.tar.bz2
gonf-ccec94a4dd6a5feb9664f004072f78d7c36eca7e.zip
chore(gonf): added makefile
-rw-r--r--GNUmakefile51
1 files changed, 51 insertions, 0 deletions
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