11
2- GO_SRC := $(shell find . -type f -name " * .go" )
2+ GO_SRC := $(shell find -type f -name ' * .go' ! -path ' * /vendor/ * ' )
33
44CONTAINER_NAME ?= wrouesnel/postgres_exporter:latest
5+ VERSION ?= $(shell git describe --dirty)
56
67all : vet test postgres_exporter
78
@@ -10,24 +11,32 @@ cross: docker-build docker
1011
1112# Simple go build
1213postgres_exporter : $(GO_SRC )
13- CGO_ENABLED=0 go build -a -ldflags " -extldflags '-static' -X main.Version=$( shell git describe --dirty ) " -o postgres_exporter .
14+ CGO_ENABLED=0 go build -a -ldflags " -extldflags '-static' -X main.Version=$( VERSION ) " -o postgres_exporter .
1415
1516postgres_exporter_integration_test : $(GO_SRC )
1617CGO_ENABLED=0 go test -c -tags integration \
17- -a -ldflags " -extldflags '-static' -X main.Version=git: $( shell git describe --dirty ) " -o postgres_exporter_integration_test .
18+ -a -ldflags " -extldflags '-static' -X main.Version=$( VERSION ) " -o postgres_exporter_integration_test -cover -covermode count .
1819
1920# Take a go build and turn it into a minimal container
2021docker : postgres_exporter
2122docker build -t $(CONTAINER_NAME ) .
2223
2324vet :
24- go vet .
25+ go vet
26+
27+ # Check code conforms to go fmt
28+ style :
29+ ! gofmt -s -l $(GO_SRC ) 2>&1 | read 2> /dev/null
30+
31+ # Format the code
32+ fmt :
33+ gofmt -s -w $(GO_SRC )
2534
2635test :
27- go test -v -cover .
36+ go test -v -covermode count -coverprofile=cover.test.out
2837
2938test-integration : postgres_exporter postgres_exporter_integration_test
30- tests/test-smoke . /postgres_exporter ./ postgres_exporter_integration_test
39+ tests/test-smoke " $( shell pwd ) /postgres_exporter" " $( shell pwd ) /postgres_exporter_integration_test_script $( shell pwd ) / postgres_exporter_integration_test $( shell pwd ) /cover.integration.out "
3140
3241# Do a self-contained docker build - we pull the official upstream container
3342# and do a self-contained build.
0 commit comments