Skip to content

Commit 9894890

Browse files
committed
Refactor repository layout and convert build system to Mage.
This commit implements a massive refactor of the repository, and moves the build system over to use Mage (magefile.org) which should allow seamless building across multiple platforms.
1 parent 3e6cf08 commit 9894890

File tree

269 files changed

+35308
-2016
lines changed

Some content is hidden

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

269 files changed

+35308
-2016
lines changed

.gitignore

+11-11
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
.build
2-
postgres_exporter
3-
postgres_exporter_integration_test
1+
/.build
2+
/postgres_exporter
3+
/postgres_exporter_integration_test
44
*.tar.gz
55
*.test
66
*-stamp
7-
.idea
7+
/.idea
88
*.iml
9-
cover.out
10-
cover.*.out
11-
.coverage
12-
bin
13-
release
14-
*.prom
15-
.metrics.*.*.prom
9+
/cover.out
10+
/cover.*.out
11+
/.coverage
12+
/bin
13+
/release
14+
/*.prom
15+
/.metrics.*.*.prom

.travis.yml

+15-23
Original file line numberDiff line numberDiff line change
@@ -3,37 +3,29 @@ services:
33
- docker
44
language: go
55
go:
6-
- '1.9'
7-
# Make sure we have p2 and the postgres client.
6+
- '1.10'
87
before_install:
98
- go get -v github.com/mattn/goveralls
10-
- sudo wget -O /usr/local/bin/p2 https://github.com/wrouesnel/p2cli/releases/download/r4/p2 &&
11-
sudo chmod +x /usr/local/bin/p2
12-
- sudo wget -O /usr/local/bin/docker-compose https://github.com/docker/compose/releases/download/1.9.0-rc4/docker-compose-Linux-x86_64 &&
13-
sudo chmod +x /usr/local/bin/docker-compose
9+
- sudo wget -O /usr/local/bin/p2 https://github.com/wrouesnel/p2cli/releases/download/r4/p2
10+
&& sudo chmod +x /usr/local/bin/p2
11+
- sudo wget -O /usr/local/bin/docker-compose https://github.com/docker/compose/releases/download/1.9.0-rc4/docker-compose-Linux-x86_64
12+
&& sudo chmod +x /usr/local/bin/docker-compose
1413
- sudo apt-get update && sudo apt-get install postgresql-client-common
15-
1614
script:
17-
- make all
18-
- make docker
19-
- make test-integration
20-
- make cover.out
21-
- make release
22-
- $HOME/gopath/bin/goveralls -coverprofile=cover.out -service=travis-ci
15+
- go run mage.go -v all
16+
- "$HOME/gopath/bin/goveralls -coverprofile=cover.out -service=travis-ci"
17+
- go run mage.go docker
2318
after_success:
2419
- docker login -e $DOCKER_EMAIL -u $DOCKER_USER -p $DOCKER_PASS
25-
# Push a tagged build if a tag is found.
26-
- if [ ! -z "$TRAVIS_TAG" ]; then
27-
docker tag wrouesnel/postgres_exporter:latest wrouesnel/postgres_exporter:$TRAVIS_TAG ;
28-
docker push wrouesnel/postgres_exporter:$TRAVIS_TAG ;
29-
fi
30-
# Push a latest version
31-
- if [ "$TRAVIS_BRANCH" == "master" ]; then docker push wrouesnel/postgres_exporter ; fi
20+
- if [ ! -z "$TRAVIS_TAG" ]; then docker tag wrouesnel/postgres_exporter:latest wrouesnel/postgres_exporter:$TRAVIS_TAG
21+
; docker push wrouesnel/postgres_exporter:$TRAVIS_TAG ; fi
22+
- if [ "$TRAVIS_BRANCH" == "master" ]; then docker push wrouesnel/postgres_exporter
23+
; fi
3224
env:
3325
global:
34-
- secure: RfoWQj5tEB/t3XL2tqJW7u7Qscpz1QBOfF9lMFpB4kAUMTtZU0zBbXfMo1JheGoJQQxD/7NLRHhbUWPT2489o3KKpRTQ7RHn3k8n5U7opH01bWX0+l/EPVmhlsKjSDSLGgmxz80j3I6C8ZV3qDUijSx7r90QUNHGbZtV7g+KtoUTpRV0zir/heK6qq9LHWNHbNsJyHK8qHmd6g1UzWIBaZPJ6a/n/rO2jq4uS1JR0VlIJPRF11HOLH8IjFQvVYpN7YbEslxyNsfQJUSP/7CghSLLVWPSATEjMm8a5GJVLc564+nYghm484psEtiMXkZ3n6ie7AT8aJrKfexWrwh2aCc+cK4PiyXrf4euZehZNYogmFCqWzd1LJKcN2uIkpBSuZQDm3e6c4qkkWGpx+RdFWtAMG8IgZLDbcuryxFNzMwHc2CJ009s9Zsa+g7D57csyR5LCZ8YtNGI3g8FmhwpCKvYk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LbB8O3ll2smCu3aFYv7J9IfvI0ol0ww7kULpyf/vqxkK0NJXsKgoK/Uo1lM9gNpJBHsMt9nWnDvLj2DKZNTqkxzJeG8O98ADrQWEGFhpcsSsbW9pAMsrp6D4LQikN8KoFvh9F8h9lBsYpafzlOA=
3729
deploy:
3830
skip_cleanup: true
3931
provider: releases

README.md

+11-11
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,19 @@ docker run --net=host -e DATA_SOURCE_NAME="postgresql://postgres:password@localh
1717
```
1818

1919
## Building and running
20+
21+
The build system is based on [Mage](https://magefile.org)
22+
2023
The default make file behavior is to build the binary:
2124
```
22-
go get github.com/wrouesnel/postgres_exporter
23-
cd ${GOPATH-$HOME/go}/src/github.com/wrouesnel/postgres_exporter
24-
make
25-
export DATA_SOURCE_NAME="postgresql://login:password@hostname:port/dbname"
26-
./postgres_exporter <flags>
25+
$ go get github.com/wrouesnel/postgres_exporter
26+
$ cd ${GOPATH-$HOME/go}/src/github.com/wrouesnel/postgres_exporter
27+
$ go run mage.go
28+
$ export DATA_SOURCE_NAME="postgresql://login:password@hostname:port/dbname"
29+
$ ./postgres_exporter <flags>
2730
```
2831

29-
To build the dockerfile, run `make docker`.
32+
To build the dockerfile, run `go run mage.go docker`.
3033

3134
This will build the docker image as `wrouesnel/postgres_exporter:latest`. This
3235
is a minimal docker image containing *just* postgres_exporter. By default no SSL
@@ -130,9 +133,6 @@ GRANT SELECT ON postgres_exporter.pg_stat_replication TO postgres_exporter;
130133
> ```
131134
132135
# Hacking
133-
134-
* The build system is currently only supported for Linux-like platforms. It
135-
depends on GNU Make.
136-
* To build a copy for your current architecture run `make binary` or just `make`
136+
* To build a copy for your current architecture run `go run mage.go binary` or just `go run mage.go`
137137
This will create a symlink to the just built binary in the root directory.
138-
* To build release tar balls run `make release`.
138+
* To build release tar balls run `go run mage.go release`.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

tests/docker-postgres-replication/Dockerfile cmd/postgres_exporter/tests/docker-postgres-replication/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM postgres:9.6
1+
FROM postgres:10
22
MAINTAINER Daniel Dent (https://www.danieldent.com)
33
ENV PG_MAX_WAL_SENDERS 8
44
ENV PG_WAL_KEEP_SEGMENTS 8

tests/test-smoke cmd/postgres_exporter/tests/test-smoke

+8-2
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,17 @@ DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
1212
METRICS_DIR=$(pwd)
1313

1414
# Read the absolute path to the exporter
15-
postgres_exporter=$(readlink -f $1)
16-
test_binary=$(readlink -f $2)
15+
postgres_exporter="$1"
16+
test_binary="$2"
1717
export POSTGRES_PASSWORD=postgres
1818
exporter_port=9187
1919

20+
echo "Exporter Binary: $postgres_exporter" 1>&2
21+
echo "Test Binary: $test_binary" 1>&2
22+
23+
[ -z "$postgres_exporter" ] && echo "Missing exporter binary" && exit 1
24+
[ -z "$test_binary" ] && echo "Missing test binary" && exit 1
25+
2026
cd $DIR
2127

2228
VERSIONS=( \
File renamed without changes.
File renamed without changes.

mage.go

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// +build ignore
2+
3+
package main
4+
5+
import (
6+
"os"
7+
8+
"github.com/magefile/mage/mage"
9+
)
10+
11+
func main() { os.Exit(mage.Main()) }

0 commit comments

Comments
 (0)