From cdeb0c9743fdc18135bed1e8c8991c4a4a35242d Mon Sep 17 00:00:00 2001 From: Johannes 'fish' Ziemke Date: Sun, 24 Jan 2016 23:38:06 +0100 Subject: [PATCH] Use promu/docker/circleci based release process --- .dockerignore | 4 ++++ .gitignore | 8 ++++--- .promu.yml | 12 ++++++++++ .travis.yml | 10 +++++++++ Dockerfile | 5 ++++- Makefile | 49 ++++++++++++++++++++++++++++++++++++++--- README.md | 13 +++++++++-- VERSION | 1 + circle.yml | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++ 9 files changed, 154 insertions(+), 9 deletions(-) create mode 100644 .dockerignore create mode 100644 .promu.yml create mode 100644 .travis.yml create mode 100644 VERSION create mode 100644 circle.yml diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..1694cb0 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,4 @@ +.build/ +.tarballs/ + +!.build/linux-amd64 diff --git a/.gitignore b/.gitignore index 26bcd4e..e06c0a0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ -.build/ dependencies-stamp -*.tar.gz -statsd_exporter +/statsd_exporter +/.build +/.deps +/.release +/.tarballs diff --git a/.promu.yml b/.promu.yml new file mode 100644 index 0000000..256230f --- /dev/null +++ b/.promu.yml @@ -0,0 +1,12 @@ +go: 1.6.2 +repository: + path: github.com/prometheus/statsd_exporter +build: + flags: -a -tags 'netgo static_build' + ldflags: | + -X main.Version={{.Version}} + +tarball: + files: + - LICENSE + - NOTICE diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..a24774e --- /dev/null +++ b/.travis.yml @@ -0,0 +1,10 @@ +sudo: false + +language: go +go: +- 1.6.2 +- 1.5.4 +- tip + +script: +- make diff --git a/Dockerfile b/Dockerfile index 8891393..53da117 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,7 @@ -FROM sdurrheimer/alpine-golang-make-onbuild +FROM quay.io/prometheus/busybox:latest MAINTAINER The Prometheus Authors +COPY statsd_exporter /bin/statsd_exporter + EXPOSE 9102 9125/udp +ENTRYPOINT [ "/bin/statsd_exporter" ] diff --git a/Makefile b/Makefile index 97d0bea..163fe77 100644 --- a/Makefile +++ b/Makefile @@ -11,7 +11,50 @@ # See the License for the specific language governing permissions and # limitations under the License. -VERSION := 0.2.0 -TARGET := statsd_exporter +GO := GO15VENDOREXPERIMENT=1 go +PROMU := $(GOPATH)/bin/promu +pkgs = $(shell $(GO) list ./... | grep -v /vendor/) -include Makefile.COMMON +PREFIX ?= $(shell pwd) +BIN_DIR ?= $(shell pwd) +DOCKER_IMAGE_NAME ?= statsd-exporter +DOCKER_IMAGE_TAG ?= $(subst /,-,$(shell git rev-parse --abbrev-ref HEAD)) + + +all: format build test + +style: + @echo ">> checking code style" + @! gofmt -d $(shell find . -path ./vendor -prune -o -name '*.go' -print) | grep '^' + +test: + @echo ">> running tests" + @$(GO) test -short $(pkgs) + +format: + @echo ">> formatting code" + @$(GO) fmt $(pkgs) + +vet: + @echo ">> vetting code" + @$(GO) vet $(pkgs) + +build: promu + @echo ">> building binaries" + @$(PROMU) build --prefix $(PREFIX) + +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 + + +.PHONY: all style format build test vet tarball docker promu diff --git a/README.md b/README.md index ba4c3c7..710bc73 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,8 @@ -statsd_exporter -============= +# statsd exporter [![Build Status](https://travis-ci.org/prometheus/statsd_exporter.svg)][travis] + +[![CircleCI](https://circleci.com/gh/prometheus/statsd_exporter/tree/master.svg?style=shield)][circleci] +[![Docker Repository on Quay](https://quay.io/repository/prometheus/statsd-exporter/status)][quay] +[![Docker Pulls](https://img.shields.io/docker/pulls/prom/statsd-exporter.svg)][hub] `statsd_exporter` receives StatsD-style metrics and exports them as Prometheus metrics. @@ -123,3 +126,9 @@ docker run -d -p 9102:9102 -p 9125:9125/udp \ -v $PWD/statsd_mapping.conf:/tmp/statsd_mapping.conf \ prom/statsd-exporter -statsd.mapping-config=/tmp/statsd_mapping.conf ``` + + +[travis]: https://travis-ci.org/prometheus/statsd_exporter +[circleci]: https://circleci.com/gh/prometheus/statsd_exporter +[quay]: https://quay.io/repository/prometheus/statsd-exporter +[hub]: https://hub.docker.com/r/prom/statsd-exporter/ diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..0ea3a94 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +0.2.0 diff --git a/circle.yml b/circle.yml new file mode 100644 index 0000000..40bfbd5 --- /dev/null +++ b/circle.yml @@ -0,0 +1,61 @@ +machine: + environment: + DOCKER_IMAGE_NAME: prom/statsd-exporter + QUAY_IMAGE_NAME: quay.io/prometheus/statsd-exporter + DOCKER_TEST_IMAGE_NAME: quay.io/prometheus/golang-builder:1.5.4-main + REPO_PATH: github.com/prometheus/statsd_exporter + pre: + - sudo curl -L -o /usr/bin/docker 'https://s3-external-1.amazonaws.com/circle-downloads/docker-1.9.1-circleci' + - sudo chmod 0755 /usr/bin/docker + - sudo curl -L 'https://github.com/aktau/github-release/releases/download/v0.6.2/linux-amd64-github-release.tar.bz2' | tar xvjf - --strip-components 3 -C $HOME/bin + services: + - docker + +dependencies: + pre: + - go get -u github.com/prometheus/promu + - docker info + override: + - promu crossbuild + - ln -s .build/linux-amd64/statsd_exporter statsd_exporter + - | + if [ -n "$CIRCLE_TAG" ]; then + make docker DOCKER_IMAGE_NAME=$DOCKER_IMAGE_NAME DOCKER_IMAGE_TAG=$CIRCLE_TAG + make docker DOCKER_IMAGE_NAME=$QUAY_IMAGE_NAME DOCKER_IMAGE_TAG=$CIRCLE_TAG + else + make docker DOCKER_IMAGE_NAME=$DOCKER_IMAGE_NAME + make docker DOCKER_IMAGE_NAME=$QUAY_IMAGE_NAME + fi + post: + - mkdir $CIRCLE_ARTIFACTS/binaries/ && cp -a .build/* $CIRCLE_ARTIFACTS/binaries/ + - docker images + +test: + override: + - docker run --rm -t -v "$(pwd):/app" "${DOCKER_TEST_IMAGE_NAME}" -i "${REPO_PATH}" -T + +deployment: + hub_branch: + branch: master + owner: prometheus + commands: + - docker login -e $DOCKER_EMAIL -u $DOCKER_LOGIN -p $DOCKER_PASSWORD + - docker login -e $QUAY_EMAIL -u $QUAY_LOGIN -p $QUAY_PASSWORD quay.io + - docker push $DOCKER_IMAGE_NAME + - docker push $QUAY_IMAGE_NAME + hub_tag: + tag: /^[0-9]+(\.[0-9]+){2}(-.+|[^-.]*)$/ + owner: prometheus + commands: + - promu crossbuild 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 + - docker login -e $QUAY_EMAIL -u $QUAY_LOGIN -p $QUAY_PASSWORD quay.io + - | + if [[ "$CIRCLE_TAG" =~ ^[0-9]+(\.[0-9]+){2}$ ]]; then + docker tag "$DOCKER_IMAGE_NAME:$CIRCLE_TAG" "$DOCKER_IMAGE_NAME:latest" + docker tag "$QUAY_IMAGE_NAME:$CIRCLE_TAG" "$QUAY_IMAGE_NAME:latest" + fi + - docker push $DOCKER_IMAGE_NAME + - docker push $QUAY_IMAGE_NAME