-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
334 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1 @@ | ||
# Compiled Object files, Static and Dynamic libs (Shared Objects) | ||
*.o | ||
*.a | ||
*.so | ||
|
||
# Folders | ||
_obj | ||
_test | ||
|
||
# Architecture specific extensions/prefixes | ||
*.[568vq] | ||
[568vq].out | ||
|
||
*.cgo1.go | ||
*.cgo2.c | ||
_cgo_defun.c | ||
_cgo_gotypes.go | ||
_cgo_export.* | ||
|
||
_testmain.go | ||
|
||
*.exe | ||
*.test | ||
*.prof | ||
/vendor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
language: go | ||
go: | ||
- 1.9.x | ||
go_import_path: github.com/teamwork/vat | ||
notifications: | ||
email: false | ||
cache: | ||
directories: | ||
- $HOME/gopath/pkg | ||
install: | ||
- ./bin/setup-travis | ||
script: | ||
- cd $HOME/gopath/src/github.com/teamwork/vat | ||
- ./bin/test | ||
- ./bin/coverage | ||
- ./bin/lint |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
|
||
# Gopkg.toml example | ||
# | ||
# Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md | ||
# for detailed Gopkg.toml documentation. | ||
# | ||
# required = ["github.com/user/thing/cmd/thing"] | ||
# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"] | ||
# | ||
# [[constraint]] | ||
# name = "github.com/user/project" | ||
# version = "1.0.0" | ||
# | ||
# [[constraint]] | ||
# name = "github.com/user/project2" | ||
# branch = "dev" | ||
# source = "github.com/myfork/project2" | ||
# | ||
# [[override]] | ||
# name = "github.com/x/y" | ||
# version = "2.4.0" | ||
|
||
|
||
[[constraint]] | ||
branch = "master" | ||
name = "github.com/mattes/vat" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
[![Build Status](https://travis-ci.org/Teamwork/vat.svg?branch=master)](https://travis-ci.org/Teamwork/vat) | ||
|
||
# vat | ||
VAT matching and validation in Go | ||
|
||
## Usage | ||
|
||
See http://godoc.org/github.com/Teamwork/vat for usage and examples | ||
See http://godoc.org/github.com/Teamwork/vat for usage and examples |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#!/bin/bash | ||
|
||
usage="Run coverage analyses and send it to Codecov." | ||
|
||
# Setup | ||
####### | ||
set -euC | ||
root="$(cd "$(dirname "$0")/.." && pwd)" | ||
. "$root/bin/start" | ||
|
||
# Run action | ||
############ | ||
|
||
# Only test packages with actual test files. | ||
test_pkgs=$(find -name "*_test.go" | | ||
grep -v /vendor/ | | ||
xargs dirname | | ||
sort -u | | ||
sed -e "s#^\.#$pkgname#") | ||
|
||
# Pass all packages to -coverpkg to list coverage for all packages, even those | ||
# without tests. | ||
allpkg=$(go list -tags="$test_tags" ./... | | ||
grep -v /vendor/ | | ||
tr '\n' , | | ||
sed -e 's/,$//') | ||
|
||
# Cache | ||
go test -i -covermode=count -tags="$test_tags" $(go list ./... | grep -v /vendor/) | ||
|
||
$pre_test_func | ||
|
||
echo 'mode: count' >| coverage.txt | ||
for pkg in $test_pkgs; do | ||
go test \ | ||
-tags="$test_tags" \ | ||
-covermode=count \ | ||
-coverprofile=profile.out \ | ||
-coverpkg=$allpkg \ | ||
$pkg 2>&1 | grep -v 'warning: no packages being tested depend on ' | ||
|
||
if [ -f profile.out ]; then | ||
tail -n+2 profile.out >> coverage.txt | ||
rm profile.out | ||
fi | ||
done | ||
|
||
# The token is optional for public repos. | ||
[ -n "${codecov_token:-}" ] && codecov_token="-t $codecov_token" | ||
|
||
if [ -n ${TRAVIS} ]; then | ||
bash <(curl -s https://codecov.io/bash) $codecov_token | ||
else | ||
bash <(curl -s https://codecov.io/bash) \ | ||
$codecov_token \ | ||
-B $(git rev-parse --abbrev-ref HEAD) \ | ||
-C $(git rev-parse HEAD) | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
#!/bin/sh | ||
|
||
usage="Run Go linter tools" | ||
|
||
# Setup | ||
####### | ||
set -euC | ||
root="$(cd "$(dirname "$0")/.." && pwd)" | ||
. "$root/bin/start" | ||
|
||
# Run action | ||
############ | ||
|
||
tmpfile="$(mktemp)" | ||
|
||
ignore_grep() { | ||
local IFS="$(printf '\n\b')" | ||
for d in $lint_ignore; do printf "|$d"; done | ||
} | ||
|
||
ignore_metalinter() { | ||
local IFS="$(printf '\n\b')" | ||
for d in $lint_ignore; do printf " -s $d"; done | ||
} | ||
|
||
paths=$(go list ./... | grep -Ev "/(vendor$(ignore_grep))" | sed -e "s#^$pkgname#.#") | ||
|
||
cleanup() { | ||
rm -f "$tmpfile" | ||
} | ||
trap cleanup EXIT | ||
|
||
# Skip the linter if we're on master or beta | ||
if [ -n "$TRAVIS" ]; then | ||
branch=${TRAVIS_PULL_REQUEST_BRANCH:-${TRAVIS_BRANCH:-}} | ||
branch=${branch:-$(git rev-parse --abbrev-ref HEAD)} | ||
branch=${branch:-unknown} | ||
case "$branch" in | ||
master|beta|eu|unknown) | ||
echo "We're on $branch; skipping lint tests" | ||
exit 0 | ||
;; | ||
esac | ||
fi | ||
|
||
# Ensure generated files are up to date; only run on Travis to prevent | ||
# clobbering people's working directories. | ||
if [ -n "$TRAVIS" ]; then | ||
go generate $(go list ./... | grep -v /vendor/) | ||
changes="$(git diff)" | ||
if [ -n "$changes" ]; then | ||
echo | ||
echo "*****************************************************" | ||
echo "*** ***" | ||
echo "*** Changes in generated files: ***" | ||
echo "*** ***" | ||
echo "*****************************************************" | ||
echo | ||
echo "$changes" | ||
fi | ||
fi | ||
|
||
if [ -n "$TRAVIS" ]; then | ||
# Set up git for Travis here | ||
git fetch -q origin master:refs/remotes/origin/master | ||
|
||
# Install for Travis. | ||
go get -u github.com/alecthomas/gometalinter | ||
gometalinter --install | ||
fi | ||
|
||
gometalinter --deadline=120s --vendor --sort=path --tests --disable-all \ | ||
$(ignore_metalinter) \ | ||
--enable=vet \ | ||
--enable=golint \ | ||
--enable=varcheck \ | ||
--enable=structcheck \ | ||
--enable=errcheck \ | ||
--enable=megacheck \ | ||
--enable=ineffassign \ | ||
--enable=interfacer \ | ||
--enable=unconvert \ | ||
--enable=goconst \ | ||
--enable=gas \ | ||
--enable=goimports \ | ||
--enable=lll --line-length=120 \ | ||
./... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/bin/sh | ||
|
||
usage="Setup the environment for Travis" | ||
|
||
# Setup | ||
####### | ||
set -euC | ||
root="$(cd "$(dirname "$0")/.." && pwd)" | ||
. "$root/bin/start" | ||
|
||
# Run action | ||
############ | ||
|
||
# Setup dep if it's used and vendor isn't in git. | ||
if [ -f Gopkg.toml -a ! -d vendor ]; then | ||
go get -u github.com/golang/dep/cmd/dep | ||
dep ensure | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
# vi:ft=sh | ||
|
||
set -euC | ||
|
||
cd "$root" | ||
|
||
# Load settings | ||
[ -f "$root/bin/settings" ] && . "$root/bin/settings" | ||
|
||
### | ||
# Stuff to set in settings file. | ||
|
||
# Codecov token for coverage reports; only needed for private repos. | ||
codecov_token=${codecov_token:-} | ||
|
||
# Tags to add to "go test" when running tests. | ||
test_tags=${test_tags:-} | ||
|
||
# Verbose output? | ||
verbose=${verbose:-0} | ||
|
||
# Directory names to ignore in the ./bin/lint script; multiple directories are | ||
# separated by newlines. | ||
lint_ignore="${lint_ignore:-}" | ||
|
||
# Callback to run before "go test" in ./bin/test and ./bin/coverage. | ||
pre_test_func=${pre_test_func:-:} | ||
|
||
|
||
### | ||
# For the following the defaults should almost always be okay. If not, then | ||
# consider fixing the project maybe? | ||
|
||
# Binary name. | ||
name=${name:-$(basename "$root")} | ||
|
||
# Go package name | ||
pkgname=${pkgname:-"github.com/teamwork/$name"} | ||
|
||
# Git branch | ||
branch=${TRAVIS_PULL_REQUEST_BRANCH:-${TRAVIS_BRANCH:-$(git rev-parse --abbrev-ref HEAD)}} | ||
|
||
# Docker image tag; usually the commit | ||
docker_tag=${docker_tag:-${TRAVIS_COMMIT:-dev-env}} | ||
|
||
# Make sure this is set locally so we can do -z/-n. | ||
TRAVIS=${TRAVIS:-} | ||
|
||
# So scripts can override this. | ||
usage_func=${usage_func:-_usage} | ||
options_func=${options_func:-_parse_options} | ||
|
||
# Usage info. | ||
_usage() { | ||
echo "Usage: ${0##*/} [-hv] [-t tag]" | ||
echo | ||
echo "$usage" | ||
echo | ||
echo "Options:" | ||
echo " -h Show this help" | ||
echo " -v Enable verbose output" | ||
echo " -t Set tag for Docker and main.version" | ||
echo " -b Go build tag; can be given more than once" | ||
echo | ||
} | ||
|
||
# Parse options | ||
_parse_options() { | ||
while getopts "hvt:b:" option; do | ||
case "$option" in | ||
h) $usage_func; exit 0 ;; | ||
v) verbose=1; set -x ;; | ||
t) tag=$OPTARG ;; | ||
b) test_tags="$test_tags $OPTARG" ;; | ||
*) | ||
echo "error: unknown option '$option'" | ||
$usage_func | ||
exit 1 | ||
;; | ||
esac | ||
done | ||
|
||
[ -n "$test_tags" ] && test_tags="${test_tags# }" | ||
return 0 | ||
} | ||
|
||
$options_func "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/bin/sh | ||
|
||
usage="Run all tests" | ||
|
||
# Setup | ||
####### | ||
set -euC | ||
root="$(cd "$(dirname "$0")/.." && pwd)" | ||
. "$root/bin/start" | ||
|
||
# Run action | ||
############ | ||
|
||
# If we don't set this some stacks may not be complete when encountering race | ||
# conditions. Uses a bit more memory, but we usually have enough of that. | ||
export GORACE="history_size=4" | ||
|
||
$pre_test_func | ||
|
||
v_flag="" | ||
[ $verbose -ge 1 ] && v_flag="-v" | ||
go test $v_flag -race -tags="${test_tags# }" $(go list ./... | grep -v /vendor/) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters