check / check (push) Successful in 2m40s
The Makefile no longer passes a build architecture; it set a variable that does not exist, and the architecture is available at run time. A plain docker build now stamps neoircd with the tag or short commit: .dockerignore sends .git, without its config, and the builder takes the version from the VERSION build arg when given, otherwise from git describe. With .git present, an empty, dev or unknown version fails the build. Model: opus-5-5
60 lines
1.8 KiB
Makefile
60 lines
1.8 KiB
Makefile
.PHONY: all build lint fmt fmt-check test check clean run debug docker hooks ensure-web-dist
|
|
|
|
BINARY := neoircd
|
|
VERSION := $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
|
|
LDFLAGS := -X main.Version=$(VERSION)
|
|
|
|
all: check build
|
|
|
|
# ensure-web-dist creates placeholder files so //go:embed dist/* in
|
|
# web/embed.go resolves without a full Node.js build. The real SPA is
|
|
# built by the web-builder Docker stage; these placeholders let
|
|
# "make test" and "make build" work outside Docker.
|
|
ensure-web-dist:
|
|
@if [ ! -d web/dist ]; then \
|
|
mkdir -p web/dist && \
|
|
touch web/dist/index.html web/dist/style.css web/dist/app.js && \
|
|
echo "==> Created placeholder web/dist/ for go:embed"; \
|
|
fi
|
|
|
|
build: ensure-web-dist
|
|
go build -ldflags "$(LDFLAGS)" -o bin/$(BINARY) ./cmd/neoircd
|
|
|
|
lint: ensure-web-dist
|
|
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: ensure-web-dist
|
|
go test -timeout 120s -race -cover ./... || go test -timeout 120s -race -v ./...
|
|
|
|
# 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/neoircd
|
|
@echo "==> All checks passed!"
|
|
|
|
run: build
|
|
./bin/$(BINARY)
|
|
|
|
debug: build
|
|
DEBUG=1 GOTRACEBACK=all ./bin/$(BINARY)
|
|
|
|
clean:
|
|
rm -rf bin/ neoircd
|
|
|
|
docker:
|
|
docker build -t neoirc .
|
|
|
|
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
|