scripts-to-rule-them-all (#45)
All checks were successful
check / check (push) Successful in 4s

Reviewed-on: #45
Co-authored-by: sneak <sneak@sneak.berlin>
Co-committed-by: sneak <sneak@sneak.berlin>
This commit was merged in pull request #45.
This commit is contained in:
2026-07-07 02:14:03 +02:00
committed by Jeffrey Paul
parent 2fb909283d
commit 504afea4f8
17 changed files with 611 additions and 29 deletions

View File

@@ -1,4 +1,4 @@
.PHONY: check lint test fmt fmt-check build clean docker docker-test devserver devserver-stop hooks
.PHONY: bootstrap setup check lint test fmt fmt-check build clean docker docker-versioned docker-test devserver devserver-stop hooks
VERSION := $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
LDFLAGS := -X main.Version=$(VERSION)
@@ -15,27 +15,30 @@ else
endif
# Default target: run all checks
check: fmt-check lint test
check:
@script/check
bootstrap:
@script/bootstrap
setup:
@script/setup
# Check formatting without modifying files
fmt-check:
@echo "Checking formatting..."
@test -z "$$(gofmt -l . | grep -v '^vendor/')" || (echo "Files need formatting:"; gofmt -l . | grep -v '^vendor/'; exit 1)
@script/fmt-check
# Format code
fmt:
@echo "Formatting code..."
gofmt -w $$(find . -name '*.go' -not -path './vendor/*')
@script/fmt
# Run linter
lint:
@echo "Running linter..."
$(NIX_RUN_PREFIX)golangci-lint run$(NIX_RUN_SUFFIX)
@script/lint
# Run tests (30-second timeout)
test:
@echo "Running tests..."
$(NIX_RUN_PREFIX)CGO_ENABLED=1 go test -timeout 30s -v ./...$(NIX_RUN_SUFFIX)
@script/test
# Build the binary
build:
@@ -47,8 +50,12 @@ clean:
rm -rf bin/
rm -rf ./data
# Build Docker image
# Build Docker image (tagged via script/projectname)
docker:
@script/docker
# Build Docker image tagged pixad:$(VERSION) and pixad:latest
docker-versioned:
docker build --build-arg VERSION=$(VERSION) -t pixad:$(VERSION) -t pixad:latest .
# Run tests in Docker (needed for CGO/libvips)
@@ -57,7 +64,7 @@ docker-test:
docker run --rm pixad-builder sh -c "CGO_ENABLED=1 GOTOOLCHAIN=auto go test -v ./..."
# Run local dev server in Docker
devserver: docker devserver-stop
devserver: docker-versioned devserver-stop
docker run -d --name pixad-dev -p 8080:8080 \
-v $(CURDIR)/config.dev.yml:/etc/pixa/config.yml:ro \
pixad:latest
@@ -70,6 +77,4 @@ devserver-stop:
# Install pre-commit hook
hooks:
@printf '#!/bin/sh\nset -e\n' > .git/hooks/pre-commit
@printf 'make check\n' >> .git/hooks/pre-commit
@chmod +x .git/hooks/pre-commit
@script/install-precommit