Skip to content

Commit

Permalink
Add Makefile documentation (#25)
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
ddelange authored Aug 15, 2023
1 parent 83b1221 commit 079569e
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit 079569e

Please sign in to comment.