forked from flexera-public/wstunnel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.travis.yml
74 lines (69 loc) · 4.11 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# Travis-CI for Golang projects
# Runs the tests, builds the distribution artifacts, uploads them to S3, and produces a
# code coverage report. The upload is segregated by branch name, so each branch gets its own
# uploaded version. (Note: nothing is automatically garbage collected.)
language: go
go:
- 1.16.x
env:
global:
# RSBIN_KEY= to upload to rightscale-binaries bucket in q&b acct:
- secure: "h3mXpw9vtumQry74Q0ZvOazllSkMfp2U9g34o+OvOOPd9fWVw0orqX7twXhJ+IiQRV74AuBBVVtRnisXIyWaVZyDbmp/UU8ELTYCVnqPZpNiNEyXQFm1EWXixpaiorkwcllp1Q71r+p4OuS2MVNyroFOfZGUfseFPqJrVBkMmk4="
# GITHUB_TOKEN= to push code coverage comment to github
- secure: "jx1ItZpZvTRoqLkc6AhutJyY02yjYBGOEjHHkgcuB6EwgFWMhzBPCO5eh8S5GuEkz+HPeXD297dHIdknighaLAtSB22gVD/iWQFHIZmMg/jyC8BTW2L8g+rsLB4XIqDR7kTKKCy/T1K0QwGQi42REAalPvDDmWLcT6QJnSNNy8Y="
# COV_KEY= code coverage upload keys
- secure: "I80B5qfSbHIU5b7bzf1CjLPQnt3BHaxFKSffVePSx/Tf/2hr7Ky7nhn2W3Np6/V3ieimKk/4Ltf8XkCIOzxncf2q8MFH6yhCRG5ZyUE/Bo2PMRi22sKXlJmjAUEHVIZHSWLlUKpZlM9WBBRUBEl3jLCAQNmbzQJDyTIkYwD6U4I="
# 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=windows GOARCH=amd64 ./make.bash --no-clean) >/dev/null
- #(cd $GOROOT/src && GOOS=darwin GOARCH=amd64 ./make.bash --no-clean) >/dev/null
- #(cd $GOROOT/src && GOOS=linux GOARCH=arm ./make.bash --no-clean) >/dev/null
- make depend
before_script: make build
# 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`
- make travis-test
- which gof3r
# Deploy build result to s3
- export AWS_ACCESS_KEY_ID=AKIAIX3L4RHHIREAHABQ
- export AWS_SECRET_ACCESS_KEY=${RSBIN_KEY}
- make upload
# Compute code coverage
- "echo 'mode: atomic' >_total"
- for f in `find . -name \*.coverprofile`; do tail -n +2 $f >>_total; done
- mv _total total.coverprofile
- go tool cover -func=total.coverprofile > coverage.txt
- export COVERAGE=$(grep "^total:" coverage.txt | grep -o "[0-9\.]*")
- echo "Code Coverage is ${COVERAGE}%"
- 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}
notifications:
slack:
#secure: XOzXMfYmpv7xsycDWrjKkLVuZOOfPpYi8BQDVjHaSVzq233ClyqTktUAfLbPRu27E96+FyGueN7Yb6yYHqijYgycx7X7wcbYrE990xDcAzMXJxj3l3gSEzFgj8mRVqkQ9yB17JqZ9bnNRuoCMg4fjdIoI5GZlDkKOzdDJuGA/xs=