Adopt scripts-to-rule-them-all: script/ entrypoints, Makefile shims

This commit is contained in:
2026-07-07 00:19:19 +02:00
parent df975bb8f0
commit 43346e62db
16 changed files with 291 additions and 13 deletions

View File

@@ -1,4 +1,4 @@
.PHONY: all check test lint fmt fmt-check build clean deps test-coverage test-integration local install release release-snapshot docker hooks
.PHONY: all bootstrap setup check test lint fmt fmt-check build clean deps test-coverage test-integration local install release release-snapshot docker hooks
# Version number
VERSION := 1.0.0-rc.1
@@ -15,24 +15,33 @@ LDFLAGS := -X 'sneak.berlin/go/vaultik/internal/globals.Version=$(VERSION)' \
# Default target
all: vaultik
# 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.
vaultik: internal/*/*.go cmd/vaultik/*.go
@@ -74,11 +83,8 @@ release-snapshot:
# Build Docker image.
docker:
docker build -t vaultik .
@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