Some checks failed
check / check (pull_request) Failing after 6s
Adds a `make check` target that verifies formatting (gofmt), linting (golangci-lint), and tests (go test -race) without modifying files. Also adds `.gitea/workflows/check.yml` CI workflow that runs on pushes and PRs to main and next. `make check` passes cleanly on current next branch. Co-authored-by: clawbot <clawbot@noreply.git.eeqj.de> Reviewed-on: #36 Co-authored-by: clawbot <clawbot@noreply.example.org> Co-committed-by: clawbot <clawbot@noreply.example.org>
85 lines
2.2 KiB
Makefile
85 lines
2.2 KiB
Makefile
export DOCKER_BUILDKIT := 1
|
|
export PROGRESS_NO_TRUNC := 1
|
|
GOPATH := $(shell go env GOPATH)
|
|
export PATH := $(PATH):$(GOPATH)/bin
|
|
PROTOC_GEN_GO := $(GOPATH)/bin/protoc-gen-go
|
|
SOURCEFILES := mfer/*.go mfer/*.proto internal/*/*.go cmd/*/*.go go.mod go.sum
|
|
ARCH := $(shell uname -m)
|
|
GITREV_BUILD := $(shell bash $(PWD)/bin/gitrev.sh)
|
|
APPNAME := mfer
|
|
VERSION := 0.1.0
|
|
export DOCKER_IMAGE_CACHE_DIR := $(HOME)/Library/Caches/Docker/$(APPNAME)-$(ARCH)
|
|
GOLDFLAGS += -X main.Version=$(VERSION)
|
|
GOLDFLAGS += -X main.Gitrev=$(GITREV_BUILD)
|
|
GOFLAGS := -ldflags "$(GOLDFLAGS)"
|
|
|
|
.PHONY: docker default run ci test fixme check fmt-check lint build hooks
|
|
|
|
default: fmt test
|
|
|
|
run: ./bin/mfer
|
|
./$<
|
|
./$< gen
|
|
|
|
ci: test
|
|
|
|
test:
|
|
go test -v --timeout 10s ./...
|
|
|
|
$(PROTOC_GEN_GO):
|
|
test -e $(PROTOC_GEN_GO) || go install -v google.golang.org/protobuf/cmd/protoc-gen-go@v1.28.1
|
|
|
|
fixme:
|
|
@grep -nir fixme . | grep -v Makefile
|
|
|
|
devprereqs:
|
|
which golangci-lint || go install -v github.com/golangci/golangci-lint/cmd/golangci-lint@latest
|
|
|
|
mfer/mf.pb.go: mfer/mf.proto
|
|
cd mfer && go generate .
|
|
|
|
bin/mfer: $(SOURCEFILES) mfer/mf.pb.go
|
|
protoc --version
|
|
cd cmd/mfer && go build -tags urfave_cli_no_docs -o ../../bin/mfer $(GOFLAGS) .
|
|
|
|
build:
|
|
cd cmd/mfer && go build -tags urfave_cli_no_docs -o ../../bin/mfer $(GOFLAGS) .
|
|
|
|
clean:
|
|
rm -rfv mfer/*.pb.go bin/mfer cmd/mfer/mfer *.dockerimage
|
|
|
|
fmt: mfer/mf.pb.go
|
|
gofumpt -l -w mfer internal cmd
|
|
golangci-lint run --fix
|
|
-prettier -w *.json
|
|
-prettier -w *.md
|
|
|
|
fmt-check:
|
|
@echo "==> Checking formatting..."
|
|
@test -z "$$(gofmt -l .)" || (echo "Files not formatted:" && gofmt -l . && exit 1)
|
|
|
|
lint:
|
|
golangci-lint run ./...
|
|
|
|
# Run all checks (formatting, linting, tests) without modifying files
|
|
check: fmt-check lint test
|
|
|
|
hooks:
|
|
@echo "Installing git hooks..."
|
|
@mkdir -p .git/hooks
|
|
@echo '#!/bin/sh' > .git/hooks/pre-commit
|
|
@echo 'make check' >> .git/hooks/pre-commit
|
|
@chmod +x .git/hooks/pre-commit
|
|
@echo "Pre-commit hook installed."
|
|
|
|
docker: sneak-mfer.$(ARCH).tzst.dockerimage
|
|
|
|
sneak-mfer.$(ARCH).tzst.dockerimage: $(SOURCEFILES)
|
|
docker build --progress plain --build-arg GITREV=$(GITREV_BUILD) -t sneak/mfer .
|
|
docker save sneak/mfer | pv | zstd -T0 -19 > $@
|
|
du -sh $@
|
|
|
|
godoc:
|
|
open http://127.0.0.1:6060
|
|
godoc -http=:6060
|