-
Notifications
You must be signed in to change notification settings - Fork 238
840 lines (740 loc) · 30.6 KB
/
CI.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
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License").
# You may not use this file except in compliance with the License.
# A copy of the License is located at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# or in the "license" file accompanying this file. This file is distributed
# on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
# express or implied. See the License for the specific language governing
# permissions and limitations under the License.
name: C/I
on:
push:
branches:
- main
- release/v*
- dev
- test/*
paths-ignore:
- '.github/**'
- '!.github/config/testcases.json'
- '!.github/workflows/CI.yml'
- '!.github/workflows/CI-Operator.yml'
- '**.md'
- 'tools/workflow/**'
# from collector and contrib repo
repository_dispatch:
types: [dependency-build, workflow-run]
env:
IMAGE_NAME: aws-otel-collector
PACKAGING_ROOT: build/packages
ECR_REPO: aws-otel-test/adot-collector-integration-test
# TF_VAR_patch: 'true'
PKG_SIGN_PRIVATE_KEY_NAME: aoc-linux-pkg-signing-gpg-key
WIN_UNSIGNED_PKG_BUCKET: aoc-aws-signer-unsigned-artifact-src
WIN_SIGNED_PKG_BUCKET: aoc-aws-signer-signed-artifact-dest
WIN_UNSIGNED_PKG_FOLDER: OTelCollectorAuthenticode/AuthenticodeSigner-SHA256-RSA
WIN_SIGNED_PKG_FOLDER: OTelCollectorAuthenticode/AuthenticodeSigner-SHA256-RSA
SSM_PACKAGE_NAME: "testAWSDistroOTel-Collector"
EKS_ARM_64_AMP_ENDPOINT: "https://aps-workspaces.us-west-2.amazonaws.com/workspaces/ws-e0c3c74f-7fdf-4e90-87d2-a61f52df40cd"
EKS_ARM_64_CLUSTER_NAME: "collector-ci-arm64-1-21"
EKS_ARM_64_REGION: "us-west-2"
TESTING_FRAMEWORK_REPO: aws-observability/aws-otel-test-framework
GITHB_RUN_ID: ${{ github.run_id }}
DDB_TABLE_NAME: BatchTestCache
MAX_JOBS: 110
BATCH_INCLUDED_SERVICES: EKS,ECS,EC2,EKS_ARM64,EKS_FARGATE
GO_VERSION: ~1.20.6
concurrency:
group: ci-batched${{ github.ref_name }}
cancel-in-progress: true
permissions:
id-token: write
contents: read
jobs:
validate-markdown:
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install markdown-link-check
run: npm install -g markdown-link-check
- name: Run markdown-link-check in the developers docs
run: |
find ./docs/developers -name "*.md" | xargs markdown-link-check \
--verbose \
--config .github/config/markdown-links-config.json \
|| { echo "Check that anchor links are lowercase"; exit 1; }
- name: Run markdown-link-check on main documentation
run: |
markdown-link-check \
--verbose \
--config .github/config/markdown-links-config.json \
README.md CONTRIBUTING.md CODE_OF_CONDUCT.md \
|| { echo "Check that anchor links are lowercase"; exit 1; }
create-test-ref:
runs-on: ubuntu-latest
needs: validate-markdown
outputs:
testRef: ${{ steps.setRef.outputs.ref }}
steps:
- name: Set testRef output
id: setRef
run: |
if [[ ${{ github.ref_name }} == release/v* ]]; then
echo "ref=${{github.ref_name}}" >> $GITHUB_OUTPUT
else
echo "ref=terraform" >> $GITHUB_OUTPUT
fi
build-aotutil:
runs-on: ubuntu-latest
needs: create-test-ref
steps:
- name: Check out testing framework
uses: actions/checkout@v3
with:
repository: ${{ env.TESTING_FRAMEWORK_REPO }}
path: testing-framework
ref: ${{ needs.create-test-ref.outputs.testRef }}
- name: Set up Go 1.x
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
cache-dependency-path: testing-framework/cmd/aotutil/go.sum
- name: Build aotutil
run: cd testing-framework/cmd/aotutil && make build
- name: Cache aotutil
uses: actions/cache@v3
with:
key: "aotutil_${{ hashFiles('testing-framework/cmd/aotutil/*.go') }}_${{ hashFiles('testing-framework/cmd/aotutil/go.sum') }}"
path: testing-framework/cmd/aotutil/aotutil
build:
needs:
- create-test-ref
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: apply patches
run: make apply-patches
# Set up building environment, patch the dev repo code on dispatch events.
- name: Set up Go 1.x
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
- name: Checkout dev opentelemetry-collector-contrib
if: github.event_name == 'repository_dispatch' && github.event.action == 'dependency-build'
uses: actions/checkout@v3
with:
repository: ${{ github.repository_owner }}/opentelemetry-collector-contrib
ref: main
path: pkg/opentelemetry-collector-contrib
- name: Checkout dev opentelemetry-collector
if: github.event_name == 'repository_dispatch' && github.event.action == 'dependency-build'
uses: actions/checkout@v3
with:
repository: ${{ github.repository_owner }}/opentelemetry-collector
ref: main
path: pkg/opentelemetry-collector
- name: append replace statement to go.mod to build with dev repo
if: github.event_name == 'repository_dispatch' && github.event.action == 'dependency-build'
run: |
echo "replace github.com/open-telemetry/opentelemetry-collector-contrib/exporter/awsxrayexporter => ./pkg/opentelemetry-collector-contrib/exporter/awsxrayexporter" >> go.mod
echo "replace go.opentelemetry.io/collector => ./pkg/opentelemetry-collector" >> go.mod
cat go.mod
ls pkg
- name: Cache binaries
id: cached_binaries
uses: actions/cache@v3
with:
key: "cached_binaries_${{ github.run_id }}"
path: build
# Unit Test and attach test coverage badge
- name: Unit Test
if: steps.cached_binaries.outputs.cache-hit != 'true'
run: make gotest
- name: Upload Coverage report to CodeCov
if: steps.cached_binaries.outputs.cache-hit != 'true'
uses: codecov/codecov-action@v3
with:
file: ./coverage.txt
# Build and archive binaries into cache.
- name: Build Binaries
if: steps.cached_binaries.outputs.cache-hit != 'true'
run: make build
# upload the binaries to artifact as well because cache@v3 hasn't support windows
- name: Upload
uses: actions/upload-artifact@v3
with:
name: binary_artifacts
path: build
retention-days: 1
packaging-msi:
needs: build
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- name: Download built artifacts
uses: actions/download-artifact@v3
with:
name: binary_artifacts
path: build
- name: Display structure of downloaded files
run: ls -R
- name: Create msi file using candle and light
run: .\tools\packaging\windows\create_msi.ps1
- name: Install AWS Cli v2
run: |
Invoke-WebRequest -Uri "https://awscli.amazonaws.com/AWSCLIV2.msi" -OutFile "AWSCLIV2.msi"
msiexec.exe /i AWSCLIV2.msi /passive
[System.Environment]::SetEnvironmentVariable('Path',$Env:Path + ";C:\\Program Files\\Amazon\\AWSCLIV2",'User')
- uses: aws-actions/[email protected]
with:
role-to-assume: ${{ secrets.COLLECTOR_PROD_PKG_SIGNER_ROLE_ARN }}
aws-region: us-west-2
- name: Sign windows artifacts
run: |
$pkgfile = "build\packages\windows\amd64\aws-otel-collector.msi"
$hashobj = Get-FileHash -Algorithm sha256 $pkgfile
$hash = $hashobj.Hash
$create_date = Get-Date -format s
aws s3api put-object "--body" $pkgfile "--bucket" ${{ env.WIN_UNSIGNED_PKG_BUCKET }} "--key" ${{ env.WIN_UNSIGNED_PKG_FOLDER }}/aws-otel-collector-$hash.msi
$objkey = ""
for ($num = 1 ; $num -le 60 ; $num++) { # 60 * 10 = 600s = 10min timeout
Start-Sleep -s 10
Write-Output "Poll number $num"
$objkey = aws s3api list-objects "--bucket" ${{ env.WIN_SIGNED_PKG_BUCKET }} "--prefix" ${{ env.WIN_SIGNED_PKG_FOLDER }}/aws-otel-collector-$hash.msi "--output" text "--query" "Contents[?LastModified>'$create_date'].Key|[0]"
if ($objkey -ne "None") {
Write-Output "Found: $objkey"
break
} else {
Write-Output "$objkey returned, obj not available yet, try again later"
}
}
if ($objkey -eq "None") {
Throw "Could not find the signed artifact"
}
aws s3api get-object "--bucket" ${{ env.WIN_SIGNED_PKG_BUCKET }} "--key" $objkey $pkgfile
- name: Verify package signature
run: |
$pkgfile = "build\packages\windows\amd64\aws-otel-collector.msi"
$sig = Get-AuthenticodeSignature $pkgfile
$status = $sig.Status
if ($status -ne "Valid") {
Throw "Invalid signature found: $status"
}
Write-Output "Valid signature found from the package"
- name: Upload the msi
uses: actions/upload-artifact@v3
with:
name: msi_artifacts
path: "${{ env.PACKAGING_ROOT }}"
retention-days: 1
packaging-rpm:
runs-on: ubuntu-latest
needs: build
steps:
# Build and archive rpms into cache.
- uses: actions/checkout@v3
- name: Cache rpms
id: cached_rpms
uses: actions/cache@v3
with:
key: "cached_rpms_${{ github.run_id }}"
path: "${{ env.PACKAGING_ROOT }}"
- name: restore cached binaries
if: steps.cached_rpms.outputs.cache-hit != 'true'
uses: actions/cache@v3
with:
key: "cached_binaries_${{ github.run_id }}"
path: build
- name: Display structure of downloaded files
run: ls -R
- name: Build RPM
if: steps.cached_rpms.outputs.cache-hit != 'true'
run: |
ARCH=x86_64 SOURCE_ARCH=amd64 DEST=$PACKAGING_ROOT/linux/amd64 tools/packaging/linux/create_rpm.sh
ARCH=aarch64 SOURCE_ARCH=arm64 DEST=$PACKAGING_ROOT/linux/arm64 tools/packaging/linux/create_rpm.sh
- uses: aws-actions/[email protected]
with:
role-to-assume: ${{ secrets.COLLECTOR_PROD_PKG_SIGNER_ROLE_ARN }}
aws-region: us-west-2
- name: Download Package Signing GPG key
if: steps.cached_rpms.outputs.cache-hit != 'true'
run: |
aws secretsmanager get-secret-value --region us-west-2 --secret-id "$PKG_SIGN_PRIVATE_KEY_NAME" | jq -r ".SecretString" > pkg_sign_private.key
md5sum pkg_sign_private.key
- name: Import Package Signing GPG Key
if: steps.cached_rpms.outputs.cache-hit != 'true'
run: |
gpg --import pkg_sign_private.key
gpg --list-keys
gpg --armor --export -a "[email protected]" > pkg_sign_public.key
rpm --import pkg_sign_public.key
echo "%_gpg_name [email protected]" > ~/.rpmmacros
md5sum pkg_sign_public.key
shred -fuvz pkg_sign_private.key
- name: Sign RPM Pakcage
if: steps.cached_rpms.outputs.cache-hit != 'true'
run: |
rpmsign --addsign $PACKAGING_ROOT/linux/*/*.rpm
- name: Remove Package Signing GPG Key from local GPG Key Ring
if: steps.cached_rpms.outputs.cache-hit != 'true'
run: |
gpg --fingerprint --with-colons [email protected] grep "^fpr" | sed -n 's/^fpr:::::::::\([[:alnum:]]\+\):/\1/p' | xargs gpg --batch --yes --delete-secret-keys
gpg --list-secret-keys
packaging-deb:
runs-on: ubuntu-latest
needs: build
steps:
# Build and archive debs into cache.
- uses: actions/checkout@v3
- name: Cache Debs
id: cached_debs
uses: actions/cache@v3
with:
key: "cached_debs_${{ github.run_id }}"
path: ${{ env.PACKAGING_ROOT }}
- name: restore cached binaries
if: steps.cached_debs.outputs.cache-hit != 'true'
uses: actions/cache@v3
with:
key: "cached_binaries_${{ github.run_id }}"
path: build
- name: Build Debs
if: steps.cached_debs.outputs.cache-hit != 'true'
run: |
ARCH=amd64 DEST=$PACKAGING_ROOT/debian/amd64 tools/packaging/debian/create_deb.sh
ARCH=arm64 DEST=$PACKAGING_ROOT/debian/arm64 tools/packaging/debian/create_deb.sh
- uses: aws-actions/[email protected]
with:
role-to-assume: ${{ secrets.COLLECTOR_PROD_PKG_SIGNER_ROLE_ARN }}
aws-region: us-west-2
- name: Download Package Signing GPG key
if: steps.cached_debs.outputs.cache-hit != 'true'
run: |
aws secretsmanager get-secret-value --region us-west-2 --secret-id "$PKG_SIGN_PRIVATE_KEY_NAME" | jq -r ".SecretString" > pkg_sign_private.key
md5sum pkg_sign_private.key
- name: Import Package Signing GPG Key
if: steps.cached_debs.outputs.cache-hit != 'true'
run: |
gpg --import pkg_sign_private.key
gpg --list-secret-keys
shred -fuvz pkg_sign_private.key
- name: Sign DEB Pakcage
if: steps.cached_debs.outputs.cache-hit != 'true'
run: |
sudo apt install -y dpkg-sig
dpkg-sig --sign origin -k "[email protected]" $PACKAGING_ROOT/debian/*/*.deb
- name: Remove Package Signing GPG Key from local GPG Key Ring
if: steps.cached_debs.outputs.cache-hit != 'true'
run: |
gpg --fingerprint --with-colons [email protected] grep "^fpr" | sed -n 's/^fpr:::::::::\([[:alnum:]]\+\):/\1/p' | xargs gpg --batch --yes --delete-secret-keys
gpg --list-secret-keys
test-control-stript:
runs-on: ubuntu-latest
needs: [packaging-deb]
steps:
- name: Checkout
if: ${{ needs.changes.outputs.changed == 'true' }}
uses: actions/checkout@v3
- name: Restore cached Debs
if: ${{ needs.changes.outputs.changed == 'true' }}
uses: actions/cache@v3
with:
key: "cached_debs_${{ github.run_id }}"
path: ${{ env.PACKAGING_ROOT }}
- name: Execute tests
if: ${{ needs.changes.outputs.changed == 'true' }}
run: |
sudo ./.github/scripts/test-collector-ctl.sh $PACKAGING_ROOT/debian/amd64/aws-otel-collector.deb ./config.yaml
packaging-ssm:
runs-on: ubuntu-latest
needs: [packaging-rpm, packaging-deb, packaging-msi]
steps:
# Build and archive SSM package into cache.
- uses: actions/checkout@v3
- name: Cache SSM files
id: cached_ssm
uses: actions/cache@v3
with:
key: "cached_ssm_${{ github.run_id }}"
path: "${{ env.PACKAGING_ROOT }}/ssm"
- name: Restore cached rpms
if: steps.cached_ssm.outputs.cache-hit != 'true'
uses: actions/cache@v3
with:
key: "cached_rpms_${{ github.run_id }}"
path: "${{ env.PACKAGING_ROOT }}"
- name: Restore cached debs
if: steps.cached_ssm.outputs.cache-hit != 'true'
uses: actions/cache@v3
with:
key: "cached_debs_${{ github.run_id }}"
path: "${{ env.PACKAGING_ROOT }}"
- name: Download built artifacts
if: steps.cached_ssm.outputs.cache-hit != 'true'
uses: actions/download-artifact@v3
with:
name: msi_artifacts
path: "${{ env.PACKAGING_ROOT }}"
- run: ls -R
# Build the ssm package and manifest by using a version with github short sha as same as e2etest-preparation.
- name: Create zip file and manifest for SSM package
if: steps.cached_ssm.outputs.cache-hit != 'true'
run: |
ssm_pkg_version="$(cat VERSION)-$(git rev-parse --short HEAD)"
rm -rf $PACKAGING_ROOT/ssm
python3 tools/ssm/ssm_manifest.py ${ssm_pkg_version}
e2etest-preparation:
runs-on: ubuntu-latest
needs: [packaging-rpm, packaging-deb, packaging-msi, packaging-ssm]
outputs:
version: ${{ steps.versioning.outputs.version }}
steps:
# Archive all the packages into one, and build a unique version number for e2etesting
- uses: actions/checkout@v3
- name: Cache the packages
id: cached_packages
uses: actions/cache@v3
with:
key: "cached_packages_${{ github.run_id }}"
path: "${{ env.PACKAGING_ROOT }}"
- name: Restore cached rpms
if: steps.cached_packages.outputs.cache-hit != 'true'
uses: actions/cache@v3
with:
key: "cached_rpms_${{ github.run_id }}"
path: "${{ env.PACKAGING_ROOT }}"
- name: Restore cached debs
if: steps.cached_packages.outputs.cache-hit != 'true'
uses: actions/cache@v3
with:
key: "cached_debs_${{ github.run_id }}"
path: "${{ env.PACKAGING_ROOT }}"
- name: Download built artifacts
if: steps.cached_packages.outputs.cache-hit != 'true'
uses: actions/download-artifact@v3
with:
name: msi_artifacts
path: "${{ env.PACKAGING_ROOT }}"
- name: Restore cached ssm
if: steps.cached_packages.outputs.cache-hit != 'true'
uses: actions/cache@v3
with:
key: "cached_ssm_${{ github.run_id }}"
path: "${{ env.PACKAGING_ROOT }}/ssm"
- run: ls -R
# Build a version with github short sha for the following reasons:
# - Distingush each build for Integration test
# - Increase more visibility to the customer and also for the dev since we publish the image for integration test.
# - Avoid having similar layers image and only have a final result image.
- name: Versioning for testing
id: versioning
run: |
version="$(cat VERSION)-$(git rev-parse --short HEAD)"
echo $version > $PACKAGING_ROOT/VERSION
cat $PACKAGING_ROOT/VERSION
echo "version=$version" >> $GITHUB_OUTPUT
e2etest-release:
runs-on: ubuntu-latest
needs: [e2etest-preparation]
steps:
- uses: actions/checkout@v3
- name: Cache if success
id: e2etest-release
uses: actions/cache@v3
with:
path: |
VERSION
key: e2etest-release-${{ github.run_id }}
- name: restore cached rpms
uses: actions/cache@v3
with:
key: "cached_packages_${{ github.run_id }}"
path: "${{ env.PACKAGING_ROOT }}"
- name: Restore cached binaries
if: steps.e2etest-release.outputs.cache-hit != 'true'
uses: actions/cache@v3
with:
key: "cached_binaries_${{ github.run_id }}"
path: build
- name: Configure AWS Credentials
uses: aws-actions/[email protected]
with:
role-to-assume: ${{ secrets.COLLECTOR_ASSUMABLE_ROLE_ARN }}
aws-region: us-west-2
- name: Login to Public Integration Test ECR
if: steps.e2etest-release.outputs.cache-hit != 'true'
uses: docker/login-action@v2
with:
registry: public.ecr.aws
env:
AWS_REGION: us-east-1
- name: Create SSM package
run: |
ssm_pkg_version=`cat build/packages/VERSION`
(aws ssm describe-document --name ${SSM_PACKAGE_NAME} --version-name ${ssm_pkg_version} >/dev/null 2>&1) || {
pip3 install boto3
python3 tools/ssm/ssm_manifest.py ${ssm_pkg_version}
aws s3 cp build/packages/ssm s3://aws-otel-collector-test/ssm/${ssm_pkg_version} --recursive
python3 tools/ssm/ssm_create.py ${SSM_PACKAGE_NAME} ${ssm_pkg_version} aws-otel-collector-test/ssm/${ssm_pkg_version} us-west-2
}
- name: Upload to S3 in the testing stack
if: steps.e2etest-release.outputs.cache-hit != 'true'
run: s3_bucket_name=aws-otel-collector-test upload_to_latest=0 bash tools/release/image-binary-release/s3-release.sh
- name: Set up Docker Buildx
if: steps.e2etest-release.outputs.cache-hit != 'true'
uses: docker/setup-buildx-action@v2
- name: Set up QEMU
if: steps.e2etest-release.outputs.cache-hit != 'true'
uses: docker/setup-qemu-action@v2
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: public.ecr.aws/${{ env.ECR_REPO }}
#Build the adot collector image for two primary reasons:
#-Using the adot collector image to do the integration test
#-Export it for delivery version image in CD
#Documentation: https://github.com/docker/build-push-action
- name: Build ADOT collector image
uses: docker/build-push-action@v4
if: steps.e2etest-release.outputs.cache-hit != 'true'
with:
file: cmd/awscollector/Dockerfile
context: .
push: true
tags: |
public.ecr.aws/${{ env.ECR_REPO }}:${{ needs.e2etest-preparation.outputs.version }}
public.ecr.aws/${{ env.ECR_REPO }}:latest
build-args: BUILDMODE=copy
cache-from: type=registry,ref=public.ecr.aws/${{ env.ECR_REPO }}:${{ needs.e2etest-preparation.outputs.version }}
cache-to: type=inline
platforms : linux/amd64, linux/arm64
labels: ${{ steps.meta.outputs.labels }}
get-testing-suites:
runs-on: ubuntu-latest
needs: [create-test-ref]
outputs:
test-case-batch-key: ${{ steps.set-batches.outputs.batch-keys }}
test-case-batch-value: ${{ steps.set-batches.outputs.batch-values }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
repository: ${{ env.TESTING_FRAMEWORK_REPO }}
path: testing-framework
ref: ${{ needs.create-test-ref.outputs.testRef }}
- name: Checkout
uses: actions/checkout@v3
with:
path: aws-otel-collector
ref: ${{ github.ref_name }}
- name: Set up Go 1.x
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
cache-dependency-path: testing-framework/tools/batchTestGenerator/go.sum
- name: Create test batch key values
id: set-batches
run: |
cd testing-framework/tools/batchTestGenerator
go build
./batchTestGenerator github --testCaseFilePath=$GITHUB_WORKSPACE/aws-otel-collector/.github/config/testcases.json --maxBatch=${{ env.MAX_JOBS }} \
--include=${{ env.BATCH_INCLUDED_SERVICES }}
- name: List testing suites
run: |
echo ${{ steps.set-batches.outputs.batch-keys }}
echo ${{ steps.set-batches.outputs.batch-values }}
run-batch-job:
runs-on: ubuntu-latest
needs: [get-testing-suites, e2etest-release, e2etest-preparation, create-test-ref, build-aotutil]
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.get-testing-suites.outputs.test-case-batch-key) }}
steps:
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '11'
- name: Set up terraform
uses: hashicorp/setup-terraform@v2
with:
terraform_version: "~1.4"
- name: Configure AWS Credentials
if: steps.e2etest-eks.outputs.cache-hit != 'true'
uses: aws-actions/[email protected]
with:
role-to-assume: ${{ secrets.COLLECTOR_ASSUMABLE_ROLE_ARN }}
aws-region: us-west-2
# 6 hours
role-duration-seconds: 21600
- name: Checkout testing framework
uses: actions/checkout@v3
with:
repository: ${{ env.TESTING_FRAMEWORK_REPO }}
path: testing-framework
ref: ${{ needs.create-test-ref.outputs.testRef }}
- name: create test-case-batch file
run: |
jsonStr='${{ needs.get-testing-suites.outputs.test-case-batch-value }}'
jsonStr="$(jq -r '.${{ matrix.BatchKey }} | join("\n")' <<< "${jsonStr}")"
echo "$jsonStr" >> testing-framework/terraform/test-case-batch
cat testing-framework/terraform/test-case-batch
- name: Get TTL_DATE for cache
id: date
run: echo "ttldate=$(date -u -d "+7 days" +%s)" >> $GITHUB_OUTPUT
- name: Restore aotutil
uses: actions/cache@v3
with:
key: "aotutil_${{ hashFiles('testing-framework/cmd/aotutil/*.go') }}_${{ hashFiles('testing-framework/cmd/aotutil/go.sum') }}"
path: testing-framework/cmd/aotutil/aotutil
- name: run tests
run: |
export TTL_DATE=${{ steps.date.outputs.ttldate }}
export TF_VAR_aoc_version=${{ needs.e2etest-preparation.outputs.version }}
cd testing-framework/terraform
make execute-batch-test
- name: output cache misses
if: ${{ failure() }}
run: |
export TF_VAR_aoc_version=${{ needs.e2etest-preparation.outputs.version }}
cd testing-framework/terraform
make checkCacheHits
# This is here just in case workflow cancel
# We first kill terraform processes to ensure that no state
# file locks are being held from SIGTERMS dispatched in previous
# steps.
- name: Destroy resources
if: ${{ cancelled() }}
shell: bash {0}
run: |
ps -ef | grep terraform | grep -v grep | awk '{print $2}' | xargs -n 1 kill
cd testing-framework/terraform
make terraformCleanup
clean-ssm-package:
runs-on: ubuntu-latest
if: ${{ always() && needs.e2etest-preparation.result == 'success' }}
needs: [run-batch-job,e2etest-preparation]
steps:
- uses: actions/checkout@v3
- name: Configure AWS Credentials
uses: aws-actions/[email protected]
with:
role-to-assume: ${{ secrets.COLLECTOR_ASSUMABLE_ROLE_ARN }}
aws-region: us-west-2
- name: restore cached packages
id: cache_packages
uses: actions/cache@v3
with:
path: "${{ env.PACKAGING_ROOT }}"
key: "cached_packages_${{ github.run_id }}"
- name: Get SSM package version
id: versioning
if: steps.cache_packages.outputs.cache-hit == 'true'
run: |
ssm_pkg_version=$(cat $PACKAGING_ROOT/VERSION)
echo "ssm_pkg_version=$ssm_pkg_version" >> $GITHUB_OUTPUT
- name: Rollback SSM default version
if: steps.cache_packages.outputs.cache-hit == 'true'
run: |
ssm_package_name=${{ env.SSM_PACKAGE_NAME }} version=${{ steps.versioning.outputs.ssm_pkg_version }} bash tools/ssm/ssm_rollback_default_version.sh
- name: clean up SSM test package
if: steps.cache_packages.outputs.cache-hit == 'true'
run: |
aws ssm describe-document --name ${{ env.SSM_PACKAGE_NAME }} --version-name ${{ steps.versioning.outputs.ssm_pkg_version }} >/dev/null 2>&1 && \
aws ssm delete-document --name ${{ env.SSM_PACKAGE_NAME }} --version-name ${{ steps.versioning.outputs.ssm_pkg_version }}
validate-all-tests-pass:
runs-on: ubuntu-latest
needs: [run-batch-job,e2etest-preparation,create-test-ref,get-testing-suites]
if: always()
steps:
- name: Checkout
uses: actions/checkout@v3
with:
repository: ${{ env.TESTING_FRAMEWORK_REPO }}
path: testing-framework
ref: ${{ needs.create-test-ref.outputs.testRef }}
- name: Set up Go 1.x
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
- name: Configure AWS Credentials
uses: aws-actions/[email protected]
with:
role-to-assume: ${{ secrets.COLLECTOR_ASSUMABLE_ROLE_ARN }}
aws-region: us-west-2
# combine all test-case-batch values
- name: create test-case-batch file
run: |
jsonStr='${{ needs.get-testing-suites.outputs.test-case-batch-value }}'
jsonStr="$(jq -r '.[] | join("\n")' <<< "${jsonStr}")"
echo "$jsonStr" >> testing-framework/terraform/test-case-batch
cat testing-framework/terraform/test-case-batch
- name: output cache misses
run: |
export TF_VAR_aoc_version=${{ needs.e2etest-preparation.outputs.version }}
cd testing-framework/terraform
make checkCacheHits
release-candidate:
runs-on: ubuntu-latest
if: ${{ always() && needs.validate-all-tests-pass.result == 'success'
&& (startsWith(github.ref_name, 'release/v') || github.ref_name == 'main') }}
needs: validate-all-tests-pass
steps:
- name: Configure AWS Credentials
uses: aws-actions/[email protected]
with:
role-to-assume: ${{ secrets.COLLECTOR_ASSUMABLE_ROLE_ARN }}
aws-region: us-west-2
- name: restore cached packages
uses: actions/cache@v3
with:
path: "${{ env.PACKAGING_ROOT }}"
key: "cached_packages_${{ github.run_id }}"
- name: prepare production version
run: |
TESTING_VERSION=`cat $PACKAGING_ROOT/VERSION`
VERSION=`echo $TESTING_VERSION | awk -F "-" '{print $1}'`
echo $VERSION > $PACKAGING_ROOT/VERSION
echo $GITHUB_SHA > $PACKAGING_ROOT/GITHUB_SHA
echo $TESTING_VERSION > $PACKAGING_ROOT/TESTING_VERSION
- name: upload packages as release candidate on s3
run: |
tar czvf $GITHUB_SHA.tar.gz build
aws s3 cp $GITHUB_SHA.tar.gz s3://aws-otel-collector-release-candidate/$GITHUB_SHA.tar.gz
- name: Trigger performance test
uses: peter-evans/repository-dispatch@v2
with:
token: "${{ secrets.REPO_WRITE_ACCESS_TOKEN }}"
event-type: trigger-perf
client-payload: '{"ref": "${{ github.ref }}", "sha": "${{ github.sha }}"}'
publish-ci-status:
runs-on: ubuntu-latest
needs: [release-candidate]
if: always()
steps:
- name: Configure AWS Credentials
uses: aws-actions/[email protected]
with:
role-to-assume: ${{ secrets.COLLECTOR_ASSUMABLE_ROLE_ARN }}
aws-region: us-west-2
- name: Publish CI status
run: |
if [ '${{ needs.release-candidate.result }}' = 'success' ]; then
aws cloudwatch put-metric-data --namespace 'ADOT/GitHubActions' \
--metric-name Success \
--dimensions repository=${{ github.repository }},branch=${{ github.ref_name }},workflow=CI \
--value 1.0
else
aws cloudwatch put-metric-data --namespace 'ADOT/GitHubActions' \
--metric-name Success \
--dimensions repository=${{ github.repository }},branch=${{ github.ref_name }},workflow=CI \
--value 0.0
fi