-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
43 lines (33 loc) · 1.32 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
.PHONY: build push run
IMAGE = quay.io/fortnox/go-import-redirector
# supply when running make: make all VERSION=1.0.0
#VERSION = 0.0.1
build:
CGO_ENABLED=0 GOOS=linux go build
docker: build
docker build --pull --rm -t $(IMAGE):$(VERSION) .
rm go-import-redirector
push:
docker push $(IMAGE):$(VERSION)
all: build docker push
run:
docker run -i --env-file=.env --rm -p 8080:8080 -t $(IMAGE):$(VERSION)
test: fmt
go test ./...
cover:
@echo Running coverage
go get github.com/wadey/gocovmerge
$(eval PKGS := $(shell go list ./... | grep -v /vendor/))
$(eval PKGS_DELIM := $(shell echo $(PKGS) | sed -e 's/ /,/g'))
go list -f '{{if or (len .TestGoFiles) (len .XTestGoFiles)}}go test -test.v -test.timeout=120s -covermode=count -coverprofile={{.Name}}_{{len .Imports}}_{{len .Deps}}.coverprofile -coverpkg $(PKGS_DELIM) {{.ImportPath}}{{end}}' $(PKGS) | xargs -I {} bash -c {}
gocovmerge `ls *.coverprofile` > cover.out
rm *.coverprofile
cover-html: cover
go tool cover -html cover.out
cover-test: cover
go get github.com/jonaz/gototcov
gototcov -f cover.out -limit 80 -ignore-zero
localrun:
bash -c "env `grep -Ev '^#' .env | xargs` go run *.go"
fmt:
bash -c "test -z $$(gofmt -l $$(find . -type f -name '*.go' -not -path './vendor/*') | tee /dev/stderr) || (echo 'Code not formatted correctly according to gofmt!' && exit 1)"