fix: rebase onto main, fix SQLite concurrency, lint clean
All checks were successful
check / check (push) Successful in 2m11s
All checks were successful
check / check (push) Successful in 2m11s
- Add busy_timeout PRAGMA and MaxOpenConns(1) for SQLite stability - Use per-test temp DB in handler tests to prevent state leaks - Pre-allocate migrations slice (prealloc lint) - Remove invalid linter names (wsl_v5, noinlineerr) from .golangci.yml - Remove unused //nolint:gosec directives - Replace context.Background() with t.Context() in tests - Use goimports formatting for all files - All make check passes with zero failures
This commit is contained in:
55
Makefile
55
Makefile
@@ -1,20 +1,49 @@
|
||||
VERSION := $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
|
||||
LDFLAGS := -ldflags "-X main.Version=$(VERSION)"
|
||||
.PHONY: all build lint fmt fmt-check test check clean run debug docker hooks
|
||||
|
||||
.PHONY: build test clean docker lint
|
||||
BINARY := chatd
|
||||
VERSION := $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
|
||||
BUILDARCH := $(shell go env GOARCH)
|
||||
LDFLAGS := -X main.Version=$(VERSION) -X main.Buildarch=$(BUILDARCH)
|
||||
|
||||
all: check build
|
||||
|
||||
build:
|
||||
go build $(LDFLAGS) -o chatd ./cmd/chatd/
|
||||
go build $(LDFLAGS) -o chat-cli ./cmd/chat-cli/
|
||||
|
||||
test:
|
||||
DBURL="file::memory:?cache=shared" go test ./...
|
||||
|
||||
clean:
|
||||
rm -f chatd chat-cli
|
||||
go build -ldflags "$(LDFLAGS)" -o bin/$(BINARY) ./cmd/chatd
|
||||
|
||||
lint:
|
||||
GOFLAGS=-buildvcs=false golangci-lint run ./...
|
||||
golangci-lint run --config .golangci.yml ./...
|
||||
|
||||
fmt:
|
||||
gofmt -s -w .
|
||||
goimports -w .
|
||||
|
||||
fmt-check:
|
||||
@test -z "$$(gofmt -l .)" || (echo "Files not formatted:" && gofmt -l . && exit 1)
|
||||
|
||||
test:
|
||||
go test -timeout 30s -v -race -cover ./...
|
||||
|
||||
# check runs all validation without making changes
|
||||
# Used by CI and Docker build — fails if anything is wrong
|
||||
check: test lint fmt-check
|
||||
@echo "==> Building..."
|
||||
go build -ldflags "$(LDFLAGS)" -o /dev/null ./cmd/chatd
|
||||
@echo "==> All checks passed!"
|
||||
|
||||
run: build
|
||||
./bin/$(BINARY)
|
||||
|
||||
debug: build
|
||||
DEBUG=1 GOTRACEBACK=all ./bin/$(BINARY)
|
||||
|
||||
clean:
|
||||
rm -rf bin/ chatd data.db
|
||||
|
||||
docker:
|
||||
docker build -t chat:$(VERSION) .
|
||||
docker build -t chat .
|
||||
|
||||
hooks:
|
||||
@printf '#!/bin/sh\nset -e\n' > .git/hooks/pre-commit
|
||||
@printf 'go mod tidy\ngo fmt ./...\ngit diff --exit-code -- go.mod go.sum || { echo "go mod tidy changed files; please stage and retry"; exit 1; }\n' >> .git/hooks/pre-commit
|
||||
@printf 'make check\n' >> .git/hooks/pre-commit
|
||||
@chmod +x .git/hooks/pre-commit
|
||||
|
||||
Reference in New Issue
Block a user