-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMakefile
More file actions
48 lines (37 loc) · 1.54 KB
/
Copy pathMakefile
File metadata and controls
48 lines (37 loc) · 1.54 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
.PHONY: build push run
IMAGE = quay.io/fortnox/opensearch-csv-exporter
# supply when running make: make all VERSION=1.0.0
#VERSION = 0.0.1
build:
CGO_ENABLED=0 GOOS=linux go build ./cmd/opensearch-csv-exporter/
docker: build
docker build --pull --rm -t $(IMAGE):$(VERSION) .
rm opensearch-csv-exporter
push:
docker push $(IMAGE):$(VERSION)
all: build docker push
run:
docker run -i --env-file=.env --rm -p 8080:8080 -t $(IMAGE):$(VERSION)
test: imports
go test ./...
cover:
@echo Running coverage
go install 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 install github.com/jonaz/gototcov
gototcov -f cover.out -limit 80 -ignore-zero
localrun:
bash -c "env `grep -Ev '^#' .env | xargs` go run ./cmd/opensearch-csv-exporter"
# To format your files according to goimports you can run: `goimports -w .`
# or setup your ide to do it for you
imports: SHELL:=/bin/bash
imports:
go install golang.org/x/tools/cmd/goimports@latest
ASD=$$(goimports -l . 2>&1); test -z "$$ASD" || (echo "Code is not formatted correctly according to goimports! $$ASD" && exit 1)