diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..72f751e --- /dev/null +++ b/Makefile @@ -0,0 +1,52 @@ +# yetano-webui-template is a library (package layout): nothing to build or +# publish, only to check. A release is a git tag -- see README.md, +# "Versioning note". + +.PHONY: all +all: ci + +.PHONY: test +test: + go test ./... -race + +.PHONY: fmt +fmt: + @out="$$(gofmt -l .)"; \ + if [ -n "$$out" ]; then \ + echo "not gofmt'ed:"; echo "$$out"; exit 1; \ + fi + +.PHONY: fmt-fix +fmt-fix: + gofmt -w . + +.PHONY: vet +vet: + go vet ./... + +# govulncheck at a pinned version via "go run" -- no global install. Not +# part of test on purpose: it needs network access to vuln.go.dev, and +# since that database changes daily, a check would start failing without +# any code change (see ../TODO.md "govulncheck in allen Go-Modulen"). +GOVULNCHECK ?= go run golang.org/x/vuln/cmd/govulncheck@v1.9.0 + +.PHONY: vulncheck +vulncheck: + $(GOVULNCHECK) ./... + +.PHONY: tidy +tidy: + go mod tidy + +.PHONY: ci +ci: fmt vet test vulncheck + +.PHONY: help +help: + @echo "Targets:" + @echo " ci fmt + vet + test + vulncheck (the default)" + @echo " fmt fail if a file is not gofmt'ed (fmt-fix rewrites them)" + @echo " vet go vet" + @echo " test go test -race" + @echo " vulncheck govulncheck $(subst go run ,,$(GOVULNCHECK))" + @echo " tidy go mod tidy" diff --git a/README.md b/README.md index ac7a818..ec5f8a9 100644 --- a/README.md +++ b/README.md @@ -145,6 +145,12 @@ deliverable (Go templates) doesn't apply. It adopted the same dark palette independently in its own stylesheet instead, plus its own light/dark toggle — see its `internal/yaais/static/style.css`. +## Checks + +`make ci` (the default target) runs `fmt`, `vet`, `test` (with `-race`) +and `vulncheck` (govulncheck at a pinned version, needs network access). +Run it before tagging. + ## Versioning note Use `v0.1.5` or later. `v0.1.3` and `v0.1.4` were force-moved to