forked from digitalocean/firebolt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
66 lines (51 loc) · 2.01 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
GIT_HASH = $(shell git describe --tags --dirty --always)
FIREBOLT_SRCS := $(shell find . -type f -iname '*.go' -not -path './pkg/*')
.PHONY: all docker push clean format lint test inttest cover
###
# phony targets
all: test
clean:
@echo ">> Removing bin directory"
@rm -rf bin
@echo ">> Removing pkg/mod directory"
@rm -rf pkg/mod
@echo ">> Removing .makecache directory"
@rm -rf .makecache
format:
@go fmt
@go get golang.org/x/tools/cmd/goimports
@goimports -w $$(find . -name '*.go' | grep -v 'mock_*')
lint: .makecache .makecache/lint
test: lint .makecache/test
inttest: lint .makecache/inttest
cover: inttest .makecache/cover
###
# real targets
.makecache:
@echo ">> Making directory $@"
@mkdir $@
.makecache/lint: $(FIREBOLT_SRCS)
@go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.50.1
@golangci-lint run --no-config --disable-all -E gosec -E vet -E unused -E gocyclo -E revive -E dupl -E ineffassign -E unconvert -E nakedret -E gofmt -E unparam -E prealloc ./...
# Unit Tests only
.makecache/test: $(FIREBOLT_SRCS)
@echo ">> Running tests"
@go vet ./...
@go test -race ./... --coverprofile=coverage.out
@touch $@
# Unit and Integration Tests
.makecache/inttest: $(FIREBOLT_SRCS)
@echo ">> Running integration tests"
@docker-compose -f ./inttest/docker-compose.yml down -v
@docker-compose -f ./inttest/docker-compose.yml up -d --force-recreate
@go test -p 1 ./... -tags=integration -coverpkg=./... -coverprofile=coverage.out
@docker-compose -f ./inttest/docker-compose.yml down -v
@touch $@
# Generate coverage report and an updated coverage badge
# Note that some non-production patterns like mocks are excluded by filtering them out of the coverage file with 'grep'
.makecache/cover: $(FIREBOLT_SRCS)
@echo ">> Computing test coverage"
@go install github.com/jpoles1/gopherbadger@1f4eedb7a3f6f2897d66f0aed24a5cc272a202a6
@grep -Ev '/mock_|/internal|/inttest|/examples|/testutil' coverage.out > coverage-nomocks.out
@gopherbadger -covercmd "go tool cover -func=coverage-nomocks.out"
@touch $@