Use Travis build stages for lint and test builds

- Lint build runs scripts in ci directory.
- Test build runs go test kkn.fi/vanity
- Test build is only run if Lint succeeds
- Run all stages (Lint & Test) with Go 1.9

git-svn-id: file:///srv/svn/repo/toyohime/trunk@73 922d331f-388e-da47-97a9-ad700dc0b8b9
This commit is contained in:
kare.nuorteva 2018-01-11 16:11:42 +00:00
parent 3cd1c026a8
commit 86974d94cd
3 changed files with 39 additions and 4 deletions

View File

@ -1,6 +1,14 @@
dist: trusty
language: go
go_import_path: kkn.fi/vanity
script: make test
go:
- 1.9
- tip
go: 1.9.x
jobs:
include:
- stage: lint
script:
- ./ci/validate-gofmt.sh
- go get -u github.com/golang/lint/golint
- ./ci/lint.sh
- stage: test
script: go test kkn.fi/vanity
install: skip

14
ci/lint.sh Executable file
View File

@ -0,0 +1,14 @@
#!/bin/bash
pkg=kkn.fi/vanity
go vet $pkg
if [ $? -ne 0 ]; then
exit 1
fi
output=`golint $pkg`
if [ "$output" != "" ]; then
echo "$output" 1>&2
exit 1
fi

13
ci/validate-gofmt.sh Executable file
View File

@ -0,0 +1,13 @@
#!/bin/bash
# $pkg is relative path to package
pkg=kkn.fi/vanity
importPath=kkn.fi/vanity
relativePkg="${pkg/$importPath/.}"
output=`gofmt -s -l $relativePkg`
if [ "$output" != "" ]; then
echo "validate-gofmt.sh: error $pkg" 1>&2
exit 1
fi
exit 0