-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
75 lines (60 loc) · 3.03 KB
/
Copy pathMakefile
File metadata and controls
75 lines (60 loc) · 3.03 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
SHELL := /usr/bin/env bash
BINARY := volcano
PKG := github.com/Kong/volcano-cli
VERSION_PKG := $(PKG)/internal/version
CONFIG_PKG := $(PKG)/internal/config
VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo dev)
COMMIT ?= $(shell git rev-parse --short HEAD 2>/dev/null || echo none)
DATE ?= $(shell date -u +%Y-%m-%dT%H:%M:%SZ)
DEFAULT_API_URL ?= https://api.volcano.dev
DEFAULT_WEB_URL ?= https://volcano.dev
FIRST_PARTY_DEVICE_CLIENT_ID ?=
LDFLAGS := -s -w \
-X $(VERSION_PKG).Version=$(VERSION) \
-X $(VERSION_PKG).Commit=$(COMMIT) \
-X $(VERSION_PKG).Date=$(DATE) \
-X $(CONFIG_PKG).compiledDefaultAPIURL=$(DEFAULT_API_URL) \
-X $(CONFIG_PKG).compiledDefaultWebURL=$(DEFAULT_WEB_URL) \
-X $(CONFIG_PKG).compiledFirstPartyDeviceClientID=$(FIRST_PARTY_DEVICE_CLIENT_ID)
.PHONY: all build local test api-e2e-smoke api-e2e-cloud localmode-e2e lint tidy check clean help
all: build
build: ## Build the volcano binary into ./$(BINARY)
go build -ldflags '$(LDFLAGS)' -o $(BINARY) ./cmd/volcano
local: ## Build volcano using variables loaded from .env.local
@if [ ! -f .env.local ]; then \
echo ".env.local not found. Create one with VOLCANO_WEB_URL=... and VOLCANO_API_URL=..."; \
exit 1; \
fi; \
set -a; source .env.local; set +a; \
if [ -z "$${FIRST_PARTY_DEVICE_CLIENT_ID:-}" ] && [ -n "$${VOLCANO_FIRST_PARTY_DEVICE_CLIENT_ID:-}" ]; then \
export FIRST_PARTY_DEVICE_CLIENT_ID="$${VOLCANO_FIRST_PARTY_DEVICE_CLIENT_ID}"; \
fi; \
if [ -z "$${DEFAULT_API_URL:-}" ] && [ -n "$${VOLCANO_API_URL:-}" ]; then \
export DEFAULT_API_URL="$${VOLCANO_API_URL}"; \
fi; \
if [ -z "$${DEFAULT_WEB_URL:-}" ] && [ -n "$${VOLCANO_WEB_URL:-}" ]; then \
export DEFAULT_WEB_URL="$${VOLCANO_WEB_URL}"; \
fi; \
: "Fall back to the conventional local Volcano Web port (3000) when pointing at a loopback API without an explicit web URL"; \
if [ -z "$${DEFAULT_WEB_URL:-}" ] && [[ "$${VOLCANO_API_URL:-}" == http://localhost:* || "$${VOLCANO_API_URL:-}" == http://127.0.0.1:* ]]; then \
export DEFAULT_WEB_URL="http://localhost:3000"; \
fi; \
$(MAKE) build
test: ## Run unit tests
go test ./...
api-e2e-smoke: ## Run CLI API smoke tests against VOLCANO_API_URL and VOLCANO_MGMT_URL
VOLCANO_API_E2E=1 go test ./tests/e2e/api -run '^TestAPIE2ESmoke' -count=1 -timeout 45m
api-e2e-cloud: ## Run provisioning CLI API E2E tests against VOLCANO_API_URL and VOLCANO_MGMT_URL
VOLCANO_API_E2E=1 go test ./tests/e2e/api -run '^TestAPIE2E(Smoke|Cloud)' -count=1 -timeout 240m
localmode-e2e: ## Run destructive local-mode Docker smoke tests
VOLCANO_LOCALMODE_E2E=1 go test ./tests/e2e/localmode -run TestLocalModeE2ESmoke -count=1 -timeout 20m
lint: ## Run golangci-lint (includes gofmt, goimports, and go vet)
go tool golangci-lint run ./...
go tool golangci-lint fmt --diff ./...
tidy: ## Run go mod tidy
go mod tidy
check: lint test ## Run lint + test
clean: ## Remove build artifacts
rm -f $(BINARY)
help: ## Show this help
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf " %-14s %s\n", $$1, $$2}' $(MAKEFILE_LIST)