-
Notifications
You must be signed in to change notification settings - Fork 2
/
.travis.yml
58 lines (55 loc) · 4.16 KB
/
.travis.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# Travis-CI for Golang projects
# Runs the tests and produces a code coverage report.
language: go
go:
- 1.4
env:
global:
# GITHUB_TOKEN= to push code coverage comment to github
- secure: "VENBT5SZ8r/nDHaRvyVCkvbs87UJdQw9YzrmKY4fJGlWR3GzVP1UuVl96vMWTCkJoonQSfpkllCdvnHUhm7OJIhd4+x3l53S1KNx2YbzOZ9T2h43xHfYlVhkWAikQkDVd/R3z1ykn+Jihh7uwqh266fyxn0XdBGVf1NlEbmcS4O7Yr3dWgctSK3CFHvCWuCSHPfg0JTNL35qoQ+z9RoHqxk/59/xNK5JF/MgzCAqTbfym8Hhl0uaBGzXXlEfmqluHemOpoyJP8EqNQaA6G5NbFYmIaBXIbFCHLopRr3KAypssZY/JEBl0SAt/4ZsV5OffqwvKJKHPwVAYD5w/XWPY938+Sud6H3+o2pcen8C9RUgaGOh5maN+619zXUMd2//PRv+seACrwa6dkZvZz5yWv4bdsT+eY7TktrWlD96Jl6m7+66D+HJhKBvwk8xKQjFk93nWen3xPLfap5M5E2l5P9tH3dOsZeEUwRR2axlDc7G5ZUx3cijpkNewsjwzJIfI03skJF26lgjmp6eaIuxkPR4waAUIkCJ695DZsXgFdCb2cxzULnImVRL6NahoGHQ2hGpp7O5/ZQeit9MUSZyTYeSJEkLsfrbZ8LNd/NELDkO9Zjmpm0ZHE5k7jj2aMEHMyG+u7pIgyHm2/t6VXZmmC26SBu7RazeOCoatRFAsX8="
# COV_KEY= code coverage upload keys
- secure: "Fw17ZB9+OTT9w4XfmPBQJFcLkZduo/R0cx0ME0wxkNta0t4b8uADEevN12V22tYaWi7tzyMwIxJvBmXlPdOz6omfCJgp4Os4UegdtBjaXglaw040fK0y1FaTA6t47cQ7OtTpKOxIAq9mWRbFKdF5CRa1+O3s/IfPZySMOo9twe7c0T715dbsE0j5beOgvd9AKWA7p2rbfgi0+cewm6IhKHMT5LwPnoU+UlxKpE8ZJSilAyfKOtxxwhqMlsa7VRVf2XRwBPdV4pYgvJ+5cb+zodF3rLI17j5KdglZRrUKIpuyQ17r7R1dvKsIu5RAj0M04gmjJrKMue4SYuHR6A1u4NEsmMqefea2YCXQCQZrzpZXg5rAZO4UjgP/YXMHGEgB89mN14CvUJyaTNISue5gedsF4HKfnCdVyLzy2WgpxLiI6JTaf0PcqhAt+c5rEcuQwo6J/+asLhTAFtgMuAWNSoDRM41OLPzVT6VercCTsiZHNMmTv8OMCKEeHSjczJCPJFccA9tGnvs5h3L+1BJ6WLMh9XArGSa+8Q+1gUyOuqQ+hkxFfp8nmCfvyCL5ngBpFLrkntXl29KG0g12kf4XMc36EFhuGbszB/y81ieqO/jokObRsrpBwL79ySaIvwndU0Ga2JOO8raGpC2784oGEvRKhiYNF539TbKi5ADEVOc="
# sudo=false makes the build run using a container
sudo: false
# I'm putting as many tasks as possible into the Makefile, hence the make depend...
install:
- export PATH=$PATH:$HOME/gopath/bin # travis' worker doesn't seem to do this consistently
- #(cd $GOROOT/src && GOOS=darwin GOARCH=amd64 ./make.bash --no-clean) >/dev/null
- #(cd $GOROOT/src && GOOS=windows GOARCH=amd64 ./make.bash --no-clean) >/dev/null
- #(cd $GOROOT/src && GOOS=linux GOARCH=arm ./make.bash --no-clean) >/dev/null
- make depend
# Everything else in here, we don't put the uploads into an after_success section because
# that can cause the build to succeed even if the artifacts are not actually uploaded
script:
- export NAME=`basename $TRAVIS_BUILD_DIR`
- echo NAME=$NAME
- make travis-test
- export PATH=./.vendor/bin:$PATH
- which gof3r
# Compute code coverage
- go tool cover -func=total.coverprofile > coverage.txt
- export COVERAGE=$(grep "^total:" coverage.txt | grep -o "[0-9\.]*")
- export BUILD=${TRAVIS_BUILD_NUMBER}
- if [[ "${TRAVIS_PULL_REQUEST}" != "false" ]]; then let BUILD=BUILD-1; fi
- export FILENAME="$(date +%Y-%m-%d)_${BUILD}_Coverage-${COVERAGE}.txt"
- mv coverage.txt $FILENAME
# Post code coverage comment to github
- export CODCOV_URL="https://s3.amazonaws.com/rs-code-coverage/${NAME}/${FILENAME}"
- export JSON_COMMENT="{\"body\":\"Code Coverage is ${COVERAGE}%, details at $CODCOV_URL
(sometimes the URL can take a few minutes to be available)\"}"
- |
if [[ "${TRAVIS_PULL_REQUEST}" != "false" ]]; then
curl -XPOST -s -H "Authorization: token ${GITHUB_TOKEN}" \
-H "Content-Type: application/json" -d "${JSON_COMMENT}" \
"https://api.github.com/repos/rightscale/${NAME}/issues/${TRAVIS_PULL_REQUEST}/comments"
fi
# Deploy code coverage result to S3
- export AWS_ACCESS_KEY_ID=AKIAI4RIGBPD3NP2RQ3Q # code coverage bucket access
- export AWS_SECRET_ACCESS_KEY=${COV_KEY}
- gof3r put -b rs-code-coverage -k ${NAME}/${FILENAME} -m x-amz-acl:public-read < ${FILENAME}
# Deploy code coverage badge to S3
- export COVERAGE_INT=$(echo $COVERAGE | cut -d. -f1)
- export BADGE_FILENAME=cc_badge_${TRAVIS_BRANCH}.svg
- export BADGE_COLOR=$( if [ ${COVERAGE_INT} -gt 80 ] ; then echo brightgreen ; elif [ ${COVERAGE_INT} -gt 40 ] ; then echo yellow ; else echo red ; fi )
- wget "http://img.shields.io/badge/coverage-${COVERAGE}%25-${BADGE_COLOR}.svg" -O ${BADGE_FILENAME}
- gof3r put -b rs-code-coverage -k ${NAME}/${BADGE_FILENAME} -m x-amz-acl:public-read -m cache-control:no-cache -m content-type:image/svg+xml < ${BADGE_FILENAME}