All checks were successful
check / check (push) Successful in 4s
Buildarch was erroneously included. Remove it from: - internal/globals/globals.go (struct field, package var, setter) - cmd/dnswatcher/main.go (var declaration, setter call) - Makefile (BUILDARCH var, ldflags) - internal/logger/logger.go (Identify log field) - internal/config/config_test.go (test fixture) - README.md (build command, architecture section)
49 lines
1.2 KiB
Makefile
49 lines
1.2 KiB
Makefile
.PHONY: all build lint fmt fmt-check test check clean hooks docker
|
|
|
|
BINARY := dnswatcher
|
|
VERSION := $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
|
|
LDFLAGS := -X main.Version=$(VERSION)
|
|
|
|
all: check build
|
|
|
|
build:
|
|
go build -ldflags "$(LDFLAGS)" -o bin/$(BINARY) ./cmd/dnswatcher
|
|
|
|
lint:
|
|
golangci-lint run --config .golangci.yml ./...
|
|
|
|
fmt:
|
|
gofmt -s -w .
|
|
goimports -w .
|
|
|
|
fmt-check:
|
|
@test -z "$$(gofmt -l .)" || (echo "gofmt: files not formatted:" && gofmt -l . && exit 1)
|
|
|
|
test:
|
|
go test -v -race -timeout 30s -cover ./...
|
|
|
|
# Check runs all validation without making changes
|
|
# Used by CI and Docker build - fails if anything is wrong
|
|
check:
|
|
@echo "==> Checking formatting..."
|
|
@test -z "$$(gofmt -l .)" || (echo "Files not formatted:" && gofmt -l . && exit 1)
|
|
@echo "==> Running linter..."
|
|
golangci-lint run --config .golangci.yml ./...
|
|
@echo "==> Running tests..."
|
|
go test -v -race -timeout 30s ./...
|
|
@echo "==> Building..."
|
|
go build -ldflags "$(LDFLAGS)" -o /dev/null ./cmd/dnswatcher
|
|
@echo "==> All checks passed!"
|
|
|
|
clean:
|
|
rm -rf bin/
|
|
|
|
hooks:
|
|
@echo '#!/bin/sh' > .git/hooks/pre-commit
|
|
@echo 'make check' >> .git/hooks/pre-commit
|
|
@chmod +x .git/hooks/pre-commit
|
|
@echo "Pre-commit hook installed."
|
|
|
|
docker:
|
|
docker build .
|