/
config.yml
433 lines (383 loc) · 14.8 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
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
version: 2.1
plain-go114: &plain-go114
working_directory: /home/circleci/dd-trace-go.v1
docker:
- image: circleci/golang:1.14
environment:
GOPATH: "/home/circleci/go"
jobs:
go1_12-build:
# Validate that the core builds with go1.12
parameters:
build_tags:
description: "go build tags used to compile"
default: ""
type: string
goflags:
description: "extra goflags to pass to go test"
default: ""
type: string
docker:
- image: circleci/golang:1.12
environment:
GOPATH: "/home/circleci/go"
working_directory: /home/circleci/dd-trace-go.v1
steps:
- checkout
- run:
name: build
command: |
# Fixes fatal: unable to access 'https://gopkg.in/yaml.v3/': server certificate verification failed. CAfile: none CRLfile: none
# See https://github.com/DataDog/dd-trace-go/pull/1029
sudo apt update && sudo apt install ca-certificates libgnutls30 -y
go build -v -tags "<< parameters.build_tags >>" ./ddtrace/... ./profiler/... ./internal/appsec/...
metadata:
<<: *plain-go114
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-go114
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
DD_APPSEC_WAF_TIMEOUT: 1s
<<: *plain-go114
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: Enforce some dependencies
command: |
# last version compatible with go1.14, needed for testtraceprof
echo 'replace golang.org/x/net => golang.org/x/net d418f374d30933c6c7db22cf349625c295a5afaa' >> go.mod
- run:
name: Testing
command: |
PACKAGE_NAMES=$(go list ./... | grep -v /contrib/ | circleci tests split --split-by=timings --timings-type=classname)
env DD_APPSEC_ENABLED=$(test "<< parameters.build_tags >>" = appsec && echo -n true) 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)
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
DD_APPSEC_WAF_TIMEOUT: 1s
working_directory: /home/circleci/dd-trace-go.v1
docker:
- image: circleci/golang:1.14
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: Enforce some dependencies
command: |
go get k8s.io/client-go@v0.17.0
go get k8s.io/apimachinery@v0.17.0
go get cloud.google.com/go/pubsub@v1.6.1
# Temporarily enforce this version. 1.9.0 is incompatible with go < 1.16
go get github.com/hashicorp/consul/api@v1.8.1
# github.com/hashicorp/vault/sdk > v0.2.0 doesn't compile with go1.14
go get github.com/hashicorp/vault/sdk@v0.2.0
# Shopify/sarama > v1.22 doesn't compile with go1.14
go get github.com/Shopify/sarama@v1.22.0
# Temporary enforcing gorm to v1.22.4 to avoid the problems of v1.22.5
go get -v gorm.io/gorm@v1.22.4
# gofiber >= v2.27.0 has a transitive dependency on a newer version of
# golang.org/x/net that requires Go >= 1.15, breaking our build
go get github.com/gofiber/fiber/v2@v2.26.0
# The following gorm drivers need to be pinned, or newer versions
# will force an update to gorm.io/gorm, which we are also trying to
# pin above.
go get gorm.io/driver/mysql@v1.2.3
go get gorm.io/driver/postgres@v1.2.3
go get gorm.io/driver/sqlserver@v1.2.1
go get github.com/zenazn/goji@v1.0.1
- 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 DD_APPSEC_ENABLED=$(test "<< parameters.build_tags >>" = appsec && echo -n true)
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/grpc@v1.29.0 # https://github.com/grpc/grpc-go/issues/3726
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 grpc-go@v1.2.0 alongside sketches-go@v1.0.0
go mod vendor
# Checkout grpc-go@v1.2.0
cd vendor/google.golang.org && rm -rf grpc
git clone git@github.com:grpc/grpc-go grpc && cd grpc
git fetch origin && git checkout v1.2.0 && cd ../..
# Checkout sketches-go@v1.0.0
cd vendor/github.com/DataDog && rm -rf sketches-go
git clone git@github.com: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)
workflows:
version: 2
build-and-test:
jobs:
- go1_12-build:
matrix:
parameters:
build_tags: [ "", "appsec" ]
- metadata
- lint
- test-core:
matrix:
parameters:
build_tags: [ "", "appsec" ]
- test-contrib:
matrix:
parameters:
build_tags: [ "", "appsec" ]
nightly:
triggers:
- schedule:
cron: "0 0 * * *"
filters:
branches:
only:
- v1
jobs:
- go1_12-build:
matrix:
parameters:
build_tags: [ "", "appsec" ]
goflags: [ "-race" ]
- test-core:
matrix:
parameters:
build_tags: [ "", "appsec" ]
goflags: [ "-race" ]
- test-contrib:
matrix:
parameters:
build_tags: [ "", "appsec" ]
goflags: [ "-race" ]