Skip to content

Commit

Permalink
Update build
Browse files Browse the repository at this point in the history
* Fix use of `prometheus` to use `promhttp`.
* Enable `vet` and `staticcheck` in build.
* Update to Go 1.8.x.
  • Loading branch information
SuperQ authored and brian-brazil committed Jul 26, 2017
1 parent 8c0f3a3 commit 4d30f92
Show file tree
Hide file tree
Showing 6 changed files with 239 additions and 13 deletions.
6 changes: 4 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ sudo: false
language: go

go:
- 1.5.4
- 1.6.2
- 1.8.x
- master

go_import_path: github.com/prometheus/influxdb_exporter

script:
- make
33 changes: 23 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,19 @@
# limitations under the License.

GO := GO15VENDOREXPERIMENT=1 go
PROMU := $(GOPATH)/bin/promu
pkgs = $(shell $(GO) list ./... | grep -v /vendor/)
GOPATH := $(firstword $(subst :, ,$(shell $(GO) env GOPATH)))

PROMU ?= $(GOPATH)/bin/promu
STATICCHECK ?= $(GOPATH)/bin/staticcheck
pkgs = $(shell $(GO) list ./... | grep -v /vendor/)

PREFIX ?= $(shell pwd)
BIN_DIR ?= $(shell pwd)
DOCKER_IMAGE_NAME ?= influxdb-exporter
DOCKER_IMAGE_TAG ?= $(subst /,-,$(shell git rev-parse --abbrev-ref HEAD))


all: format build test
all: format vet staticcheck build test

style:
@echo ">> checking code style"
Expand All @@ -39,22 +42,32 @@ vet:
@echo ">> vetting code"
@$(GO) vet $(pkgs)

build: promu
staticcheck: $(STATICCHECK)
@echo ">> running staticcheck"
@$(STATICCHECK) $(pkgs)

build: $(PROMU)
@echo ">> building binaries"
@$(PROMU) build --prefix $(PREFIX)

tarball: promu
tarball: $(PROMU)
@echo ">> building release tarball"
@$(PROMU) tarball --prefix $(PREFIX) $(BIN_DIR)

docker:
@echo ">> building docker image"
@docker build -t "$(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_TAG)" .

promu:
@GOOS=$(shell uname -s | tr A-Z a-z) \
GOARCH=$(subst x86_64,amd64,$(patsubst i%86,386,$(shell uname -m))) \
$(GO) get -u github.com/prometheus/promu
$(GOPATH)/bin/promu promu:
@GOOS= GOARCH= $(GO) get -u github.com/prometheus/promu

$(GOPATH)/bin/staticcheck:
@GOOS= GOARCH= $(GO) get -u honnef.co/go/tools/cmd/staticcheck

.PHONY: all style format build test vet tarball docker promu staticcheck

.PHONY: all style format build test vet tarball docker promu
# Declaring the binaries at their default locations as PHONY targets is a hack
# to ensure the latest version is downloaded on every make execution.
# If this is not desired, copy/symlink these binaries to a different path and
# set the respective environment variables.
.PHONY: $(GOPATH)/bin/promu $(GOPATH)/bin/staticcheck
1 change: 1 addition & 0 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ deployment:
owner: prometheus
commands:
- promu crossbuild tarballs
- promu checksum .tarballs
- promu release .tarballs
- mkdir $CIRCLE_ARTIFACTS/releases/ && cp -a .tarballs/* $CIRCLE_ARTIFACTS/releases/
- docker login -e $DOCKER_EMAIL -u $DOCKER_LOGIN -p $DOCKER_PASSWORD
Expand Down
3 changes: 2 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"time"

"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/prometheus/common/log"
"github.com/prometheus/common/version"

Expand Down Expand Up @@ -281,7 +282,7 @@ func main() {
fmt.Fprintf(w, `{"results": []}`)
})

http.Handle(*metricsPath, prometheus.Handler())
http.Handle(*metricsPath, promhttp.Handler())

http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte(`<html>
Expand Down
201 changes: 201 additions & 0 deletions vendor/github.com/prometheus/client_golang/prometheus/promhttp/http.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions vendor/vendor.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@
"version": "v0.8.0",
"versionExact": "v0.8.0"
},
{
"checksumSHA1": "lG3//eDlwqA4IOuAPrNtLh9G0TA=",
"path": "github.com/prometheus/client_golang/prometheus/promhttp",
"revision": "c5b7fccd204277076155f10851dad72b76a49317",
"revisionTime": "2016-08-17T15:48:24Z",
"version": "v0.8.0",
"versionExact": "v0.8.0"
},
{
"checksumSHA1": "DvwvOlPNAgRntBzt3b3OSRMS2N4=",
"path": "github.com/prometheus/client_model/go",
Expand Down

0 comments on commit 4d30f92

Please sign in to comment.