From 5db19b26aeb54a6551cdd4e841717d5ebebca480 Mon Sep 17 00:00:00 2001 From: Esa Kataja Date: Sat, 5 Sep 2026 13:46:30 +0300 Subject: [PATCH] Add a Makefile, so one command is the whole check MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Verifying a change meant four invocations — gofmt, go vet, go build, go test — and remembering the order. `make` is all of them with one exit code. gofmt needs the wrapper: it reports offending files on stdout and still exits 0, so a bare `gofmt -l .` in a target would never fail the build. --- Makefile | 24 ++++++++++++++++++++++++ README.md | 8 +++++--- 2 files changed, 29 insertions(+), 3 deletions(-) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..d4c8753 --- /dev/null +++ b/Makefile @@ -0,0 +1,24 @@ +# One command before committing: make +# +# gofmt is first because a formatting failure is the cheapest to fix, and it is the only check that +# needs a wrapper — gofmt reports offending files on stdout and still exits 0. +.POSIX: +.PHONY: check fmt vet test build run + +check: fmt vet test + +fmt: + @out=$$(gofmt -l .); test -z "$$out" || { echo "not gofmt'd:"; echo "$$out"; exit 1; } + +vet: + go vet ./... + +test: + go test ./... + +build: + go build -o levyraati26-go . + +# Templates and migrations are embedded, so seeing a change means rebuilding. +run: build + ./levyraati26-go diff --git a/README.md b/README.md index d9a8df6..189630c 100644 --- a/README.md +++ b/README.md @@ -88,14 +88,16 @@ go run . Requires Go 1.27+, plus `ffmpeg`, `ffprobe`, and `yt-dlp` on `PATH`. There is nothing to start first: the database is a file under `./storage`, created on the first run. -Tests get a fresh database file in a temp directory each, so they need no setup and touch nothing: +Tests get a fresh database file in a temp directory each, so they need no setup and touch nothing. +`make` is everything that has to pass before a commit — formatting, `go vet`, and the tests: ```sh -go test ./... +make # gofmt -l, go vet, go test +make test # just the tests ``` Templates, stylesheet, and migrations are embedded with `embed.FS`, so a rebuild is needed to see -template changes. `go build && ./levyraati` is the loop. +template changes. `make run` is the loop. ## Admin page