travis: adding checks for basic regressions

* go vet
* golint
* whether the tool builds
* tests (there are none yet)

Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
This commit is contained in:
Vincent Batts 2016-04-05 13:16:40 -04:00
parent 41062f1be2
commit e3ba588c3a
2 changed files with 32 additions and 1 deletions

20
.travis.yml Normal file
View File

@ -0,0 +1,20 @@
language: go
go:
- 1.6
- 1.5.3
sudo: false
before_install:
- go get golang.org/x/tools/cmd/vet
- go get -u github.com/golang/lint/golint
- mkdir -p $GOPATH/src/github.com/vbatts && ln -sf $(pwd) $GOPATH/src/github.com/vbatts/git-validation && go get ./...
install: true
script:
- go vet -x ./...
- golint ./...
- go build .
- go test -v ./...

13
main.go
View File

@ -5,6 +5,7 @@ import (
"fmt"
"log"
"os"
"strings"
_ "github.com/vbatts/git-validation/rules/dco"
_ "github.com/vbatts/git-validation/rules/shortsubject"
@ -19,6 +20,7 @@ var (
flDebug = flag.Bool("D", false, "debug output")
flQuiet = flag.Bool("q", false, "less output")
flDir = flag.String("d", ".", "git directory to validate from")
flNoTravis = flag.Bool("no-travis", false, "disables travis environment checks (when env TRAVIS=true is set)")
)
func main() {
@ -44,7 +46,16 @@ func main() {
rules = validate.FilterRules(rules, validate.SanitizeFilters(*flRun))
}
runner, err := validate.NewRunner(*flDir, rules, *flCommitRange, *flVerbose)
var commitRange = *flCommitRange
if strings.ToLower(os.Getenv("TRAVIS")) == "true" && !*flNoTravis {
if os.Getenv("TRAVIS_COMMIT_RANGE") != "" {
commitRange = os.Getenv("TRAVIS_COMMIT_RANGE")
} else if os.Getenv("TRAVIS_COMMIT") != "" {
commitRange = os.Getenv("TRAVIS_COMMIT")
}
}
runner, err := validate.NewRunner(*flDir, rules, commitRange, *flVerbose)
if err != nil {
log.Fatal(err)
}