-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
87 lines (69 loc) · 2.32 KB
/
Makefile
File metadata and controls
87 lines (69 loc) · 2.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
BINARY := github-runner
MODULE := github.com/nficano/github-runner
VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
COMMIT ?= $(shell git rev-parse --short HEAD 2>/dev/null || echo "unknown")
DATE ?= $(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
LDFLAGS := -s -w \
-X $(MODULE)/internal/version.Version=$(VERSION) \
-X $(MODULE)/internal/version.Commit=$(COMMIT) \
-X $(MODULE)/internal/version.Date=$(DATE)
GO := go
GOFLAGS ?=
GOTESTFLAGS ?= -race
.DEFAULT_GOAL := build
.PHONY: build
build: ## Build the binary
$(GO) build $(GOFLAGS) -ldflags '$(LDFLAGS)' -o bin/$(BINARY) ./cmd/github-runner
.PHONY: install
install: ## Install to GOPATH/bin
$(GO) install $(GOFLAGS) -ldflags '$(LDFLAGS)' ./cmd/github-runner
.PHONY: test
test: ## Run unit tests with race detection
$(GO) test $(GOTESTFLAGS) ./...
.PHONY: test-integration
test-integration: ## Run integration tests
$(GO) test $(GOTESTFLAGS) -tags=integration ./...
.PHONY: lint
lint: ## Run golangci-lint
golangci-lint run ./...
.PHONY: fmt
fmt: ## Format code
gofumpt -w .
goimports -w .
.PHONY: vet
vet: ## Run go vet
$(GO) vet ./...
.PHONY: coverage
coverage: ## Generate coverage report
$(GO) test $(GOTESTFLAGS) -coverprofile=coverage.out ./...
$(GO) tool cover -html=coverage.out -o coverage.html
@echo "Coverage report: coverage.html"
.PHONY: bench
bench: ## Run benchmarks
$(GO) test -bench=. -benchmem ./...
.PHONY: generate
generate: ## Run go generate
$(GO) generate ./...
.PHONY: docker-build
docker-build: ## Build Docker image
docker build -t $(BINARY):$(VERSION) .
.PHONY: goreleaser
goreleaser: ## Snapshot release build
goreleaser release --snapshot --clean
.PHONY: release
release: ## Create a new release tag and push (usage: make release v=0.1.0)
@if [ -z "$(v)" ]; then echo "Usage: make release v=0.1.0"; exit 1; fi
git tag -a "v$(v)" -m "Release v$(v)"
git push origin "v$(v)"
.PHONY: clean
clean: ## Remove build artifacts
rm -rf bin/ dist/ coverage.out coverage.html
.PHONY: tidy
tidy: ## Tidy go modules
$(GO) mod tidy
.PHONY: check
check: vet lint test ## Run all checks
.PHONY: help
help: ## Show this help
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | \
awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'