1
1
2
- GO_SRC := $(shell find . -type f -name " * .go" )
2
+ GO_SRC := $(shell find -type f -name ' * .go' ! -path ' * /vendor/ * ' )
3
3
4
4
CONTAINER_NAME ?= wrouesnel/postgres_exporter:latest
5
+ VERSION ?= $(shell git describe --dirty)
5
6
6
7
all : vet test postgres_exporter
7
8
@@ -10,24 +11,32 @@ cross: docker-build docker
10
11
11
12
# Simple go build
12
13
postgres_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 .
14
15
15
16
postgres_exporter_integration_test : $(GO_SRC )
16
17
CGO_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 .
18
19
19
20
# Take a go build and turn it into a minimal container
20
21
docker : postgres_exporter
21
22
docker build -t $(CONTAINER_NAME ) .
22
23
23
24
vet :
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 )
25
34
26
35
test :
27
- go test -v -cover .
36
+ go test -v -covermode count -coverprofile=cover.test.out
28
37
29
38
test-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 "
31
40
32
41
# Do a self-contained docker build - we pull the official upstream container
33
42
# and do a self-contained build.
0 commit comments