Adopt scripts-to-rule-them-all: script/ entrypoints, Makefile shims
This commit is contained in:
30
Makefile
30
Makefile
@@ -1,4 +1,4 @@
|
||||
.PHONY: all check test lint fmt fmt-check build clean deps test-coverage test-integration install release release-snapshot docker hooks
|
||||
.PHONY: all bootstrap setup check test lint fmt fmt-check build clean deps test-coverage test-integration install release release-snapshot docker hooks
|
||||
|
||||
# Version number
|
||||
VERSION := 0.1.0-dev
|
||||
@@ -6,24 +6,33 @@ VERSION := 0.1.0-dev
|
||||
# Default target
|
||||
all: bsdaily
|
||||
|
||||
# Combined pre-commit/CI gate: lint, format check, then tests.
|
||||
check: lint fmt-check test
|
||||
# Install all development dependencies.
|
||||
bootstrap:
|
||||
@script/bootstrap
|
||||
|
||||
# Prepare a fresh clone: bootstrap plus pre-commit hook.
|
||||
setup:
|
||||
@script/setup
|
||||
|
||||
# Combined pre-commit/CI gate: tests, lint, format check.
|
||||
check:
|
||||
@script/check
|
||||
|
||||
# Run tests only.
|
||||
test:
|
||||
go test -race -timeout 30s ./...
|
||||
@script/test
|
||||
|
||||
# Check if code is formatted (read-only).
|
||||
fmt-check:
|
||||
@test -z "$$(gofmt -l .)" || (echo "Files not formatted:" && gofmt -l . && exit 1)
|
||||
@script/fmt-check
|
||||
|
||||
# Format code.
|
||||
fmt:
|
||||
go fmt ./...
|
||||
@script/fmt
|
||||
|
||||
# Run linter only.
|
||||
lint:
|
||||
golangci-lint run ./...
|
||||
@script/lint
|
||||
|
||||
# Build binary (pure Go; no CGO required since we use modernc.org/sqlite).
|
||||
bsdaily: internal/*/*.go cmd/bsdaily/*.go
|
||||
@@ -61,11 +70,8 @@ release-snapshot:
|
||||
|
||||
# Build Docker image.
|
||||
docker:
|
||||
docker build -t bsdaily .
|
||||
@script/docker
|
||||
|
||||
# Install pre-commit hook.
|
||||
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
|
||||
@script/install-precommit
|
||||
|
||||
Reference in New Issue
Block a user