-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
71 lines (54 loc) · 1.62 KB
/
Makefile
File metadata and controls
71 lines (54 loc) · 1.62 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
APP_NAME = bunny
APP_VSN ?= $(shell git rev-parse --short HEAD)
.PHONY: help
help: #: Show this help message
@echo "$(APP_NAME):$(APP_VSN)"
@awk '/^[A-Za-z_ -]*:.*#:/ {printf("%c[1;32m%-15s%c[0m", 27, $$1, 27); for(i=3; i<=NF; i++) { printf("%s ", $$i); } printf("\n"); }' Makefile* | sort
CGO_ENABLED ?= 0
GO = CGO_ENABLED=$(CGO_ENABLED) go
GO_BUILD_FLAGS = -ldflags "-X main.Version=${APP_VSN}"
#---------#
# - Dev - #
#---------#
.PHONY: code-check
code-check: #: Run the linter
golangci-lint run
.PHONY: generate
generate: ## Run generate for non-vendor packages only
go list ./... | xargs go generate
go fmt ./fakes/...
#-----------#
# - Build - #
#-----------#
.PHONY: build
build: #: Build the app locally
build: clean
$(GO) build $(GO_BUILD_FLAGS) -o ./$(APP_NAME)
.PHONY: clean
clean: #: Clean up build artifacts
clean:
$(RM) ./$(APP_NAME)
#----------#
# - Test - #
#----------#
TEST_PACKAGES := $(shell go list ./... | grep -v mocks | grep -v fakes )
.PHONY: test
test: #: Run Go unit tests
test:
GO111MODULE=on $(GO) test $(TEST_PACKAGES) -coverprofile=coverage.out
.PHONY: testv
testv: #: Run Go unit tests verbose
testv:
GO111MODULE=on $(GO) test -v $(TEST_PACKAGES) -coverprofile=coverage.out
.PHONY: cover
cover: #: Open coverage report in a browser
go test $(TEST_PACKAGES) -coverprofile=coverage.out && go tool cover -html=coverage.out
#------------#
# - Docker - #
#------------#
.PHONY: run-infra
run-infra: #: Run the infrastructure we use to test/develop the app
@./ci/scripts/start-deps.sh
.PHONY: stop-infra
stop-infra: #: Stop the infrastructure we started
@docker-compose --file ./ci/docker-compose.yml stop