Skip to content

Commit

Permalink
modify travis
Browse files Browse the repository at this point in the history
  • Loading branch information
hea9549 committed Mar 7, 2019
1 parent 4200995 commit 23c640a
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 13 deletions.
18 changes: 10 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
language: go

go:
- '1.10'
- '1.11'

notifications:
email: false

services:
- docker
env:
- GO111MODULE=on

git:
depth: 1

before_install:
- curl https://github.com/golang/dep/master/install.sh | sh
- go get golang.org/x/tools/cmd/goimports
os: linux

install:
- dep ensure
- go get golang.org/x/tools/cmd/goimports
- go get golang.org/x/tools/cmd/cover
- go get github.com/mattn/goveralls
- go mod vendor

script:
- bash ./travis/run.sh
- 'if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then bash ./travis/run_on_pull_requests.sh; fi'
- 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then bash ./travis/run_on_non_pull_requests.sh; fi'
35 changes: 35 additions & 0 deletions travis/run_on_non_pull_requests
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash

# goimports test
diff <(goimports -d $(find . -type f -name '*.go' -not -path "*/vendor/*")) <(printf "")

if [ $? -ne 0 ]; then
echo "goimports format error" >&2
exit 1
fi

# run go test
go test -v -mod=vendor ./...

if [ $? -ne 0 ]; then
echo "go test fail" >&2
exit 1
fi

# generate go test coverage file
go test -v -mod=vendor ./... -covermode=count -coverprofile=coverage.out

if [ $? -ne 0 ]; then
echo "go test coverage fail" >&2
exit 1
fi

# notify to coveralls
goveralls -coverprofile=coverage.out -service=travis-ci

if [ $? -ne 0 ]; then
echo "go update test coverage fail" >&2
exit 1
fi

exit 0
14 changes: 9 additions & 5 deletions travis/run.sh → travis/run_on_pull_requests
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
#!/bin/bash

# goimports test
diff <(goimports -d $(find . -type f -name '*.go' -not -path "*/vendor/*")) <(printf "")

if [ $? -ne 0 ]; then
echo "goimports format error" >&2
exit 1
echo "goimports format error" >&2
exit 1
fi

go test -p 1 ./...
# run go test
go test -v -mod=vendor ./...

if [ $? -ne 0 ]; then
echo "go test fail" >&2
exit 1
echo "go test fail" >&2
exit 1
fi

exit 0

0 comments on commit 23c640a

Please sign in to comment.