-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
109 lines (90 loc) · 2.98 KB
/
Makefile
File metadata and controls
109 lines (90 loc) · 2.98 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
# Iris SDK Makefile
.PHONY: all build test lint fmt vet clean install-hooks help coverage
# Version information
VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
COMMIT ?= $(shell git rev-parse --short HEAD 2>/dev/null || echo "unknown")
BUILD_DATE ?= $(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
LDFLAGS := -ldflags "-X github.com/petal-labs/iris/cli/commands.Version=$(VERSION) \
-X github.com/petal-labs/iris/cli/commands.Commit=$(COMMIT) \
-X github.com/petal-labs/iris/cli/commands.BuildDate=$(BUILD_DATE)"
# Default target
all: lint test build
# Build all packages
build:
go build ./...
# Run all tests
test:
go test ./...
# Run tests with verbose output
test-v:
go test -v ./...
# Run tests with coverage summary
test-cover:
go test -cover ./...
# Generate coverage profile for CI/Codecov
coverage:
go test -race -coverprofile=coverage.out -covermode=atomic ./...
@echo "Coverage report generated: coverage.out"
# Generate and view HTML coverage report
coverage-html: coverage
go tool cover -html=coverage.out -o coverage.html
@echo "HTML report generated: coverage.html"
# Lint: format check and vet
lint: fmt-check vet
# Check formatting (fails if files need formatting)
fmt-check:
@echo "Checking gofmt..."
@UNFORMATTED=$$(gofmt -l .); \
if [ -n "$$UNFORMATTED" ]; then \
echo "The following files need formatting:"; \
echo "$$UNFORMATTED"; \
echo ""; \
echo "Run 'make fmt' to fix."; \
exit 1; \
fi
@echo "All files formatted correctly."
# Format all Go files
fmt:
gofmt -w .
# Run go vet
vet:
go vet ./...
# Clean build artifacts
clean:
go clean ./...
# Install git hooks
install-hooks:
./scripts/setup-hooks.sh
# Build the CLI with version information
build-cli:
go build $(LDFLAGS) -o bin/iris ./cli/cmd/iris
# Install the CLI locally with version information
install-cli:
go install $(LDFLAGS) ./cli/cmd/iris
# Run integration tests (requires API keys)
test-integration:
go test -tags=integration ./tests/integration/...
# Help
help:
@echo "Iris SDK Makefile"
@echo ""
@echo "Usage: make [target]"
@echo ""
@echo "Targets:"
@echo " all Run lint, test, and build (default)"
@echo " build Build all packages"
@echo " test Run all tests"
@echo " test-v Run tests with verbose output"
@echo " test-cover Run tests with coverage summary"
@echo " coverage Generate coverage.out profile for Codecov"
@echo " coverage-html Generate HTML coverage report"
@echo " lint Run fmt-check and vet"
@echo " fmt-check Check if files are formatted"
@echo " fmt Format all Go files"
@echo " vet Run go vet"
@echo " clean Clean build artifacts"
@echo " install-hooks Install git pre-commit hooks"
@echo " build-cli Build the CLI to bin/iris (with version info)"
@echo " install-cli Install the CLI locally (with version info)"
@echo " test-integration Run integration tests (requires API keys)"
@echo " help Show this help"