1
- # Copyright 2020 New Relic Corporation. All rights reserved.
1
+ # Copyright 2023 New Relic Corporation. All rights reserved.
2
2
# SPDX-License-Identifier: Apache-2.0
3
-
4
3
name : Go Agent CI
5
-
6
4
on : pull_request
5
+ env :
6
+ # Specifies which go version to run integration tests on
7
+ INTEGRATION_TESTS_GO_VERSION : 1.21.5
7
8
8
9
jobs :
9
10
go-agent-v3 :
10
11
runs-on : ubuntu-latest
11
- env :
12
- # Required when using older versions of Go that do not support gomod.
13
- GOPATH : ${{ github.workspace }}
14
-
15
12
strategy :
16
13
# if one test fails, do not abort the rest
17
14
fail-fast : false
18
15
matrix :
19
16
include :
20
- - go-version : 1.19.x
17
+ # Core Tests on 3 most recent major Go versions
18
+ - go-version : 1.19.0
21
19
dirs : v3/newrelic,v3/internal,v3/examples
22
- - go-version : 1.20.x
20
+ - go-version : 1.20.0
23
21
dirs : v3/newrelic,v3/internal,v3/examples
24
- - go-version : 1.21.x
22
+ - go-version : 1.21.0
25
23
dirs : v3/newrelic,v3/internal,v3/examples
26
24
27
- # v3 integrations
28
- - go-version : 1.19.x
29
- dirs : v3/integrations/nramqp
30
- - go-version : 1.19.x
31
- dirs : v3/integrations/nrfasthttp
32
- - go-version : 1.19.x
33
- dirs : v3/integrations/nrsarama
34
- - go-version : 1.19.x
35
- dirs : v3/integrations/logcontext/nrlogrusplugin
36
- # extratesting: go get -u github.com/sirupsen/logrus@master
37
- - go-version : 1.19.x
38
- dirs : v3/integrations/logcontext-v2/nrlogrus
39
- # extratesting: go get -u github.com/sirupsen/logrus@master
40
- - go-version : 1.19.x
41
- dirs : v3/integrations/logcontext-v2/nrzerolog
42
- extratesting : go get -u github.com/rs/zerolog@master
43
- - go-version : 1.19.x
44
- dirs : v3/integrations/logcontext-v2/nrzap
45
- - go-version : 1.19.x
46
- dirs : v3/integrations/logcontext-v2/nrwriter
47
- - go-version : 1.19.x
48
- dirs : v3/integrations/logcontext-v2/zerologWriter
49
- extratesting : go get -u github.com/rs/zerolog@master
50
- - go-version : 1.19.x
51
- dirs : v3/integrations/logcontext-v2/logWriter
52
- - go-version : 1.19.x
53
- dirs : v3/integrations/nrawssdk-v1
54
- extratesting : go get -u github.com/aws/aws-sdk-go@main
55
- - go-version : 1.19.x
56
- dirs : v3/integrations/nrawssdk-v2
57
- extratesting : go get -u github.com/aws/aws-sdk-go-v2@main
58
- - go-version : 1.19.x
59
- dirs : v3/integrations/nrecho-v3
60
- # Test against the latest v3 Echo:
61
- extratesting : go get -u github.com/labstack/echo@v3
62
- # go/new/http no longer stable under go 1.18.x
63
- - go-version : 1.19.x
64
- dirs : v3/integrations/nrecho-v4
65
- extratesting : go get -u github.com/labstack/echo/v4@master
66
- - go-version : 1.19.x
67
- dirs : v3/integrations/nrelasticsearch-v7
68
- extratesting :
go get -u github.com/elastic/go-elasticsearch/[email protected]
69
- - go-version : 1.19.x
70
- dirs : v3/integrations/nrgin
71
- extratesting : go get -u github.com/gin-gonic/gin@master
72
- - go-version : 1.19.x
73
- dirs : v3/integrations/nrgorilla
74
- extratesting : go get -u github.com/gorilla/mux@master
75
- - go-version : 1.19.x
76
- dirs : v3/integrations/nrgraphgophers
77
- - go-version : 1.19.x
78
- dirs : v3/integrations/nrlogrus
79
- - go-version : 1.19.x
80
- dirs : v3/integrations/nrlogxi
81
- extratesting : go get -u github.com/mgutz/logxi@master
82
- - go-version : 1.19.x
83
- dirs : v3/integrations/nrpkgerrors
84
- extratesting : go get -u github.com/pkg/errors@master
85
- - go-version : 1.19.x
86
- dirs : v3/integrations/nrlambda
87
- extratesting : go get -u github.com/aws/aws-lambda-go@master
88
- - go-version : 1.19.x
89
- dirs : v3/integrations/nrmysql
90
- extratesting : go get -u github.com/go-sql-driver/mysql@master
91
- - go-version : 1.19.x
92
- dirs : v3/integrations/nrpq
93
- extratesting : go get -u github.com/lib/pq@master
94
- - go-version : 1.19.x
95
- dirs : v3/integrations/nrpgx5
96
- - go-version : 1.19.x
97
- dirs : v3/integrations/nrpq/example/sqlx
98
- - go-version : 1.19.x
99
- dirs : v3/integrations/nrredis-v7
100
- extratesting : go get -u github.com/go-redis/redis/v7@master
101
- - go-version : 1.19.x
102
- dirs : v3/integrations/nrredis-v9
103
- extratesting : go get -u github.com/redis/go-redis/v9@master
104
- - go-version : 1.19.x
105
- dirs : v3/integrations/nrsqlite3
106
- extratesting : go get -u github.com/mattn/go-sqlite3@master
107
- - go-version : 1.19.x
108
- dirs : v3/integrations/nrsnowflake
109
- - go-version : 1.19.x
110
- dirs : v3/integrations/nrgrpc
111
- extratesting : go get -u google.golang.org/grpc@master
112
- - go-version : 1.19.x
113
- dirs : v3/integrations/nrmicro
114
- # As of Dec 2019, there is a race condition in when using go-micro@master
115
- # in their logging system. Instead, we'll test against the latest
116
- # released version.
117
- # As of Jan 2019, it is impossible to go get the latest micro version.
118
- # As of June 2020, confirmed errors still result
119
- # extratesting: go get -u github.com/micro/go-micro@latest
120
- # If we are using the latest released version to test, we need to use a newer version of go
121
- - go-version : 1.19.x
122
- dirs : v3/integrations/nrnats
123
- extratesting : go get -u github.com/nats-io/nats.go
124
- goproxy : direct
125
- - go-version : 1.19.x
126
- dirs : v3/integrations/nrstan
127
- extratesting : go get -u github.com/nats-io/stan.go/@master
128
- - go-version : 1.19.x
129
- dirs : v3/integrations/nrstan/test
130
- - go-version : 1.19.x
131
- dirs : v3/integrations/nrstan/examples
132
- - go-version : 1.19.x
133
- dirs : v3/integrations/logcontext
134
- extratesting : go get -u github.com/sirupsen/logrus@master
135
- # nrzap only supports the two most recent minor go releases
136
- - go-version : 1.19.x
137
- dirs : v3/integrations/nrzap
138
- - go-version : 1.19.x
139
- dirs : v3/integrations/nrhttprouter
140
- extratesting : go get -u github.com/julienschmidt/httprouter@master
141
- - go-version : 1.19.x
142
- dirs : v3/integrations/nrb3
143
- - go-version : 1.19.x
144
- dirs : v3/integrations/nrmongo
145
- - go-version : 1.19.x
146
- dirs : v3/integrations/nrgraphqlgo,v3/integrations/nrgraphqlgo/example
147
- extratesting : go get -u github.com/graphql-go/graphql@master
148
- - go-version : 1.19.x
149
- dirs : v3/integrations/nrmssql
150
- extratesting : go get -u github.com/microsoft/go-mssqldb@main
151
-
25
+ # Integration Tests on highest Supported Go Version
26
+ - dirs : v3/integrations/nramqp
27
+ - dirs : v3/integrations/nrfasthttp
28
+ - dirs : v3/integrations/nrsarama
29
+ - dirs : v3/integrations/logcontext/nrlogrusplugin
30
+ - dirs : v3/integrations/logcontext-v2/nrlogrus
31
+ - dirs : v3/integrations/logcontext-v2/nrzerolog
32
+ - dirs : v3/integrations/logcontext-v2/nrzap
33
+ - dirs : v3/integrations/logcontext-v2/nrwriter
34
+ - dirs : v3/integrations/logcontext-v2/zerologWriter
35
+ - dirs : v3/integrations/logcontext-v2/logWriter
36
+ - dirs : v3/integrations/nrawssdk-v1
37
+ - dirs : v3/integrations/nrawssdk-v2
38
+ - dirs : v3/integrations/nrecho-v3
39
+ - dirs : v3/integrations/nrecho-v4
40
+ - dirs : v3/integrations/nrelasticsearch-v7
41
+ - dirs : v3/integrations/nrgin
42
+ - dirs : v3/integrations/nrgorilla
43
+ - dirs : v3/integrations/nrgraphgophers
44
+ - dirs : v3/integrations/nrlogrus
45
+ - dirs : v3/integrations/nrlogxi
46
+ - dirs : v3/integrations/nrpkgerrors
47
+ - dirs : v3/integrations/nrlambda
48
+ - dirs : v3/integrations/nrmysql
49
+ - dirs : v3/integrations/nrpq
50
+ - dirs : v3/integrations/nrpgx5
51
+ - dirs : v3/integrations/nrpq/example/sqlx
52
+ - dirs : v3/integrations/nrredis-v7
53
+ - dirs : v3/integrations/nrredis-v9
54
+ - dirs : v3/integrations/nrsqlite3
55
+ - dirs : v3/integrations/nrsnowflake
56
+ - dirs : v3/integrations/nrgrpc
57
+ - dirs : v3/integrations/nrmicro
58
+ - dirs : v3/integrations/nrnats
59
+ - dirs : v3/integrations/nrstan
60
+ - dirs : v3/integrations/nrstan/test
61
+ - dirs : v3/integrations/nrstan/examples
62
+ - dirs : v3/integrations/logcontext
63
+ - dirs : v3/integrations/nrzap
64
+ - dirs : v3/integrations/nrhttprouter
65
+ - dirs : v3/integrations/nrb3
66
+ - dirs : v3/integrations/nrmongo
67
+ - dirs : v3/integrations/nrgraphqlgo,v3/integrations/nrgraphqlgo/example
68
+ - dirs : v3/integrations/nrmssql
152
69
steps :
153
- - name : Install Go
154
- uses : actions/setup-go@v4
155
- with :
156
- go-version : ${{ matrix.go-version }}
157
-
158
70
- name : Checkout Code
159
- uses : actions/checkout@v1
71
+ uses : actions/checkout@v2
160
72
with :
161
- # Required when using older versions of Go that do not support gomod.
162
- # Note the required presence of the /go-agent/ directory at the
163
- # beginning of this path. It is required in order to match the
164
- # ${{ github.workspace }} used by the GOPATH env var. pwd when cloning
165
- # the repo is <something>/go-agent/ whereas ${{ github.workspace }}
166
- # returns <something/go-agent/go-agent/.
167
- path : ./go-agent/src/github.com/newrelic/go-agent
73
+ path : " go-agent"
74
+
75
+
76
+ - name : Build Docker Image
77
+ run : docker build -f ${{ github.workspace }}/go-agent/Dockerfile ${{ github.workspace }} --build-arg GO_VERSION=${{ matrix.go-version || env.INTEGRATION_TESTS_GO_VERSION }} -t go-agent-tests-amd64
168
78
169
- - name : Run Tests
170
- run : bash v3/build-script.sh
171
- env :
172
- DIRS : ${{ matrix.dirs }}
173
- EXTRATESTING : ${{ matrix.extratesting }}
174
- PIN : ${{ matrix.pin }}
175
- GOPROXY : ${{ matrix.goproxy }}
176
- - name : Upload coverage to Codecov
177
- uses : codecov/codecov-action@v3
79
+ - name : Set up Docker container and run tests
80
+ run : |
81
+ IFS=',' read -ra DIRS <<< "${{ matrix.dirs }}"
82
+ for dir in "${DIRS[@]}"; do
83
+ if [ -d "go-agent/$dir" ]; then
84
+ # Create Coverage Report Directory for CodeCov
85
+ coverage_dir="${{ github.workspace }}/coverage-reports"
86
+ mkdir -p "$coverage_dir"
87
+ # Special case for nrnats, which requires direct module proxying
88
+ if [[ "$dir" == *"nrnats"* ]]; then
89
+ docker run -e GOPROXY=direct -e CODECOV_TOKEN=${{ secrets.CODECOV_TOKEN }} -e GITHUB_HEAD_REF=${GITHUB_HEAD_REF} -v "$coverage_dir:/coverage" go-agent-tests-amd64 ./go-agent/run-tests.sh "$dir" "/coverage"
90
+ else
91
+ docker run -e CODECOV_TOKEN=${{ secrets.CODECOV_TOKEN }} -e GITHUB_HEAD_REF=${GITHUB_HEAD_REF} -v "$coverage_dir:/coverage" go-agent-tests-amd64 ./go-agent/run-tests.sh "$dir" "/coverage"
92
+ fi
93
+ else
94
+ echo "Directory /app/$dir does not exist."
95
+ fi
96
+ done
178
97
179
- go-agent-arm64 :
180
- # Run all unit tests on aarch64 emulator to ensure compatibility with AWS
181
- # Graviton instances
98
+ # Arm64 tests
99
+ go-agent-v3-arm64 :
182
100
runs-on : ubuntu-latest
183
101
strategy :
184
- # if one test fails, do not abort the rest
102
+ # if one test fails, do not abort the rest
185
103
fail-fast : false
186
104
matrix :
187
105
include :
188
- - go-version : 1.19.x
106
+ # Core Tests on 3 most recent major Go versions
107
+ - go-version : 1.19.0
108
+ dirs : v3/newrelic,v3/internal,v3/examples
109
+ - go-version : 1.20.0
110
+ dirs : v3/newrelic,v3/internal,v3/examples
111
+ - go-version : 1.21.0
112
+ dirs : v3/newrelic,v3/internal,v3/examples
189
113
steps :
190
- - uses : actions/checkout@v1
191
- with :
192
- # Required when using older versions of Go that do not support gomod.
193
- # Note the required presence of the /go-agent/ directory at the
194
- # beginning of this path. It is required in order to match the
195
- # ${{ github.workspace }} used by the GOPATH env var. pwd when cloning
196
- # the repo is <something>/go-agent/ whereas ${{ github.workspace }}
197
- # returns <something/go-agent/go-agent/.
198
- path : ./go-agent/src/github.com/newrelic/go-agent
199
-
200
- name : Run Tests
201
- id : runcmd
114
+ - name : Checkout Code
115
+ uses : actions/checkout@v2
202
116
with :
203
- arch : aarch64
204
- distro : ubuntu20.04
205
- githubToken : ${{ github.token }}
206
- install : |
207
- DEBIAN_FRONTEND=noninteractive apt-get -qq update
208
- DEBIAN_FRONTEND=noninteractive apt-get -qq install -y wget build-essential
209
- wget -nv https://go.dev/dl/go${{ matrix.go-version }}.linux-arm64.tar.gz
210
- rm -rf /usr/local/go
211
- tar -C /usr/local -xzf go${{ matrix.go-version }}.linux-arm64.tar.gz
212
- run : |
213
- export PATH=$PATH:/usr/local/go/bin
214
- go version
215
- cd v3/newrelic
216
- go mod download github.com/golang/protobuf
217
- go get -t
218
- echo ==== v3/newrelic tests ====
219
- go test ./...
220
- cd ../internal
221
- echo ==== v3/internal tests ====
222
- go test ./...
223
- cd ../examples
224
- echo ==== v3/examples tests ====
225
- go test ./...
117
+ path : " go-agent"
118
+
119
+ - name : Set up QEMU
120
+ uses : docker/setup-qemu-action@v1
121
+
122
+ - name : Set up Docker Buildx
123
+ uses : docker/setup-buildx-action@v1
124
+
125
+ - name : Build Docker Image
126
+ run : |
127
+ docker buildx create --use
128
+ docker buildx build --platform linux/arm64 -f ${{ github.workspace }}/go-agent/Dockerfile ${{ github.workspace }} --build-arg GO_VERSION=${{ matrix.go-version || env.INTEGRATION_TESTS_GO_VERSION }} -t go-agent-tests-arm64 --load
129
+ - name : Run Tests in Docker
130
+ run : |
131
+ IFS=',' read -ra DIRS <<< "${{ matrix.dirs }}"
132
+ for dir in "${DIRS[@]}"; do
133
+ if [ -d "go-agent/$dir" ]; then
134
+ coverage_dir="${{ github.workspace }}/coverage-reports"
135
+ mkdir -p "$coverage_dir"
136
+ docker run -e CODECOV_TOKEN=${{ secrets.CODECOV_TOKEN }} -e GITHUB_HEAD_REF=${GITHUB_HEAD_REF} -v "$coverage_dir:/coverage" go-agent-tests-arm64 ./go-agent/run-tests.sh "$dir" "/coverage"
137
+ else
138
+ echo "Directory /app/$dir does not exist."
139
+ fi
140
+ done
0 commit comments