Add coverage and code quality badges.
This commit is contained in:
21
Makefile
21
Makefile
@@ -1,7 +1,8 @@
|
||||
|
||||
GO_SRC := $(shell find . -type f -name "*.go")
|
||||
GO_SRC := $(shell find -type f -name '*.go' ! -path '*/vendor/*')
|
||||
|
||||
CONTAINER_NAME ?= wrouesnel/postgres_exporter:latest
|
||||
VERSION ?= $(shell git describe --dirty)
|
||||
|
||||
all: vet test postgres_exporter
|
||||
|
||||
@@ -10,24 +11,32 @@ cross: docker-build docker
|
||||
|
||||
# Simple go build
|
||||
postgres_exporter: $(GO_SRC)
|
||||
CGO_ENABLED=0 go build -a -ldflags "-extldflags '-static' -X main.Version=$(shell git describe --dirty)" -o postgres_exporter .
|
||||
CGO_ENABLED=0 go build -a -ldflags "-extldflags '-static' -X main.Version=$(VERSION)" -o postgres_exporter .
|
||||
|
||||
postgres_exporter_integration_test: $(GO_SRC)
|
||||
CGO_ENABLED=0 go test -c -tags integration \
|
||||
-a -ldflags "-extldflags '-static' -X main.Version=git:$(shell git describe --dirty)" -o postgres_exporter_integration_test .
|
||||
-a -ldflags "-extldflags '-static' -X main.Version=$(VERSION)" -o postgres_exporter_integration_test -cover -covermode count .
|
||||
|
||||
# Take a go build and turn it into a minimal container
|
||||
docker: postgres_exporter
|
||||
docker build -t $(CONTAINER_NAME) .
|
||||
|
||||
vet:
|
||||
go vet .
|
||||
go vet
|
||||
|
||||
# Check code conforms to go fmt
|
||||
style:
|
||||
! gofmt -s -l $(GO_SRC) 2>&1 | read 2>/dev/null
|
||||
|
||||
# Format the code
|
||||
fmt:
|
||||
gofmt -s -w $(GO_SRC)
|
||||
|
||||
test:
|
||||
go test -v -cover .
|
||||
go test -v -covermode count -coverprofile=cover.test.out
|
||||
|
||||
test-integration: postgres_exporter postgres_exporter_integration_test
|
||||
tests/test-smoke ./postgres_exporter ./postgres_exporter_integration_test
|
||||
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"
|
||||
|
||||
# Do a self-contained docker build - we pull the official upstream container
|
||||
# and do a self-contained build.
|
||||
|
||||
Reference in New Issue
Block a user