Skip to content
This repository has been archived by the owner on Nov 22, 2020. It is now read-only.

Commit

Permalink
Merge 57e0177 into 6a8c0a0
Browse files Browse the repository at this point in the history
  • Loading branch information
jandelgado committed Sep 27, 2019
2 parents 6a8c0a0 + 57e0177 commit cc4d963
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 51 deletions.
18 changes: 8 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
language: go
go:
- 1.8.x
- 1.9.x
- 1.12.x
- 1.13.x

before_install:
- go get github.com/golang/lint/golint
- go get github.com/gordonklaus/ineffassign
- go get github.com/fzipp/gocyclo
- go get github.com/client9/misspell/cmd/misspell
- go get golang.org/x/tools/cmd/cover
- go get github.com/mattn/goveralls
- go get -u github.com/mattn/goveralls
- go get -u github.com/golangci/golangci-lint/cmd/golangci-lint

script:
- export GO111MODULE=on
- "./pre-commit"
- go test -v -covermode=count -coverprofile=coverage.out
- GOOS=windows GOARCH=amd64 go build -o ci-test-windows-amd64.exe
- GOOS=linux GOARCH=amd64 go build -o ci-test-linux-amd64
- goveralls -coverprofile=coverage.out -service=travis-ci -repotoken $COVERALLS_TOKEN
- GOOS=linux GOARCH=amd64 go build -o ci-test
- 'if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then goveralls -coverprofile=coverage.out -service=travis-ci -repotoken $COVERALLS_TOKEN; fi'
- 'if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then goveralls -coverprofile=coverage.out -service=travis-ci ; fi'

before_deploy:
- zip ci-test-${TRAVIS_TAG}-windows-amd64.zip ci-test-windows-amd64.exe README.md
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* [Test coverage (coveralls)](#test-coverage-coveralls)

<!-- vim-markdown-toc -->

This repository serves as my template for travis-ci-integrated go projects. It
consists of a `hello, world!` like example in source file `main.go` which gets
compiled into binary `ci-test`. The `pre-commit` script runs some checks on the
Expand Down
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module github.com/jandelgado/golang-ci-template

go 1.12
41 changes: 1 addition & 40 deletions pre-commit
Original file line number Diff line number Diff line change
@@ -1,41 +1,2 @@
#!/bin/sh
# inspired from https://github.com/streadway/amqp/blob/master/pre-commit

MAX_CYCLO=15

INEFFASSIGN_ERRORS=$(ineffassign .)
if [ -n "${INEFFASSIGN_ERRORS}" ]; then
printf >&2 'ineffassign failed for the following files:\n%s\n' "${INEFFASSIGN_ERRORS}"
exit 1
fi

MISSPELL_ERRORS=$(misspell *go)
if [ -n "${MISSPELL_ERRORS}" ]; then
printf >&2 'misspell failed for the following files:\n%s\n' "${MISSPELL_ERRORS}"
exit 1
fi

GOCYCLO_ERRORS=$(gocyclo -over $MAX_CYCLO *go)
if [ -n "${GOCYCLO_ERRORS}" ]; then
printf >&2 'gocyclo failed for the following files:\n%s\n' "${GOCYCLO_ERRORS}"
exit 1
fi

GOFMT_FILES=$(gofmt -l *go)
if [ -n "${GOFMT_FILES}" ]; then
printf >&2 'gofmt failed for the following files:\n%s\n\nplease run "gofmt -w ." on your changes before committing.\n' "${GOFMT_FILES}"
exit 1
fi

GOLINT_ERRORS=$(golint ./... 2>&1 | grep -v "^vendor/")
if [ -n "${GOLINT_ERRORS}" ]; then
printf >&2 'golint failed for the following reasons:\n%s\n.\n' "${GOLINT_ERRORS}"
exit 1
fi

GOVET_ERRORS=$(go tool vet --all *.go 2>&1)
if [ -n "${GOVET_ERRORS}" ]; then
printf >&2 'go vet failed for the following reasons:\n%s\n\nplease run "go tool vet *.go" on your changes before committing.\n' "${GOVET_ERRORS}"
exit 1
fi

golangci-lint -E bodyclose,misspell,gocyclo,dupl,gofmt,golint,unconvert,goimports,depguard,gocritic,funlen,interfacer run

0 comments on commit cc4d963

Please sign in to comment.