Skip to content

Commit 8eb4cf7

Browse files
committed
Add makefile, run gofmt/golint/govet in travis
1 parent 3d01c7e commit 8eb4cf7

4 files changed

Lines changed: 68 additions & 1 deletion

File tree

.githooks/pre-push

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/usr/bin/env bash
2+
3+
# install from the root of the repo with:
4+
# ln -s ../../.githooks/pre-push .git/hooks/pre-push
5+
6+
make vet fmt lint

.travis.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,24 @@
11
language: go
2+
env:
3+
global:
4+
- VET_VERSIONS="1.5 1.6 tip"
5+
- LINT_VERSIONS="1.5 1.6 tip"
26
go:
37
- 1.2
48
- 1.3
59
- 1.4
610
- 1.5
11+
- 1.6
712
- tip
813
go_import_path: gopkg.in/ldap.v2
914
install:
1015
- go get gopkg.in/asn1-ber.v1
1116
- go get gopkg.in/ldap.v2
1217
- go get code.google.com/p/go.tools/cmd/cover || go get golang.org/x/tools/cmd/cover
18+
- go get github.com/golang/lint/golint || true
1319
- go build -v ./...
1420
script:
15-
- go test -v -cover ./...
21+
- make test
22+
- make fmt
23+
- if [[ "$VET_VERSIONS" == *"$TRAVIS_GO_VERSION"* ]]; then make vet; fi
24+
- if [[ "$LINT_VERSIONS" == *"$TRAVIS_GO_VERSION"* ]]; then make lint; fi

Makefile

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
.PHONY: default install build test quicktest fmt vet lint
2+
3+
default: fmt vet lint build quicktest
4+
5+
install:
6+
go get -t -v ./...
7+
8+
build:
9+
go build -v ./...
10+
11+
test:
12+
go test -v -cover ./...
13+
14+
quicktest:
15+
go test ./...
16+
17+
# Capture output and force failure when there is non-empty output
18+
fmt:
19+
@echo gofmt -l .
20+
@OUTPUT=`gofmt -l . 2>&1`; \
21+
if [ "$$OUTPUT" ]; then \
22+
echo "gofmt must be run on the following files:"; \
23+
echo "$$OUTPUT"; \
24+
exit 1; \
25+
fi
26+
27+
# Only run on go1.5+
28+
vet:
29+
go tool vet -atomic -bool -copylocks -nilfunc -printf -shadow -rangeloops -unreachable -unsafeptr -unusedresult .
30+
31+
# https://github.com/golang/lint
32+
# go get github.com/golang/lint/golint
33+
# Capture output and force failure when there is non-empty output
34+
# Only run on go1.5+
35+
lint:
36+
@echo golint ./...
37+
@OUTPUT=`golint ./... 2>&1`; \
38+
if [ "$$OUTPUT" ]; then \
39+
echo "golint errors:"; \
40+
echo "$$OUTPUT"; \
41+
exit 1; \
42+
fi

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,19 @@ Import the latest version with:
3333
- search
3434
- modify
3535

36+
## Contributing:
3637

38+
Bug reports and pull requests are welcome!
3739

40+
Before submitting a pull request, please make sure tests and verification scripts pass:
41+
```
42+
make all
43+
```
3844

45+
To set up a pre-push hook to run the tests and verify scripts before pushing:
46+
```
47+
ln -s ../../.githooks/pre-push .git/hooks/pre-push
48+
```
3949

4050
---
4151
The Go gopher was designed by Renee French. (http://reneefrench.blogspot.com/)

0 commit comments

Comments
 (0)