forked from honeydipper/honeydipper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
73 lines (59 loc) · 1.89 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
SHELL := /bin/sh
BOLD := \033[1m
DIM := \033[2m
RESET := \033[0m
files_require_mocking = internal/workflow/session.go \
internal/workflow/store.go \
pkg/dipper/rpc.go \
internal/api/request_context.go \
drivers/cmd/gcloud-secret/main.go \
drivers/cmd/datadog-emitter/statsd.go
ifneq (,$(wildcard ./.env))
include ./.env
export
endif
.PHONY: build lint run_mockgen unit-tests integration-tests test all clean run
build:
@printf "$(BOLD)Buiding$(RESET)\n"
@go install ./...
lint:
@printf "$(BOLD)Linting source code$(RESET)\n"
@golangci-lint run
.mockgen_installed:
@printf "$(BOLD)Installing mockgen$(RESET)\n"
@go install github.com/golang/mock/mockgen@v1.6.0
@touch "$@"
.mockgen_files_generated: $(files_require_mocking)
@for f in $?; do \
basedir=`dirname $$f`; \
mockdir="$$basedir"/mock_`basename $$basedir`; \
mockfile="$$mockdir"/`basename $$f`; \
mkdir -p "$$mockdir"; \
printf "$(BOLD)Generating $$mockfile $(RESET)\n"; \
mockgen -copyright_file=COPYRIGHT -source="$$f" -destination="$$mockfile"; \
done
@touch "$@"
run_mockgen: .mockgen_installed .mockgen_files_generated
unit-tests:
@printf "$(BOLD)Running unit tests$(RESET)\n"
ifneq (,$(REPORT_TEST_COVERAGE))
@go test -coverprofile=c.out ./...
else
@go test ./...
endif
integration-tests:
@printf "$(BOLD)Running integration tests$(RESET)\n"
@go test -tags=integration ./cmd/honeydipper
test: unit-tests integration-tests
all: lint test build
clean:
@for f in $(files_require_mocking); do \
basedir=`dirname $$f`; \
mockdir="$$basedir"/mock_`basename $$basedir`; \
[[ -d "$$mockdir" ]] && rm -rf "$$mockdir" || true; \
done
@[[ -f ".mockgen_files_generated" ]] && rm -f .mockgen_files_generated || true
@[[ -f ".mockgen_installed" ]] && rm -f .mockgen_installed || true
run: build
@printf "$(BOLD)Starting the daemon$(RESET)\n"
@REPO=$${REPO:-$${REPO_DIR}} $$(go env GOPATH)/bin/honeydipper