-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
70 lines (52 loc) · 2.14 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
BINPATH ?= build
BUILD_TIME=$(shell date +%s)
GIT_COMMIT=$(shell git rev-parse HEAD)
VERSION ?= $(shell git tag --points-at HEAD | grep ^v | head -n 1)
LDFLAGS = -ldflags "-X main.BuildTime=$(BUILD_TIME) -X main.GitCommit=$(GIT_COMMIT) -X main.Version=$(VERSION)"
.PHONY: all
all: audit test build ## run audit, test and build
.PHONY: audit
audit: ## run nancy auditor
go list -json -m all | nancy sleuth
.PHONY: lint
lint:
golangci-lint run ./... --tests=false
.PHONY: build
build:
go build -tags 'production' $(LDFLAGS) -o $(BINPATH)/dp-cantabular-metadata-extractor-api
.PHONY: debug
debug: ## run poc service in debug mode
go build -tags 'debug' $(LDFLAGS) -o $(BINPATH)/dp-cantabular-metadata-extractor-api
HUMAN_LOG=1 DEBUG=1 $(BINPATH)/dp-cantabular-metadata-extractor-api
.PHONY: test
test: ## run tests -race
go test -race -cover ./...
.PHONY: test-nocache
test-nocache: ## run tests no cache, no race, no cover
go test -count=1 ./...
.PHONY: convey
convey: ## run goconvey
goconvey ./...
.PHONY: test-component
test-component:
go test -cover -coverpkg=github.com/ONSdigital/dp-cantabular-metadata-extractor-api/... -component
.PHONY: generate
generate: ## update autogenerated files
@go install github.com/matryer/[email protected]
@go generate service/interfaces.go
@go generate api/api.go
.PHONY: test-int
test-int: ## integration tests needs cantabular docker running
go test -v -count 1 ./metadata -args -int
.PHONY: cover
cover: ## aggregate coverage hat tip @efragkiadaki
go test -count=1 -coverprofile=coverage.out ./...
@awk 'BEGIN {cov=0; stat=0;} $$3!="" { cov+=($$3==1?$$2:0); stat+=$$2; } END {printf("Total coverage: %.2f%% of statements\n", (cov/stat)*100);}' coverage.out
@go tool cover -html=coverage.out
.PHONY: check-generate
check-generate: generate ## check no manual commits to auto-generated files on a clean tree
@[ "$$(git diff)" = "" ] || (echo "commits to autogen file?" && exit 1)
# stolen from https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
.PHONY: help
help: ## This help
@awk 'BEGIN {FS = ":.*?## "} /^[a-z0-9A-Z_-]+:.*?## / {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)