forked from DataDog/dd-trace-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.yml
391 lines (342 loc) · 12.9 KB
/
config.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
version: 2.1
plain-go114: &plain-go116
working_directory: /home/circleci/dd-trace-go.v1
docker:
- image: circleci/golang:1.16
environment:
GOPATH: "/home/circleci/go"
jobs:
metadata:
<<: *plain-go116
steps:
- checkout
# -mod=readonly is enabled by default starting in go1.16 causing many go
# tools and editor integrations to report problems if the go.sum file is
# not up-to-date, so let's make sure it is.
- run:
name: go.sum up-to-date
command: |
if ! go run -mod=readonly gosum.go; then
# Older go versions, e.g. go1.14 will fail the check above with
# the message below.
#
# go: updates to go.sum needed, disabled by -mod=readonly
#
# Newer versions show which go.sum entries are missing. To get
# useful CI errors for older versions, always print an explicit
# diff when go.sum is not up-to-date.
cp go.sum go.sum.before
go mod tidy
echo "--> go.sum diff:"
diff go.sum.before go.sum
exit 1
fi
- run:
name: milestone
command: |
go run checkmilestone.go
- run:
name: copyright
command: |
go run checkcopyright.go
lint:
<<: *plain-go116
steps:
- checkout
- run:
name: gofmt
command: |
if [ "$(gofmt -e -l . | wc -l)" -gt 0 ]; then
exit 1
fi
- run:
name: goimports
command: |
go install golang.org/x/tools/cmd/goimports
if [ "$(~/go/bin/goimports -e -l -local gopkg.in/DataDog/dd-trace-go.v1 . | wc -l)" -gt 0 ]; then
echo "Run 'goimports -w -local gopkg.in/DataDog/dd-trace-go.v1 .' to format code."
~/go/bin/goimports -d -local gopkg.in/DataDog/dd-trace-go.v1 .
exit 1
fi
- run:
name: lint
command: |
go get -u golang.org/x/lint/golint
curl -L https://git.io/vp6lP | sh # https://github.com/alecthomas/gometalinter#binary-releases
./bin/gometalinter --disable-all --vendor --deadline=60s --enable=golint ./...
test-core:
parameters:
build_tags:
description: "go build tags to use to compile the tests"
default: ""
type: string
goflags:
description: "extra goflags to pass to go test"
default: ""
type: string
resource_class: xlarge
environment: # environment variables for the build itself
TEST_RESULTS: /tmp/test-results # path to where test results will be saved
CI_APP_SERVICE_NAME: dd-trace-go
<<: *plain-go116
steps:
- checkout
- run: mkdir -p $TEST_RESULTS
- run: cp go.sum go.sum.orig
- restore_cache: # restores saved cache if no changes are detected since last run
keys:
- go-mod-v5-core-{{ checksum "go.sum.orig" }}
- run:
name: Testing
command: |
PACKAGE_NAMES=$(go list ./... | grep -v /contrib/ | circleci tests split --split-by=timings --timings-type=classname)
gotestsum --junitfile ${TEST_RESULTS}/gotestsum-report.xml -- $PACKAGE_NAMES -v << parameters.goflags >> -coverprofile=coverage.txt -covermode=atomic -tags "<< parameters.build_tags >>"
- save_cache:
key: go-mod-v5-core-{{ checksum "go.sum.orig" }}
paths:
- "/home/circleci/go"
- store_artifacts: # upload test summary for display in Artifacts
path: /tmp/test-results
destination: raw-test-output
- store_test_results: # upload test results for display in Test Summary
path: /tmp/test-results
- run:
name: Upload coverage report to Codecov
command: bash <(curl -s https://codecov.io/bash)
- upload-to-ci-app:
test-result-path: ${TEST_RESULTS}
ci-app-service-name: ${CI_APP_SERVICE_NAME}
test-contrib:
parameters:
build_tags:
description: "go build tags to use to compile the tests"
default: ""
type: string
goflags:
description: "extra goflags to pass to go test"
default: ""
type: string
resource_class: xlarge
environment: # environment variables for the build itself
TEST_RESULTS: /tmp/test-results # path to where test results will be saved
CI_APP_SERVICE_NAME: dd-trace-go
working_directory: /home/circleci/dd-trace-go.v1
docker:
- image: circleci/golang:1.16
environment:
GOPATH: "/home/circleci/go"
- image: cassandra:3.7
environment:
JVM_OPTS: "-Xms750m -Xmx750m"
- image: circleci/mysql:5.7
environment:
MYSQL_ROOT_PASSWORD: admin
MYSQL_PASSWORD: test
MYSQL_USER: test
MYSQL_DATABASE: test
- image: circleci/postgres:9.5
environment:
POSTGRES_PASSWORD: postgres
POSTGRES_USER: postgres
POSTGRES_DB: postgres
- image: mcr.microsoft.com/mssql/server:2019-latest
environment:
SA_PASSWORD: myPassw0rd
ACCEPT_EULA: Y
- image: consul:1.6.0
- image: redis:3.2
- image: elasticsearch:2
environment:
ES_JAVA_OPTS: "-Xms750m -Xmx750m" # https://github.com/10up/wp-local-docker/issues/6
- image: elasticsearch:5
environment:
ES_JAVA_OPTS: "-Xms750m -Xmx750m" # https://github.com/10up/wp-local-docker/issues/6
- image: elasticsearch:6.8.13
environment:
http.port: 9202-9300
discovery.type: single-node
ES_JAVA_OPTS: "-Xms750m -Xmx750m" # https://github.com/10up/wp-local-docker/issues/6
- image: elasticsearch:7.14.1
environment:
http.port: 9203-9300
discovery.type: single-node
ES_JAVA_OPTS: "-Xms750m -Xmx750m" # https://github.com/10up/wp-local-docker/issues/6
- image: datadog/docker-dd-agent
environment:
DD_APM_ENABLED: "true"
DD_BIND_HOST: "0.0.0.0"
DD_API_KEY: invalid_key_but_this_is_fine
- image: circleci/mongo:latest-ram
- image: memcached:1.5.9
- image: bitnami/zookeeper:latest
environment:
ALLOW_ANONYMOUS_LOGIN: yes
- image: bitnami/kafka:2
environment:
KAFKA_CFG_ZOOKEEPER_CONNECT: localhost:2181
KAFKA_CFG_ADVERTISED_LISTENERS: PLAINTEXT://localhost:9092
KAFKA_CFG_LISTENERS: PLAINTEXT://0.0.0.0:9092
ALLOW_PLAINTEXT_LISTENER: yes
- image: bitnami/kafka:2
environment:
KAFKA_CFG_ZOOKEEPER_CONNECT: localhost:2181
command: [kafka-topics.sh, --create, --topic, gosegtest, --bootstrap-server, localhost:9092]
steps:
- checkout
- run: mkdir -p $TEST_RESULTS
- run: cp go.sum go.sum.orig
- restore_cache: # restores saved cache if no changes are detected since last run
keys:
- go-mod-v5-contrib-{{ checksum "go.sum.orig" }}
- restore_cache:
keys:
- v1-librdkafka-v1.3.0-{{ checksum "/etc/os-release" }}
- run:
name: Install librdkafka v1.3.0
command: |
if [ ! -d /tmp/librdkafka-v1.3.0 ] ; then
echo "building librdkafka"
git clone --branch v1.3.0 https://github.com/edenhill/librdkafka.git /tmp/librdkafka-v1.3.0
(cd /tmp/librdkafka-v1.3.0 && ./configure && make)
fi
echo "installing librdkafka"
(cd /tmp/librdkafka-v1.3.0 && sudo make install)
sudo ldconfig
- save_cache:
key: v1-librdkafka-v1.3.0-{{ checksum "/etc/os-release" }}
paths:
- /tmp/librdkafka-v1.3.0
- run:
name: Wait for MySQL
command: dockerize -wait tcp://localhost:3306 -timeout 1m
- run:
name: Wait for Postgres
command: dockerize -wait tcp://localhost:5432 -timeout 1m
- run:
name: Wait for MS SQL Server
command: dockerize -wait tcp://localhost:1433 -timeout 1m
- run:
name: Wait for Redis
command: dockerize -wait tcp://localhost:6379 -timeout 1m
- run:
name: Wait for ElasticSearch (2)
command: dockerize -wait http://localhost:9200 -timeout 1m
- run:
name: Wait for ElasticSearch (5)
command: dockerize -wait http://localhost:9201 -timeout 1m
- run:
name: Wait for ElasticSearch (6)
command: dockerize -wait http://localhost:9202 -timeout 1m
- run:
name: Wait for ElasticSearch (7)
command: dockerize -wait http://localhost:9203 -timeout 1m
- run:
name: Wait for Datadog Agent
command: dockerize -wait tcp://127.0.0.1:8126 -timeout 1m
- run:
name: Wait for Cassandra
command: dockerize -wait tcp://localhost:9042 -timeout 2m
- run:
name: Wait for Mongo
command: dockerize -wait tcp://localhost:27017 -timeout 1m
- run:
name: Wait for Consul
command: dockerize -wait http://localhost:8500 -timeout 1m
- run:
name: Go module graph (before)
command: go mod graph
- run:
name: Testing integrations
command: |
PACKAGE_NAMES=$(go list ./contrib/... | grep -v -e grpc.v12 -e google.golang.org/api | circleci tests split --split-by=timings --timings-type=classname)
export INTEGRATION=true
gotestsum --junitfile ${TEST_RESULTS}/gotestsum-report.xml -- $PACKAGE_NAMES -v << parameters.goflags >> -coverprofile=coverage.txt -covermode=atomic -tags "<< parameters.build_tags >>"
- run:
name: Go module graph (after)
command: go mod graph
when: always
- store_artifacts: # upload test summary for display in Artifacts
path: /tmp/test-results
destination: raw-test-output
- store_test_results: # upload test results for display in Test Summary
path: /tmp/test-results
- run:
name: Testing outlier google.golang.org/api
command: |
go get google.golang.org/[email protected] # https://github.com/grpc/grpc-go/issues/3726
go mod tidy # Go1.16 doesn't update the sum file correctly after the go get, this tidy fixes it
go test -v ./contrib/google.golang.org/api/...
- run:
name: Testing outlier gRPC v1.2
command: |
# This hacky approach is necessary because running the tests regularly
# do not allow using [email protected] alongside [email protected]
go mod vendor
# Checkout [email protected]
cd vendor/google.golang.org && rm -rf grpc
git clone [email protected]:grpc/grpc-go grpc && cd grpc
git fetch origin && git checkout v1.2.0 && cd ../..
# Checkout [email protected]
cd vendor/github.com/DataDog && rm -rf sketches-go
git clone [email protected]:DataDog/sketches-go && cd sketches-go
git fetch origin && git checkout v1.0.0 && cd ../..
INTEGRATION=true go test -mod=vendor -v ./contrib/google.golang.org/grpc.v12/...
- save_cache:
key: go-mod-v5-contrib-{{ checksum "go.sum.orig" }}
paths:
- "/home/circleci/go"
- run:
name: Upload coverage report to Codecov
command: bash <(curl -s https://codecov.io/bash)
- upload-to-ci-app:
test-result-path: ${TEST_RESULTS}
ci-app-service-name: ${CI_APP_SERVICE_NAME}
commands:
upload-to-ci-app:
parameters:
test-result-path:
description: test result path
type: string
ci-app-service-name:
description: service name
type: string
steps:
- run:
name: Install datadog-ci binary
command: |
if [ -n "${DATADOG_API_KEY}" ]; then
curl -L --fail "https://github.com/DataDog/datadog-ci/releases/latest/download/datadog-ci_linux-x64" --output "/tmp/datadog-ci" && chmod +x "/tmp/datadog-ci"
fi
when: always
- run:
name: Upload test result to datadog ci-app
command: |
if [ -n "${DATADOG_API_KEY}" ]; then
DATADOG_API_KEY=${DATADOG_API_KEY} /tmp/datadog-ci junit upload --service << parameters.ci-app-service-name >> << parameters.test-result-path >>
fi
when: always
workflows:
version: 2
build-and-test:
jobs:
- metadata
- lint
- test-core
- test-contrib
nightly:
triggers:
- schedule:
cron: "0 0 * * *"
filters:
branches:
only:
- main
jobs:
- test-core:
matrix:
parameters:
goflags: [ "-race" ]
- test-contrib:
matrix:
parameters:
goflags: [ "-race" ]