diff --git a/.promu.yml b/.promu.yml new file mode 100644 index 0000000..52e8b47 --- /dev/null +++ b/.promu.yml @@ -0,0 +1,42 @@ +repository: + path: github.com/cloudflare/alertmanager2es +build: + binaries: + - name: alertmanager2es + path: . + ldflags: | + -X {{repoPath}}/vendor/github.com/prometheus/common/version.Version={{.Version}} + -X {{repoPath}}/vendor/github.com/prometheus/common/version.Revision={{.Revision}} + -X {{repoPath}}/vendor/github.com/prometheus/common/version.Branch={{.Branch}} + -X {{repoPath}}/vendor/github.com/prometheus/common/version.BuildUser={{user}}@{{host}} + -X {{repoPath}}/vendor/github.com/prometheus/common/version.BuildDate={{date "20060102-15:04:05"}} + +tarball: + files: + - LICENSE +crossbuild: + platforms: + - linux/amd64 + - linux/386 + - darwin/amd64 + - darwin/386 + - windows/amd64 + - windows/386 + - freebsd/amd64 + - freebsd/386 + - openbsd/amd64 + - openbsd/386 + - netbsd/amd64 + - netbsd/386 + - dragonfly/amd64 + - linux/arm + - linux/arm64 + - freebsd/arm + # Temporarily deactivated as golang.org/x/sys does not have syscalls + # implemented for that os/platform combination. + #- openbsd/arm + #- linux/mips64 + #- linux/mips64le + - netbsd/arm + - linux/ppc64 + - linux/ppc64le diff --git a/.travis.yml b/.travis.yml index 8868756..255d6dc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,10 +1,13 @@ language: go go: - - 1.7.x - - 1.8.x - - master +- 1.7.x +- 1.8.x +- master matrix: allow_failures: - go: master + +script: +- make style test diff --git a/Makefile b/Makefile index 08fb0bd..47b833d 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,51 @@ -.PHONY: build test +GO := GO15VENDOREXPERIMENT=1 go +PROMU := $(GOPATH)/bin/promu +pkgs = $(shell $(GO) list ./... | grep -v -E '/vendor/') -build: test - go build -ldflags "-X main.revision=$(shell git describe --tags --always --dirty=-dev)" +PREFIX ?= $(shell pwd) +BIN_DIR ?= $(shell pwd) +DOCKER_IMAGE_NAME ?= alertmanager2es +DOCKER_IMAGE_TAG ?= $(subst /,-,$(shell git rev-parse --abbrev-ref HEAD)) + +ifdef DEBUG + bindata_flags = -debug +endif + + +all: format build test test: - go test $(go list ./... | grep -v /vendor/) + @echo ">> running tests" + @$(GO) test -race -short $(pkgs) + +style: + @echo ">> checking code style" + @! gofmt -d $(shell find . -path ./vendor -prune -o -name '*.go' -print) | grep '^' + +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 assets tarball docker promu proto diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..4e379d2 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +0.0.2