Add make check target and CI workflow (#36)
Some checks failed
check / check (pull_request) Failing after 6s
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>
This commit was merged in pull request #36.
This commit is contained in:
43
Makefile
43
Makefile
@@ -13,7 +13,7 @@ GOLDFLAGS += -X main.Version=$(VERSION)
|
||||
GOLDFLAGS += -X main.Gitrev=$(GITREV_BUILD)
|
||||
GOFLAGS := -ldflags "$(GOLDFLAGS)"
|
||||
|
||||
.PHONY: docker default run ci test fixme
|
||||
.PHONY: docker default run ci test fixme check fmt-check lint build hooks
|
||||
|
||||
default: fmt test
|
||||
|
||||
@@ -23,7 +23,7 @@ run: ./bin/mfer
|
||||
|
||||
ci: test
|
||||
|
||||
test: $(SOURCEFILES) mfer/mf.pb.go
|
||||
test:
|
||||
go test -v --timeout 10s ./...
|
||||
|
||||
$(PROTOC_GEN_GO):
|
||||
@@ -42,6 +42,9 @@ 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
|
||||
|
||||
@@ -51,31 +54,31 @@ fmt: mfer/mf.pb.go
|
||||
-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
|
||||
sh -c 'test -z "$$(gofmt -l .)"'
|
||||
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) vendor.tzst modcache.tzst
|
||||
sneak-mfer.$(ARCH).tzst.dockerimage: $(SOURCEFILES)
|
||||
docker build --progress plain --build-arg GITREV=$(GITREV_BUILD) -t sneak/mfer .
|
||||
docker save sneak/mfer | pv | zstdmt -19 > $@
|
||||
docker save sneak/mfer | pv | zstd -T0 -19 > $@
|
||||
du -sh $@
|
||||
|
||||
godoc:
|
||||
open http://127.0.0.1:6060
|
||||
godoc -http=:6060
|
||||
|
||||
vendor.tzst: go.mod go.sum
|
||||
go mod tidy
|
||||
go mod vendor
|
||||
cd vendor && tar -c . | pv | zstdmt -19 > $(PWD)/$@.tmp
|
||||
rm -rf vendor
|
||||
mv $@.tmp $@
|
||||
|
||||
modcache.tzst: go.mod go.sum
|
||||
go mod tidy
|
||||
cd $(HOME)/go/pkg && chmod -R u+rw . && rm -rf mod sumdb
|
||||
go mod download -x
|
||||
cd $(shell go env GOMODCACHE) && tar -c . | pv | zstdmt -19 > $(PWD)/$@.tmp
|
||||
mv $@.tmp $@
|
||||
|
||||
Reference in New Issue
Block a user