From 86974d94cd2b964f620776c096c161559bf433ab Mon Sep 17 00:00:00 2001 From: "kare.nuorteva" Date: Thu, 11 Jan 2018 16:11:42 +0000 Subject: [PATCH] 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 --- .travis.yml | 16 ++++++++++++---- ci/lint.sh | 14 ++++++++++++++ ci/validate-gofmt.sh | 13 +++++++++++++ 3 files changed, 39 insertions(+), 4 deletions(-) create mode 100755 ci/lint.sh create mode 100755 ci/validate-gofmt.sh diff --git a/.travis.yml b/.travis.yml index 58efa7f..f31891d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 diff --git a/ci/lint.sh b/ci/lint.sh new file mode 100755 index 0000000..ffe81de --- /dev/null +++ b/ci/lint.sh @@ -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 diff --git a/ci/validate-gofmt.sh b/ci/validate-gofmt.sh new file mode 100755 index 0000000..da8e236 --- /dev/null +++ b/ci/validate-gofmt.sh @@ -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