-
Notifications
You must be signed in to change notification settings - Fork 7
/
Makefile
76 lines (58 loc) · 2.65 KB
/
Makefile
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
GOBIN ?= $(shell go env GOPATH)/bin
BINARY_NAME ?= spinup
VERSION ?= dev-unknown
DOCKER_NETWORK ?= "spinup_services"
SPINUP_BUILD_TAGS = -ldflags " \
-X 'github.com/spinup-host/spinup/build.Version=$(VERSION)' \
-X 'github.com/spinup-host/spinup/build.FullCommit=$(shell git rev-parse HEAD)' \
-X 'github.com/spinup-host/spinup/build.Branch=$(shell git symbolic-ref --short HEAD)' \
"
GREEN := $(shell tput -Txterm setaf 2)
YELLOW := $(shell tput -Txterm setaf 3)
WHITE := $(shell tput -Txterm setaf 7)
CYAN := $(shell tput -Txterm setaf 6)
RESET := $(shell tput -Txterm sgr0)
.PHONY: all test build
all: help
build: ## Build your project and put the output binary in out/bin/
go build $(SPINUP_BUILD_TAGS) -o bin/$(BINARY_NAME) .
clean: ## Remove build related file
rm -fr ./bin
test: ## Run the tests of the project
go test -v ./... $(OUTPUT_OPTIONS)
test-coverage: ## Run the tests of the project and export the coverage
go test -cover -covermode=count -coverprofile=profile.cov ./...
go tool cover -func profile.cov
format:
goimports -local "github.com/spinup-host/spinup" -l -w ./
for f in $(git status -s | cut -f3 -d' '); do go fmt "$f"; done
gci write --section Standard --section Default --section "Prefix(github.com/spinup-host/spinup)" .
install-deps:
go mod download
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.45.2
go install github.com/vektra/mockery/v2@v2.14.0
go install github.com/daixiang0/gci@v0.4.2
go install github.com/go-swagger/go-swagger/cmd/swagger@v0.29.0
@echo 'Dev dependencies have been installed. Run "export PATH=$$PATH/$$(go env GOPATH)/bin" to use installed binaries.'
run-api:
go run main.go start --api-only
checks: ## Run all available checks and linters
# golangci-lint run --enable-all # disable golangci-lint for now as it can get annoying
docs: ## Generate OpenAPI docs
swagger generate spec -o openapi/swagger.yaml --scan-models --exclude-deps
serve-docs:
swagger serve -F=swagger openapi/swagger.yaml
stop-services: ## Removes all running containers in the Spinup network
docker stop $(shell docker container ls --filter="network=${DOCKER_NETWORK}" -q --all)
remove-services: ## Removes all running containers in the Spinup network
docker rm $(shell docker container ls --filter="network=${DOCKER_NETWORK}" -q --all)
help: ## Show make commands help.
@echo ''
@echo 'Usage:'
@echo ' ${YELLOW}make${RESET} ${GREEN}<target>${RESET}'
@echo ''
@echo 'Targets:'
@awk 'BEGIN {FS = ":.*?## "} { \
if (/^[a-zA-Z_-]+:.*?##.*$$/) {printf " ${YELLOW}%-20s${GREEN}%s${RESET}\n", $$1, $$2} \
else if (/^## .*$$/) {printf " ${CYAN}%s${RESET}\n", substr($$1,4)} \
}' $(MAKEFILE_LIST)