github.com/newrelic/go-agent@v3.26.0+incompatible/build-script.sh (about) 1 # Copyright 2020 New Relic Corporation. All rights reserved. 2 # SPDX-License-Identifier: Apache-2.0 3 4 set -x 5 set -e 6 7 LATEST_VERSION="go1.15" 8 9 # NOTE: Once we get rid of travis for good, this whole section can be removed 10 # along with the .travis.yml file. 11 if [[ -n "$(go version | grep $LATEST_VERSION)" ]] && [[ "$TRAVIS" == "true" ]]; then 12 echo "Installing updated glibc\n" 13 # can we get this from an actual repository? 14 curl -LO 'http://launchpadlibrarian.net/130794928/libc6_2.17-0ubuntu4_amd64.deb' 15 sudo dpkg -i libc6_2.17-0ubuntu4_amd64.deb 16 else 17 echo "Skipping glibc update\n" 18 fi 19 20 pwd=$(pwd) 21 22 # inputs 23 # 1: repo pin; example: github.com/rewrelic/go-agent@v1.9.0 24 pin_go_dependency() { 25 if [[ ! -z "$1" ]]; then 26 echo "Pinning: $1" 27 repo=$(echo "$1" | cut -d '@' -f1) 28 pinTo=$(echo "$1" | cut -d '@' -f2) 29 set +e 30 go get -u "$repo" # this go get will fail to build 31 set -e 32 cd "$GOPATH"/src/"$repo" 33 git checkout "$pinTo" 34 cd - 35 fi 36 } 37 38 go_mod_tidy() { 39 go mod tidy 40 } 41 42 IFS="," 43 for dir in $DIRS; do 44 cd "$pwd/$dir" 45 46 if [ -f "go.mod" ]; then 47 go mod edit -replace github.com/newrelic/go-agent/v3="$pwd"/v3 48 fi 49 50 # Do tidy if we can 51 go_mod_tidy || true 52 53 pin_go_dependency "$PIN" 54 55 # avoid testing v3 code when testing v2 newrelic package 56 if [ "$dir" == "." ]; then 57 rm -rf v3/ 58 else 59 # Only v3 code version 1.9+ needs GRPC dependencies 60 VERSION=$(go version) 61 V1_7="1.7" 62 V1_8="1.8" 63 V1_9="1.9" 64 V1_10="1.10" 65 V1_11="1.11" 66 V1_12="1.12" 67 V1_13="1.13" 68 V1_14="1.14" 69 if [[ "$VERSION" =~ .*"$V1_7".* || "$VERSION" =~ .*"$V1_8".* ]]; then 70 echo "Not installing GRPC for old versions" 71 elif [[ "$VERSION" =~ .*"$V1_9" || "$VERSION" =~ .*"$V1_10" || "$VERSION" =~ .*"$V1_11" || "$VERSION" =~ .*"$V1_12" || "$VERSION" =~ .*"$V1_13" || "$VERSION" =~ .*"$V1_14" ]]; then 72 # install v3 dependencies that support this go version 73 pin_go_dependency "google.golang.org/grpc@v1.31.0" 74 pin_go_dependency "golang.org/x/net/http2@7fd8e65b642006927f6cec5cb4241df7f98a2210" 75 76 # install protobuf once dependencies are resolved 77 go get -u github.com/golang/protobuf/protoc-gen-go 78 else 79 go get -u github.com/golang/protobuf/protoc-gen-go 80 go get -u google.golang.org/grpc 81 fi 82 fi 83 84 # go get is necessary for testing v2 integrations since they do not have 85 # a go.mod file. 86 if [[ $dir =~ "_integrations" ]]; then 87 go get -t ./... 88 fi 89 90 go test -race -benchtime=1ms -bench=. ./... 91 go vet ./... 92 93 # Test again against the latest version of the dependencies to ensure that 94 # our instrumentation is up to date. TODO: Perhaps it is possible to 95 # upgrade all go.mod dependencies to latest master with a go command. 96 if [ -n "$EXTRATESTING" ]; then 97 eval "$EXTRATESTING" 98 go test -race -benchtime=1ms -bench=. ./... 99 fi 100 101 if [[ -n "$(go version | grep $LATEST_VERSION)" ]]; then 102 # golint requires a supported version of Go, which in practice is currently 1.9+. 103 # See: https://github.com/golang/lint#installation 104 # For simplicity, run it on a single Go version. 105 go get -u golang.org/x/lint/golint 106 # do not expect golint to be in the PATH, instead use go list to discover 107 # the path to the binary. 108 $(go list -f {{.Target}} golang.org/x/lint/golint) -set_exit_status ./... 109 110 # only run gofmt on a single version as the format changed from 1.10 to 111 # 1.11. 112 if [ -n "$(gofmt -s -l .)" ]; then 113 exit 1 114 fi 115 fi 116 done