| 
									
										
										
										
											2017-05-17 16:22:58 +02:00
										 |  |  | #!/bin/bash | 
					
						
							|  |  |  | # Issue:  https://github.com/mattn/goveralls/issues/20 | 
					
						
							|  |  |  | # Source: https://github.com/uber/go-torch/blob/63da5d33a225c195fea84610e2456d5f722f3963/.test-cover.sh | 
					
						
							|  |  |  | CI=$1 | 
					
						
							|  |  |  | echo "run for $CI" | 
					
						
							| 
									
										
										
										
											2017-06-13 00:50:55 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-24 01:21:35 +02:00
										 |  |  | # circle-ci | 
					
						
							|  |  |  | # travis-ci | 
					
						
							|  |  |  | # travis-pro | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-13 00:50:55 +02:00
										 |  |  | if [ "$CI" == "circle-ci" ]; then | 
					
						
							|  |  |  |   cd ${GOPATH}/src/github.com/${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME} | 
					
						
							|  |  |  | fi | 
					
						
							| 
									
										
										
										
											2017-05-17 16:22:58 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | echo "mode: count" > profile.cov | 
					
						
							|  |  |  | FAIL=0 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # Standard go tooling behavior is to ignore dirs with leading underscors | 
					
						
							| 
									
										
										
										
											2017-06-13 00:50:55 +02:00
										 |  |  | for dir in $(find . -maxdepth 10 -not -path './vendor/*' -not -path './.git*' -not -path '*/_*' -type d); | 
					
						
							| 
									
										
										
										
											2017-05-17 16:22:58 +02:00
										 |  |  | do | 
					
						
							|  |  |  |   if ls $dir/*.go &> /dev/null; then | 
					
						
							| 
									
										
										
										
											2017-06-13 00:50:55 +02:00
										 |  |  |     go test -v -covermode=count -coverprofile=profile.tmp $dir || FAIL=$? | 
					
						
							| 
									
										
										
										
											2017-05-17 16:22:58 +02:00
										 |  |  |     if [ -f profile.tmp ] | 
					
						
							|  |  |  |     then | 
					
						
							|  |  |  |       tail -n +2 < profile.tmp >> profile.cov | 
					
						
							|  |  |  |       rm profile.tmp | 
					
						
							|  |  |  |     fi | 
					
						
							|  |  |  |   fi | 
					
						
							|  |  |  | done | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # Failures have incomplete results, so don't send | 
					
						
							| 
									
										
										
										
											2018-08-24 01:21:35 +02:00
										 |  |  | [ "$FAIL" -ne 0 ] && exit 1 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # ci not publishing | 
					
						
							|  |  |  | [ "$CI" == "" ] && exit 0 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | if [ "$CODECOV_TOKEN" != "" ]; then | 
					
						
							|  |  |  |  bash <(curl -s https://codecov.io/bash) -t $CODECOV_TOKEN -f profile.cov | 
					
						
							|  |  |  | fi | 
					
						
							|  |  |  | if [ "$COVERALLS_REPO_TOKEN" != "" ] ; then | 
					
						
							| 
									
										
										
										
											2017-06-13 00:50:55 +02:00
										 |  |  |   goveralls -v -coverprofile=profile.cov -service=$CI -repotoken=$COVERALLS_REPO_TOKEN | 
					
						
							| 
									
										
										
										
											2017-05-17 16:22:58 +02:00
										 |  |  | fi |