Skip to content

Commit 48cae9d

Browse files
author
Camilo Aguilar
committed
Removes cruft and simplifies Makefile
1 parent 81194c9 commit 48cae9d

File tree

719 files changed

+44
-278176
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

719 files changed

+44
-278176
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
.build
2+
build
3+
dist
24
postgres_exporter
35
postgres_exporter_integration_test
46
*.tar.gz

Makefile

Lines changed: 42 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,45 @@
1-
2-
COVERDIR = .coverage
3-
TOOLDIR = tools
4-
5-
GO_SRC := $(shell find . -name '*.go' ! -path '*/vendor/*' ! -path 'tools/*' )
6-
GO_DIRS := $(shell find . -type d -name '*.go' ! -path '*/vendor/*' ! -path 'tools/*' )
7-
GO_PKGS := $(shell go list ./... | grep -v '/vendor/')
8-
9-
CONTAINER_NAME ?= wrouesnel/postgres_exporter:latest
10-
VERSION ?= $(shell git describe --dirty)
11-
12-
CONCURRENT_LINTERS ?= $(shell cat /proc/cpuinfo | grep processor | wc -l)
13-
LINTER_DEADLINE ?= 30s
14-
15-
export PATH := $(TOOLDIR)/bin:$(PATH)
16-
SHELL := env PATH=$(PATH) /bin/bash
17-
18-
all: style lint test postgres_exporter
19-
20-
# Cross compilation (e.g. if you are on a Mac)
21-
cross: docker-build docker
22-
23-
# Simple go build
24-
postgres_exporter: $(GO_SRC)
25-
CGO_ENABLED=0 go build -a -ldflags "-extldflags '-static' -X main.Version=$(VERSION)" -o postgres_exporter .
26-
27-
postgres_exporter_integration_test: $(GO_SRC)
28-
CGO_ENABLED=0 go test -c -tags integration \
29-
-a -ldflags "-extldflags '-static' -X main.Version=$(VERSION)" -o postgres_exporter_integration_test -cover -covermode count .
30-
31-
# Take a go build and turn it into a minimal container
32-
docker: postgres_exporter
33-
docker build -t $(CONTAINER_NAME) .
34-
35-
style: tools
36-
gometalinter --disable-all --enable=gofmt --vendor
37-
38-
lint: tools
39-
@echo Using $(CONCURRENT_LINTERS) processes
40-
gometalinter -j $(CONCURRENT_LINTERS) --deadline=$(LINTER_DEADLINE) --disable=gotype --disable=gocyclo $(GO_DIRS)
41-
42-
fmt: tools
43-
gofmt -s -w $(GO_SRC)
44-
45-
test: tools
46-
@mkdir -p $(COVERDIR)
47-
@rm -f $(COVERDIR)/*
48-
for pkg in $(GO_PKGS) ; do \
49-
go test -v -covermode count -coverprofile=$(COVERDIR)/$$(echo $$pkg | tr '/' '-').out $$pkg ; \
1+
NAME := postgres-exporter
2+
VERSION := v0.2.2
3+
4+
help: ## Shows this help text
5+
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
6+
7+
dev: ## Builds dev binary
8+
go build -ldflags "-X main.Version=$(VERSION)"
9+
10+
build: ## Builds binary for all supported platforms
11+
@rm -rf build/
12+
@gox -ldflags "-X main.Version=$(VERSION)" \
13+
-osarch="darwin/amd64" \
14+
-os="linux" \
15+
-os="windows" \
16+
-os="solaris" \
17+
-output "build/{{.Dir}}_$(VERSION)_{{.OS}}_{{.Arch}}/$(NAME)" \
18+
./...
19+
20+
install: ## Locally installs dev binary
21+
go install -ldflags "-X main.Version=$(VERSION)"
22+
23+
deps: ## Installs dev dependencies
24+
go get github.com/c4milo/github-release
25+
go get github.com/mitchellh/gox
26+
go get github.com/kardianos/govendor
27+
28+
dist: build ## Generates distributable artifacts
29+
$(eval FILES := $(shell ls build))
30+
@rm -rf dist && mkdir dist
31+
@for f in $(FILES); do \
32+
(cd $(shell pwd)/build/$$f && tar -cvzf ../../dist/$$f.tar.gz *); \
33+
(cd $(shell pwd)/dist && shasum -a 512 $$f.tar.gz > $$f.sha512); \
34+
echo $$f; \
5035
done
51-
gocovmerge $(shell find $(COVERDIR) -name '*.out') > cover.test.out
52-
53-
test-integration: postgres_exporter postgres_exporter_integration_test
54-
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"
55-
56-
cover.out: tools
57-
gocovmerge cover.*.out > cover.out
58-
59-
# Do a self-contained docker build - we pull the official upstream container
60-
# and do a self-contained build.
61-
docker-build:
62-
docker run -v $(shell pwd):/go/src/github.com/wrouesnel/postgres_exporter \
63-
-v $(shell pwd):/real_src \
64-
-e SHELL_UID=$(shell id -u) -e SHELL_GID=$(shell id -g) \
65-
-w /go/src/github.com/wrouesnel/postgres_exporter \
66-
golang:1.8-wheezy \
67-
/bin/bash -c "make >&2 && chown $$SHELL_UID:$$SHELL_GID ./postgres_exporter"
68-
docker build -t $(CONTAINER_NAME) .
69-
70-
push:
71-
docker push $(CONTAINER_NAME)
72-
73-
tools:
74-
$(MAKE) -C $(TOOLDIR)
7536

76-
clean:
77-
rm -f postgres_exporter postgres_exporter_integration_test
37+
release: dist ## Pushes up distributable artifacts to Github Releases
38+
@latest_tag=$$(git describe --tags `git rev-list --tags --max-count=1`); \
39+
comparison="$$latest_tag..HEAD"; \
40+
if [ -z "$$latest_tag" ]; then comparison=""; fi; \
41+
changelog=$$(git log $$comparison --oneline --no-merges); \
42+
github-release c4milo/$(NAME) $(VERSION) "$$(git rev-parse --abbrev-ref HEAD)" "**Changelog**<br/>$$changelog" 'dist/*'; \
43+
git pull
7844

79-
.PHONY: tools docker-build docker lint fmt test vet push cross clean
45+
.PHONY: build dev dist install deps release

tests/docker-postgres-replication/Dockerfile

Lines changed: 0 additions & 7 deletions
This file was deleted.

tests/docker-postgres-replication/Dockerfile.p2

Lines changed: 0 additions & 7 deletions
This file was deleted.

tests/docker-postgres-replication/README.md

Lines changed: 0 additions & 11 deletions
This file was deleted.

tests/docker-postgres-replication/docker-compose.yml

Lines changed: 0 additions & 32 deletions
This file was deleted.

tests/docker-postgres-replication/docker-entrypoint.sh

Lines changed: 0 additions & 140 deletions
This file was deleted.

tests/docker-postgres-replication/setup-replication.sh

Lines changed: 0 additions & 22 deletions
This file was deleted.

0 commit comments

Comments
 (0)