-
Notifications
You must be signed in to change notification settings - Fork 741
Expand file tree
/
Copy pathMakefile
More file actions
43 lines (35 loc) · 1.2 KB
/
Makefile
File metadata and controls
43 lines (35 loc) · 1.2 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
.PHONY: fmt
fmt: ## Run go fmt against code.
go fmt ./...
.PHONY: vet
vet: ## Run go vet against code.
go mod tidy && go mod vendor
go vet ./...
.PHONY: test
test: vet ## Run tests
go test -v -coverpkg=./... ./pkg/...
##@ Linter
.PHONY: install-golint
install-golint:
@if ! command -v golangci-lint &> /dev/null; then \
echo "installing golangci-lint..."; \
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest; \
else \
echo "golangci-lint already installed"; \
fi
.PHONY: golint
golint: fmt install-golint
golangci-lint run -v --fix ./...
VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
GIT_COMMIT ?= $(shell git rev-parse HEAD 2>/dev/null || echo "unknown")
BUILD_TIME ?= $(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
LDFLAGS := -X 'github.com/alibaba/opensandbox/internal/version.Version=$(VERSION)' \
-X 'github.com/alibaba/opensandbox/internal/version.BuildTime=$(BUILD_TIME)' \
-X 'github.com/alibaba/opensandbox/internal/version.GitCommit=$(GIT_COMMIT)'
.PHONY: build
build: vet ## Build the binary.
@mkdir -p bin
go build -ldflags "$(LDFLAGS)" -o bin/router main.go
.PHONY: clean
clean: ## Clean build artifacts.
rm -rf bin/ vendor/