From 079569e9499bfb7552f19192d29c3a31369f73b0 Mon Sep 17 00:00:00 2001 From: ddelange <14880945+ddelange@users.noreply.github.com> Date: Tue, 15 Aug 2023 04:51:17 +0200 Subject: [PATCH] Add Makefile documentation (#25) Add help texts to Makefile targets: all Alias for `build` build Build runtime Docker image build.develop Build develop container image develop Run interactive shell inside developer container fmt Auto-format source code and report code-style violations (lint) help Print Makefile documentation run Run make target inside developer container (e.g. `make run fmt`) test Run tests --------- Signed-off-by: ddelange <14880945+ddelange@users.noreply.github.com> --- Makefile | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Makefile b/Makefile index 7e0a2f9..70234dc 100644 --- a/Makefile +++ b/Makefile @@ -23,32 +23,45 @@ ifeq (run,$(firstword $(MAKECMDGOALS))) endif .PHONY: all +## Alias for `build` all: build .PHONY: build +## Build runtime Docker image build: docker build -t ${IMG_NAME}:latest --target runtime . .PHONY: build.develop +## Build develop container image build.develop: docker build -t ${IMG_NAME}-develop:latest --target develop . .PHONY: develop +## Run interactive shell inside developer container develop: build.develop ./scripts/develop.sh .PHONY: run +## Run make target inside developer container (e.g. `make run fmt`) run: build.develop ./scripts/develop.sh make $(RUN_ARGS) .PHONY: fmt +## Auto-format source code and report code-style violations (lint) fmt: ./scripts/fmt.sh .PHONY: test +## Run tests test: go test -coverprofile cover.out `go list ./...` +.DEFAULT_GOAL := help +.PHONY: help +## Print Makefile documentation +help: + @perl -0 -nle 'printf("\033[36m %-15s\033[0m %s\n", "$$2", "$$1") while m/^##\s*([^\r\n]+)\n^([\w.-]+):[^=]/gm' $(MAKEFILE_LIST) | sort + # Override targets if they are included in RUN_ARGs so it doesn't run them twice # otherwise 'make run fmt' would be equivalent to calling './scripts/develop.sh make fmt' # followed by 'make fmt'