-
Notifications
You must be signed in to change notification settings - Fork 14
/
Makefile
46 lines (31 loc) · 1.42 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
.DEFAULT_GOAL := help
.PHONY: all clean goget env env-ip test do-test env-stop test do-cover cover build image help
NAME = workshop-go
VERSION = 1.0.0
all: build image
clean: ## Remover binário antigo
-@rm -f $(NAME); \
find vendor/* -maxdepth 0 -type d -exec rm -rf '{}' \;
goget: ## [tools] Baixar as dependências
go mod tidy
go mod vendor
env: ## Subir ambiente necessário para os testes
docker-compose up -d
env-ip: ## Visualizar o IP do container do MongoDB
echo $$(docker inspect -f '{{.NetworkSettings.Networks.workshopgo_default.IPAddress}}' workshopgo_mongodb_1)
do-test: ## Executar os testes
MONGO_URL=$$(docker inspect -f '{{.NetworkSettings.Networks.workshopgo_default.IPAddress}}' workshopgo_mongodb_1) go test $$(go list ./... | grep -v vendor)
env-stop: ## Finalizar ambiente necessário para os testes
docker-compose kill
docker-compose rm -f
test: env do-test env-stop ## [env do-test env-stop]
do-cover: ## Relatório de cobertura de testes
go get -u golang.org/x/tools/cmd/cover
./scripts/cover.sh
cover: env do-cover env-stop ## [env do-cover env-stop]
build: clean test ## [clean test] Construir o binário
CGO_ENABLED=0 go build -v -a -installsuffix cgo -o $(NAME) ./cmd/server
image: ## Construir a imagem Docker
docker build -t=$(NAME):$(VERSION) .
help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'