gogcli/Makefile
2025-12-24 17:17:47 +01:00

43 lines
892 B
Makefile

SHELL := /bin/bash
# `make` should build the binary by default.
.DEFAULT_GOAL := build
.PHONY: build fmt fmt-check lint test ci tools
BIN_DIR := $(CURDIR)/bin
BIN := $(BIN_DIR)/gog
CMD := ./cmd/gog
TOOLS_DIR := $(CURDIR)/.tools
GOFUMPT := $(TOOLS_DIR)/gofumpt
GOIMPORTS := $(TOOLS_DIR)/goimports
GOLANGCI_LINT := $(TOOLS_DIR)/golangci-lint
build:
@mkdir -p $(BIN_DIR)
@go build -o $(BIN) $(CMD)
tools:
@mkdir -p $(TOOLS_DIR)
@GOBIN=$(TOOLS_DIR) go install mvdan.cc/gofumpt@v0.9.2
@GOBIN=$(TOOLS_DIR) go install golang.org/x/tools/cmd/goimports@v0.40.0
@GOBIN=$(TOOLS_DIR) go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.64.8
fmt: tools
@$(GOIMPORTS) -w .
@$(GOFUMPT) -w .
fmt-check: tools
@$(GOIMPORTS) -w .
@$(GOFUMPT) -w .
@git diff --exit-code -- '*.go' go.mod go.sum
lint: tools
@$(GOLANGCI_LINT) run
test:
@go test ./...
ci: fmt-check lint test