forked from open-telemetry/opentelemetry-collector
-
Notifications
You must be signed in to change notification settings - Fork 0
477 lines (476 loc) · 16.7 KB
/
build-and-test.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
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
name: build-and-test
on:
push:
branches: [master]
tags:
- 'v[0-9]+.[0-9]+.[0-9]+*'
pull_request:
env:
TEST_RESULTS: testbed/tests/results/junit/results.xml
jobs:
windows-test:
runs-on: windows-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v2
- name: Setup Go
uses: actions/[email protected]
with:
go-version: 1.15
- name: Setup Go Environment
run: |
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
shell: bash
- name: Cache Go Modules
uses: actions/cache@v2
env:
cache-name: cache-go-modules
with:
path: \Users\runneradmin\go\pkg\mod
key: go-pkg-mod-${{ runner.os }}-${{ hashFiles('./go.mod') }}
- name: Run Unit tests
run: go test ./...
- name: GitHub Issue Generator
if: ${{ failure() && github.ref == 'ref/head/master' }}
run: |
go run cmd/issuegenerator/main.go $TEST_RESULTS
setup-environment:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.splitloadtest.outputs.matrix }}
steps:
- name: Checkout Repo
uses: actions/checkout@v2
- name: Setup Go
uses: actions/[email protected]
with:
go-version: 1.15
- name: Setup Go Environment
run: |
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
- name: Cache Go Modules
uses: actions/cache@v2
env:
cache-name: cache-go-modules
with:
path: /home/runner/go/pkg/mod
key: go-pkg-mod-${{ runner.os }}-${{ hashFiles('./go.mod') }}
- name: Restore tools binaries
id: tool-cache
uses: actions/cache@v2
env:
cache-name: cache-tool-binaries
with:
path: /home/runner/go/bin
key: tools-${{ runner.os }}-${{ hashFiles('./internal/tools/go.mod') }}
- name: Install tools
if: steps.tool-cache.outputs.cache-hit != 'true'
run: make install-tools
- name: Split Loadtest Jobs
id: splitloadtest
run: ./.github/workflows/scripts/setup_load_tests.sh
- name: Upload Tool Binaries
uses: actions/upload-artifact@v1
with:
name: tool-binaries
path: /home/runner/go/bin
lint:
runs-on: ubuntu-latest
needs: [setup-environment]
steps:
- name: Checkout Repo
uses: actions/checkout@v2
- name: Setup Go
uses: actions/[email protected]
with:
go-version: 1.15
- name: Setup Go Environment
run: |
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
- name: Cache Go Modules
uses: actions/cache@v2
env:
cache-name: cache-go-modules
with:
path: /home/runner/go/pkg/mod
key: go-pkg-mod-${{ runner.os }}-${{ hashFiles('./go.mod') }}
- name: Download Tool Binaries
uses: actions/download-artifact@v1
with:
name: tool-binaries
path: /home/runner/go/bin
- name: Add Permissions to Tool Binaries
run: chmod -R +x /home/runner/go/bin
- name: Lint
run: make -j4 gochecklicense goimpi golint gomisspell
- name: Gen Metadata
run: make genmdata
- name: Check generated metadata
run: git diff --exit-code || (echo 'Generated code is out of date, please run "make genmdata" and commit the changes in this PR.' && exit 1)
cross-compile:
runs-on: ubuntu-latest
needs: [setup-environment]
steps:
- name: Checkout Repo
uses: actions/checkout@v2
- name: Setup Go
uses: actions/[email protected]
with:
go-version: 1.15
- name: Setup Go Environment
run: |
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
- name: Cache Go Modules
uses: actions/cache@v2
env:
cache-name: cache-go-modules
with:
path: /home/runner/go/pkg/mod
key: go-pkg-mod-${{ runner.os }}-${{ hashFiles('./go.mod') }}
- name: Download Tool Binaries
uses: actions/download-artifact@v1
with:
name: tool-binaries
path: /home/runner/go/bin
- name: Add Permissions to Tool Binaries
run: chmod -R +x /home/runner/go/bin
- name: Build Collector for All Architectures
run: grep ^binaries-all-sys Makefile|fmt -w 1|tail -n +2|xargs make
- name: Create Collector Binaries Archive
run: tar -cvf bin.tar ./bin
- name: Upload Collector Binaries
uses: actions/upload-artifact@v1
with:
name: collector-binaries
path: ./bin.tar
loadtest:
runs-on: ubuntu-latest
needs: [setup-environment]
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.setup-environment.outputs.matrix) }}
steps:
- name: Checkout Repo
uses: actions/checkout@v2
- name: Setup Go
uses: actions/[email protected]
with:
go-version: 1.15
- name: Setup Go Environment
run: |
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
- name: Cache Go Modules
uses: actions/cache@v2
env:
cache-name: cache-go-modules
with:
path: /home/runner/go/pkg/mod
key: go-pkg-mod-${{ runner.os }}-${{ hashFiles('./go.mod') }}
- name: Download Tool Binaries
uses: actions/download-artifact@v1
with:
name: tool-binaries
path: /home/runner/go/bin
- name: Add Permissions to Tool Binaries
run: chmod -R +x /home/runner/go/bin
- name: Install fluentbit
if: ${{ contains(matrix.test, 'Log10kDPS') }}
run: |
wget https://packages.fluentbit.io/ubuntu/bionic/pool/main/t/td-agent-bit/td-agent-bit_1.5.3_amd64.deb
sudo dpkg -i ./td-agent-bit*.deb
echo "/opt/td-agent-bit/bin" >> $GITHUB_PATH
sudo ln -s /opt/td-agent-bit/bin/td-agent-bit /usr/local/bin/fluent-bit
- run: mkdir -p results && touch results/TESTRESULTS.md
- name: Loadtest
run: make testbed-loadtest
env:
TEST_ARGS: "-test.run=${{ matrix.test }}"
- name: Create Test Result Archive # some test results have invalid characters
if: ${{ failure() || success() }}
continue-on-error: true
run: tar -cvf test_results.tar testbed/tests/results
- name: Upload Test Results
if: ${{ failure() || success() }}
continue-on-error: true
uses: actions/upload-artifact@v1
with:
name: test-results
path: test_results.tar
- name: GitHub Issue Generator
if: ${{ failure() && github.ref == 'ref/head/master' }}
run: |
go run cmd/issuegenerator/main.go $TEST_RESULTS
correctness:
runs-on: ubuntu-latest
needs: [setup-environment]
steps:
- name: Checkout Repo
uses: actions/checkout@v2
- name: Setup Go
uses: actions/[email protected]
with:
go-version: 1.15
- name: Setup Go Environment
run: |
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
- name: Cache Go Modules
uses: actions/cache@v2
env:
cache-name: cache-go-modules
with:
path: /home/runner/go/pkg/mod
key: go-pkg-mod-${{ runner.os }}-${{ hashFiles('./go.mod') }}
- name: Download Tool Binaries
uses: actions/download-artifact@v1
with:
name: tool-binaries
path: /home/runner/go/bin
- name: Add Permissions to Tool Binaries
run: chmod -R +x /home/runner/go/bin
- name: Loadtest
run: make testbed-correctness
- name: GitHub Issue Generator
if: ${{ failure() && github.ref == 'ref/head/master' }}
run: |
go run cmd/issuegenerator/main.go $TEST_RESULTS
build-package:
runs-on: ubuntu-latest
needs: [cross-compile]
strategy:
fail-fast: false
matrix:
package_type: ["deb", "rpm"]
steps:
- name: Checkout Repo
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Setup Go
uses: actions/[email protected]
with:
go-version: 1.15
- name: Setup Go Environment
run: |
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
mkdir bin/
- name: Install Ruby
uses: actions/setup-ruby@v1
with:
ruby-version: '2.6'
- name: Install fpm
run: gem install --no-document fpm -v 1.11.0
- name: Download Tool Binaries
uses: actions/download-artifact@v1
with:
name: tool-binaries
path: /home/runner/go/bin
- name: Add Permissions to Tool Binaries
run: chmod -R +x /home/runner/go/bin
- name: Download Collector Binaries
uses: actions/download-artifact@v1
with:
name: collector-binaries
- name: Extract Binaries Archive
run: tar -xvf collector-binaries/bin.tar
- name: Set Release Tag
id: github_tag
run: ./.github/workflows/scripts/set_release_tag.sh
- name: Build ${{ matrix.package_type }} amd64 package
run: ./internal/buildscripts/packaging/fpm/${{ matrix.package_type }}/build.sh "${{ steps.github_tag.outputs.tag }}" "amd64" "./dist/"
- name: Build ${{ matrix.package_type }} arm64 package
run: ./internal/buildscripts/packaging/fpm/${{ matrix.package_type }}/build.sh "${{ steps.github_tag.outputs.tag }}" "arm64" "./dist/"
- name: Test ${{ matrix.package_type }} package
run: |
if [[ "${{ matrix.package_type }}" = "deb" ]]; then
./internal/buildscripts/packaging/fpm/test.sh dist/otel-collector*amd64.deb
else
./internal/buildscripts/packaging/fpm/test.sh dist/otel-collector*x86_64.rpm
fi
- name: Upload Packages
uses: actions/upload-artifact@v1
with:
name: build-packages
path: ./dist
windows-msi:
runs-on: windows-latest
needs: [cross-compile]
steps:
- name: Checkout Repo
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Setup Go
uses: actions/[email protected]
with:
go-version: 1.15
- name: Setup Go Environment
run: |
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
mkdir bin/
- name: Cache Go Modules
uses: actions/cache@v2
env:
cache-name: cache-go-modules
with:
path: \Users\runneradmin\go\pkg\mod
key: go-pkg-mod-${{ runner.os }}-${{ hashFiles('./go.mod') }}
- name: Download Binaries
uses: actions/download-artifact@v1
with:
name: collector-binaries
- name: Extract Binaries Archive
run: tar -xvf collector-binaries/bin.tar
- name: Install Wix Toolset
run: .\internal\buildscripts\packaging\msi\make.ps1 Install-Tools
- name: Build MSI
run: |
$Version = if ($env:GITHUB_REF -match '^refs/tags/(\d+\.\d+\.\d+)') { $Matches[1] } else { "0.0.1" }
.\internal\buildscripts\packaging\msi\make.ps1 New-MSI -Version $Version
- name: Validate MSI
run: .\internal\buildscripts\packaging\msi\make.ps1 Confirm-MSI
- name: Upload MSI
uses: actions/upload-artifact@v1
with:
name: msi-binaries
path: ./dist
publish-dev:
runs-on: ubuntu-latest
needs: [build-package, windows-msi]
if: (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/')) && github.repository == 'open-telemetry/opentelemetry-collector'
steps:
- name: Checkout Repo
uses: actions/checkout@v2
- name: Setup Go
uses: actions/[email protected]
with:
go-version: 1.15
- name: Setup Go Environment
run: |
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
mkdir bin/ dist/
- name: Download Tool Binaries
uses: actions/download-artifact@v1
with:
name: tool-binaries
path: /home/runner/go/bin
- name: Add Permissions to Tool Binaries
run: chmod -R +x /home/runner/go/bin
- name: Download Binaries
uses: actions/download-artifact@v1
with:
name: collector-binaries
- name: Extract Binaries Archive
run: tar -xvf collector-binaries/bin.tar
- name: Download Packages
uses: actions/download-artifact@v1
with:
name: build-packages
path: ./dist
- name: Download MSI Packages
uses: actions/download-artifact@v1
with:
name: msi-binaries
path: ./dist
- name: Add Permissions to Tool Binaries
run: chmod -R +x ./dist
- name: Verify Distribution Files Exist
id: check
run: ./.github/workflows/scripts/verify-dist-files-exist.sh
- name: Build Docker Image
if: steps.check.outputs.passed == 'true'
run: |
make docker-otelcol
docker tag otelcol:latest otel/opentelemetry-collector-dev:$GITHUB_SHA
docker tag otelcol:latest otel/opentelemetry-collector-dev:latest
- name: Push Docker Image
if: steps.check.outputs.passed == 'true'
run: |
docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD
docker push otel/opentelemetry-collector-dev:$GITHUB_SHA
docker push otel/opentelemetry-collector-dev:latest
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME}}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD}}
publish-stable:
runs-on: ubuntu-latest
needs: [build-package, windows-msi]
if: startsWith(github.ref, 'refs/tags/') && github.repository == 'open-telemetry/opentelemetry-collector'
steps:
- name: Checkout Repo
uses: actions/checkout@v2
- name: Setup Go
uses: actions/[email protected]
with:
go-version: 1.15
- name: Setup Go Environment
run: |
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
mkdir bin/ dist/
- name: Download Tool Binaries
uses: actions/download-artifact@v1
with:
name: tool-binaries
path: /home/runner/go/bin
- name: Add Permissions to Tool Binaries
run: chmod -R +x /home/runner/go/bin
- name: Download Binaries
uses: actions/download-artifact@v1
with:
name: collector-binaries
- name: Extract Binaries Archive
run: tar -xvf collector-binaries/bin.tar
- name: Download Packages
uses: actions/download-artifact@v1
with:
name: build-packages
path: ./dist
- name: Download MSI Packages
uses: actions/download-artifact@v1
with:
name: msi-binaries
path: ./dist
- name: Add Permissions to Tool Binaries
run: chmod -R +x ./dist
- name: Verify Distribution Files Exist
id: check
run: ./.github/workflows/scripts/verify-dist-files-exist.sh
- name: Set Release Tag
id: github_tag
run: ./.github/workflows/scripts/set_release_tag.sh
- name: Build Docker Image
if: steps.check.outputs.passed == 'true'
run: |
make docker-otelcol
docker tag otelcol:latest otel/opentelemetry-collector:$RELEASE_TAG
docker tag otelcol:latest otel/opentelemetry-collector:latest
env:
RELEASE_TAG: ${{ steps.github_tag.outputs.tag }}
- name: Push Docker Image
if: steps.check.outputs.passed == 'true'
run: |
docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD
docker push otel/opentelemetry-collector:$RELEASE_TAG
docker push otel/opentelemetry-collector:latest
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME}}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD}}
RELEASE_TAG: ${{ steps.github_tag.outputs.tag }}
- name: Create Github Release
if: steps.check.outputs.passed == 'true'
run: |
cp bin/* dist/
cd dist && shasum -a 256 * > checksums.txt
ghr -t $GITHUB_TOKEN -u "GitHub Action" -r opentelemetry-collector --replace $RELEASE_TAG dist/
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_TAG: ${{ steps.github_tag.outputs.tag }}