-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
64 lines (50 loc) · 1.53 KB
/
Makefile
File metadata and controls
64 lines (50 loc) · 1.53 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
.PHONY: build test e2e-test clean docker-build fmt vet generate
BINARY_NAME=binarylane-cloud-controller-manager
DOCKER_IMAGE=binarylane-cloud-controller-manager
VERSION?=$(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
LDFLAGS=-ldflags "-X main.version=$(VERSION)"
all: test build
generate:
@echo "Generating API client from OpenAPI spec..."
go generate ./...
build:
@echo "Building $(BINARY_NAME)..."
go build $(LDFLAGS) -o bin/$(BINARY_NAME) ./cmd/$(BINARY_NAME)
test:
@echo "Running unit tests..."
go test -v -race -coverprofile=coverage.out ./...
e2e-test:
@echo "Running end-to-end tests..."
@if [ -f .env ]; then \
echo "Loading environment from .env..."; \
export $$(cat .env | grep -v '^#' | xargs) && ./scripts/e2e-test.sh; \
elif [ -z "$$BINARYLANE_API_TOKEN" ]; then \
echo "Error: BINARYLANE_API_TOKEN not set and .env file not found"; \
exit 1; \
else \
./scripts/e2e-test.sh; \
fi
coverage: test
@echo "Generating coverage report..."
go tool cover -html=coverage.out -o coverage.html
clean:
@echo "Cleaning..."
rm -rf bin/
rm -f coverage.out coverage.html
fmt:
@echo "Formatting code..."
go fmt ./...
vet:
@echo "Vetting code..."
go vet ./...
lint: fmt vet
@echo "Linting complete"
docker-build:
@echo "Building Docker image..."
docker build -t $(DOCKER_IMAGE):$(VERSION) .
docker tag $(DOCKER_IMAGE):$(VERSION) $(DOCKER_IMAGE):latest
docker-push:
@echo "Pushing Docker image..."
docker push $(DOCKER_IMAGE):$(VERSION)
docker push $(DOCKER_IMAGE):latest
.DEFAULT_GOAL := build