-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
115 lines (96 loc) · 4.38 KB
/
Copy pathMakefile
File metadata and controls
115 lines (96 loc) · 4.38 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# Variables
BINARY_NAME=artemisctl
MAIN_PATH=./cmd/artemisctl/main.go
BUILD_DIR=./bin
COVERAGE_FILE=coverage.txt
# Linker flags to strip debug information
LDFLAGS=-ldflags="-s -w"
.PHONY: all build clean fmt vet test test-short coverage release help it-clean fixtures
# Name of the shared, reused integration-test broker container.
IT_BROKER=artemisctl-it-broker
# Default target when you just type 'make'
all: clean test build
## build: Compile the CLI for your current operating system
build:
@echo "==> Building $(BINARY_NAME)..."
@mkdir -p $(BUILD_DIR)
go build -o $(BUILD_DIR)/$(BINARY_NAME) $(MAIN_PATH)
@echo "==> Done. Binary is in $(BUILD_DIR)/$(BINARY_NAME)"
## fmt: Format every Go file in the module (gofmt -s, in place)
fmt:
@echo "==> Formatting..."
gofmt -s -w .
@echo "==> Done."
## vet: Run go vet over the whole module
vet:
@echo "==> Running go vet..."
go vet ./...
@echo "==> Done."
## test: Run all tests (including our Testcontainers broker tests)
test: fmt vet
@echo "==> Running tests..."
go test -v -p 1 ./internal/...
## test-short: Run only the fast unit tests (skips every broker integration test)
# Every integration test is gated behind testing.Short(), so -short skips them
# all and no broker container is booted. Packages run in parallel (no -p 1,
# which is only needed to serialize access to the shared integration broker),
# so this is the quick inner-loop check while iterating. CI still runs the full
# `make coverage-ci` suite for the complete coverage profile.
test-short: fmt vet
@echo "==> Running fast unit tests (-short, no broker)..."
go test -short -race ./internal/...
## coverage: Run tests with coverage for CI
coverage-ci:
@echo "==> Running tests with coverage..."
go test -covermode=atomic -race -p 1 -coverprofile=$(COVERAGE_FILE) ./internal/...
@echo "==> Done."
## coverage: Run tests with coverage and generate an HTML report
coverage: coverage-ci
@echo "==> Generating HTML report..."
go tool cover -html=$(COVERAGE_FILE) -o coverage.html
@echo "==> Done. Open coverage.html in your browser."
## release: Cross-compile the CLI for Linux, macOS (Darwin), and Windows
release: clean
@echo "==> Building release binaries..."
@mkdir -p $(BUILD_DIR)/release
GOOS=linux CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GOAMD64=v3 go build $(LDFLAGS) -o $(BUILD_DIR)/release/$(BINARY_NAME)-linux-amd64 $(MAIN_PATH)
GOOS=darwin CGO_ENABLED=0 GOARCH=arm64 go build $(LDFLAGS) -o $(BUILD_DIR)/release/$(BINARY_NAME)-darwin-arm64 $(MAIN_PATH)
@echo "==> Release binaries are in $(BUILD_DIR)/release/"
## clean: Remove build artifacts and coverage files
clean:
@echo "==> Cleaning up..."
@rm -rf $(BUILD_DIR)
@echo "==> Cleaned."
@echo "==> go mod tidy to clean up go.mod and go.sum..."
@go mod tidy
## fixtures: Regenerate internal/journal/testdata from a live 2.42 container
# The harvester is an integration test gated behind ARTEMISCTL_HARVEST=1 (so
# plain `make test` skips it). It uses a dedicated container, not the shared
# reused broker, because it stops the broker to freeze the journal.
fixtures:
@echo "==> Harvesting Artemis 2.42 data-dir fixture..."
ARTEMISCTL_HARVEST=1 go test -run TestHarvestFixture -v -p 1 -timeout 15m ./internal/journal/
@echo "==> Done. See internal/journal/testdata/"
## it-clean: Remove the shared integration-test broker container
# Integration tests reuse one broker (Reuse: true) and never terminate it, and
# Ryuk cannot reap reused containers (and is disabled under rootless podman), so
# the broker lingers on purpose. Run this to force-remove it.
it-clean:
@echo "==> Removing shared integration broker $(IT_BROKER)..."
@docker rm -f $(IT_BROKER) 2>/dev/null || true
@echo "==> Done."
## help: Show this help message
help:
@echo "Usage: make <target>"
@echo ""
@echo "Targets:"
@echo " build - Compile the CLI for your current operating system"
@echo " fmt - Format every Go file (gofmt -s -w)"
@echo " vet - Run go vet over the whole module"
@echo " test - Format, vet, then run all tests"
@echo " test-short - Format, vet, then run only fast unit tests (no broker)"
@echo " coverage - Run tests with coverage and generate an HTML report"
@echo " release - Cross-compile the CLI for Linux, macOS, and Windows"
@echo " fixtures - Regenerate internal/journal/testdata from a live 2.42 container"
@echo " it-clean - Remove the shared integration-test broker container"
@echo " clean - Remove build artifacts"