Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
mongodb_exporter
coverage.txt
coverage_temp.txt
21 changes: 18 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,25 @@
sudo: false
dist: trusty
sudo: required
language: go

go:
- 1.7.x
- 1.8.x
- tip

env:
- MONGODB_IMAGE=mongo:3.4
- MONGODB_IMAGE=percona/percona-server-mongodb:3.4

services:
- docker

before_script:
- docker --version
- docker-compose --version
- docker-compose up -d

script:
- make
- make format build testall

after_success:
- bash <(curl -s https://codecov.io/bash)
20 changes: 20 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Contributing notes

## Local setup

The easiest way to make a local development setup is to use Docker Compose.

```
docker-compose up
make all testall
export MONGODB_URL='mongodb://localhost:27017'
./mongodb_exporter
```

`testall` make target will run integration tests.


## Vendoring

We use [Glide](https://glide.sh) to vendor dependencies. Please use released version of Glide (i.e. do not `go get`
from `master` branch). Also please use `--strip-vendor` flag.
30 changes: 29 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# Copyright 2015 The Prometheus Authors
# Copyright 2017 Percona LLC
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

GO := go
FIRST_GOPATH := $(firstword $(subst :, ,$(shell $(GO) env GOPATH)))
PROMU := $(FIRST_GOPATH)/bin/promu -v
Expand All @@ -17,7 +31,21 @@ style:

test:
@echo ">> running tests"
@$(GO) test -short -race $(pkgs)
rm -f coverage.txt
for p in $(pkgs); do \
rm -f coverage_temp.txt ; \
$(GO) test -v -short -race -covermode atomic -coverprofile coverage_temp.txt $$p ; \
cat coverage_temp.txt >> coverage.txt ; \
done

testall:
@echo ">> running all tests"
rm -f coverage.txt
for p in $(pkgs); do \
rm -f coverage_temp.txt ; \
$(GO) test -v -race -covermode atomic -coverprofile coverage_temp.txt $$p ; \
cat coverage_temp.txt >> coverage.txt ; \
done

format:
@echo ">> formatting code"
Expand Down
8 changes: 8 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# see CONTRIBUTING.md
---
version: '3'
services:
mongo:
image: ${MONGODB_IMAGE:-mongo:3.4}
ports:
- 127.0.0.1:27017:27017