diff options
| author | Murilo Ijanc <[email protected]> | 2026-07-26 15:18:21 -0300 |
|---|---|---|
| committer | Murilo Ijanc <[email protected]> | 2026-07-26 15:18:21 -0300 |
| commit | 3ca1d2c4370e8e79aba3940d5c8fe115960b75a8 (patch) | |
| tree | aa964675c588b80e4f81182d34130ba2d7d984e1 /Makefile | |
| download | telegram-3ca1d2c4370e8e79aba3940d5c8fe115960b75a8.tar.gz | |
Initial importv0.1.0
Diffstat (limited to 'Makefile')
| -rw-r--r-- | Makefile | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..2eeccc6 --- /dev/null +++ b/Makefile @@ -0,0 +1,56 @@ +# Development tasks. Everything runs through the `go` tool, so there is +# nothing to install first. +# +# make list the targets +# make test run the suite +# make lint gofmt check + go vet, no files touched +# make build compile the binary into bin/ +GO ?= go +BINARY ?= bin/cepis-telegram +IMAGE ?= cepis-telegram:dev + +.DEFAULT_GOAL := help +.PHONY: help test test-race lint format build image check clean + +help: + @echo 'Targets:' + @echo ' test run the test suite' + @echo ' test-race run it under the race detector' + @echo ' lint gofmt -l + go vet (read-only)' + @echo ' format apply gofmt (writes)' + @echo ' build compile the binary into $(BINARY)' + @echo ' image build the container image as $(IMAGE)' + @echo ' check lint + test + build, in that order' + @echo ' clean remove build and test artefacts' + +test: + $(GO) test ./... + +test-race: + $(GO) test -race -count=1 ./... + +# Read-only by design, so it is safe in CI and in a pre-commit hook: it reports +# what `make format` would change without changing anything. +lint: + @files=$$(gofmt -l .); \ + if [ -n "$$files" ]; then \ + echo 'gofmt would rewrite:'; echo "$$files"; exit 1; \ + fi + $(GO) vet ./... + +format: + gofmt -w . + +build: + CGO_ENABLED=0 $(GO) build -trimpath -ldflags '-s -w' -o $(BINARY) . + +image: + docker build -t $(IMAGE) . + +# The order matters: lint is the fastest to fail, so a broken run reports the +# cheapest problem first. +check: lint test build + +clean: + $(GO) clean -testcache + rm -rf bin |