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

Commit

Permalink
added test coverage reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
jandelgado committed Nov 2, 2017
1 parent 76e7a5e commit 019d604
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 18 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
*~
ci-test-*
golang-ci-template
*zip
*.out

19 changes: 13 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
language: go
go:
- 1.7.x
- 1.8.x
- 1.9.x

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

script:
- "./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

before_deploy:
- zip ci-test-${TRAVIS_TAG}-windows-amd64.zip ci-test-windows-amd64.exe README.md
Expand All @@ -23,11 +27,14 @@ deploy:
provider: releases
api_key:
secure: ZSqZx+Ej1mFm5vFjAYvBmVVUfulT7xaRkjVL3Wh13N3pVroUtRi6mwAHfcXdIprGa1rToCIP66BQD8q26DLe2kwEYNJK2gtvbjNzsOPJgmtLoBW7GKW0p9gm0MXFCNmwVwGEJUpTvi4aWNIHIVqrLrAA2adrfF1eIepBOYB5Iu6wDqa0WKnbuVd87+Bx17XquhNZCETKBUpvAL4v3D2shkxz/twOJnVTms5JuJUZ5mKNZo99PlsoW1GtfwKHDNw6ChE8pl96cCvLQz4AyBxF8BIDfNSWW9QrcxyNGzesKa2+Q5IcBPQ7v/RfuEnVctiCQqvnrZ65cKvn2edbH1j35gTRINGo9lzHWNqGGPKhAbiloeKIRXV/6L3ClewwTY4w+rTwxy8Ted4MWcGSAdMdVlodIXT7PGJ1IdJy16iw23DND4PqNEcwJyvYypoXFJ0vPz3yG8CtM5KI7C+2wNRVnm9J46m430wjlqa19YI/1DlFS+iE2KYAVvtVAJfS/fuJy6Y/db8rh2LqW2OaOMX5al8iT3dSaqkQjxiOfynITJQXiYrsoFpYoDEDbkvTG6L6oaDq3kudCvcHeYugAm61TORCKeDPtIZoInZUhw+in3DTN9zv/qJ7HHQ5LBjFwyggRGSmP33A6tvKxyXhkRXH/6UzLC0yT80lWAkEiuabbmw=
file:
- ci-test-${TRAVIS_TAG}-windows-amd64.zip
- ci-test-${TRAVIS_TAG}-linux-amd64.zip
- SHASUMS256.txt
file:
- ci-test-${TRAVIS_TAG}-windows-amd64.zip
- ci-test-${TRAVIS_TAG}-linux-amd64.zip
- SHASUMS256.txt
skip_cleanup: true
on:
tags: true

env:
global:
secure: e77l5tQAk5BdR7r407eIgt/0IFzSht2gV0YkqChneog6HWq1Jq9F+8/J2hKSpnpzGZ/G561P7/c2RKko1CaHWLAdN69jvoEW4jNwTvVpSRlbf8byU4l93zptVARG0V5oaQus+HdS8kX8bXzLB4x/s78SlCS5kMHbk8nFAHT2+TBD5cLaQMCcM9XWzTYPeMWACdQcIxSLzlBIW8AfCDfUc7C+oSpAv+SAsvBVP6c1xNxDJ7cHMS72xH8mtX2valnD8QbBX8pRW7ttoJYWg4VyX4F3I8Ovzo5u0mCM0rcRxIji07q3kyXVOp5agnE/E9LCDPBUBnQE4MR42juSTeckDEmwWZgngt91k0GkvVnKH5Ef4DJR8r9dYXG414FkdfDBEuMkjNX8D+z/wwvCIAXAqZIFRsSl7yJ9KdTWfOmSDEP3XFGRqb905YvWvMgcHg8oKwdncLXFnlZ7N91Zh2iB2F9t4XshodYpKGi0p31B/azLcqTtwJc6adrK4aSkkGsb26KuO6Xgpp9bnTa0FJECwkrg9Hz0N0ZWu914g3jzT1OSeOVNXQaLtK1je4/Uj5ZKCksiMxi718EAQabKZ1bMP/1gvyJj5NRU8Z6sGJr54rBEDLkhcfNvPbw7ty5p+baCmPUSYdA9UFX1f5ZexSpaKNqcnY0FlDqAdzAy1aj4opY=
28 changes: 24 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# golang travis-ci template
![ci status](https://travis-ci.org/jandelgado/golang-ci-template.svg?branch=master) [![Go Report Card](https://goreportcard.com/badge/github.com/jandelgado/golang-ci-template)](https://goreportcard.com/report/github.com/jandelgado/golang-ci-template)

![ci status](https://travis-ci.org/jandelgado/golang-ci-template.svg?branch=master) [![Coverage Status](https://coveralls.io/repos/github/jandelgado/golang-ci-template/badge.svg?branch=master)](https://coveralls.io/github/jandelgado/golang-ci-template?branch=master) [![Go Report Card](https://goreportcard.com/badge/github.com/jandelgado/golang-ci-template)](https://goreportcard.com/report/github.com/jandelgado/golang-ci-template)


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

* [Releasing](#releasing)
* [travis-ci cli](#travis-ci-cli)
* [coveralls test coverage](#coveralls-test-coverage)
* [Creating a release](#creating-a-release)

<!-- 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
Expand All @@ -11,9 +22,12 @@ purposes, both a linux- and windows target is created and packetized in a
zip-archive.

## Releasing

### travis-ci cli

The travis cli tool is recommended to create the encrypted api_key used in
`.travis.yml` file. Example installation on Fedora25:

```
$ sudo dnf install ruby ruby-devel redhat-rpm-config
$ gem install travis -v 1.8.8 --no-rdoc --no-ri
Expand All @@ -24,6 +38,7 @@ Set up deployment in .travis.yml and create encrypted api-key with:

This will ask some questions and create the `deploy` section in i
the [.travis.yml](.travis.yml), modify it to look like:

```
before_deploy:
- zip ci-test-${TRAVIS_TAG}-windows-amd64.zip ci-test-windows-amd64.exe README.md
Expand All @@ -42,11 +57,16 @@ deploy:
tags: true
```

### coveralls test coverage

Create coveralls account and activate coveralls for repositiory. Encrypt
coveralls token with `travis encrypt COVERALLS_TOKE="<token>"`.

For instructions on using goveralls look [here](https://coveralls.zendesk.com/hc/en-us/articles/201342809-Go).

### Creating a release

On your repositories home (github.com) go to `Releases` > `create realease`.
As soon as the release-tag is created, Travis will run the deployment step.

## TODO
- add glide example
- add unit tests and test coverage

12 changes: 12 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package main

import "fmt"

// Hello just says hello
func Hello() {
fmt.Println("hello, world!")
}

func main() {
Hello()
}
7 changes: 7 additions & 0 deletions main_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package main

func ExampleHello() {
Hello()
// Output:
// hello, world!
}
1 change: 1 addition & 0 deletions pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/sh
# inspired from https://github.com/streadway/amqp/blob/master/pre-commit

MAX_CYCLO=15

Expand Down
7 changes: 0 additions & 7 deletions test.go

This file was deleted.

0 comments on commit 019d604

Please sign in to comment.