-
Notifications
You must be signed in to change notification settings - Fork 56
461 lines (400 loc) · 15.6 KB
/
main-build.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
name: Java Agent Main Build
on:
push:
branches:
- main
- "release/v*"
env:
AWS_DEFAULT_REGION: us-east-1
TEST_TAG: public.ecr.aws/aws-observability/adot-autoinstrumentation-java:test
STAGING_ECR_REGISTRY: 611364707713.dkr.ecr.us-west-2.amazonaws.com
STAGING_ECR_REPOSITORY: adot-autoinstrumentation-java-operator-staging
TESTING_FRAMEWORK_REPO: aws-observability/aws-otel-test-framework
NUM_BATCHES: 2
DDB_TABLE_NAME: BatchTestCache
concurrency:
group: java-agent-main-build
cancel-in-progress: false
permissions:
id-token: write
contents: read
jobs:
testpatch:
name: Test patches applied to dependencies
runs-on: ubuntu-latest
if: ${{ startsWith(github.ref_name, 'release/v') }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v3
with:
java-version: 17
distribution: temurin
# vaadin 14 tests fail with node 18
- name: Set up Node
uses: actions/setup-node@v3
with:
node-version: 16
# vaadin tests use pnpm
- name: Cache pnpm modules
uses: actions/cache@v3
with:
path: ~/.pnpm-store
key: ${{ runner.os }}-test-cache-pnpm-modules
- uses: gradle/wrapper-validation-action@v1
- uses: ./.github/actions/patch-dependencies
with:
run_tests: "true"
branch: ${{ github.ref_name }}
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
gpg_password: ${{ secrets.GPG_PASSPHRASE }}
build:
runs-on: ubuntu-latest
outputs:
java_agent_tag: ${{ steps.java_agent_versioning.outputs.STAGING_TAG}}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-java@v3
with:
java-version: 17
distribution: temurin
# cache local patch outputs
- name: Cache local Maven repository
uses: actions/cache@v3
with:
path: |
~/.m2/repository/io/opentelemetry/
key: ${{ runner.os }}-maven-local-${{ hashFiles('.github/patches/**/opentelemetry-java-*.patch') }}
- name: Publish patched dependencies to maven local
uses: ./.github/actions/patch-dependencies
if: ${{ startsWith(github.ref_name, 'release/v') }}
with:
branch: ${{ github.ref_name }}
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
gpg_password: ${{ secrets.GPG_PASSPHRASE }}
- uses: gradle/wrapper-validation-action@v1
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_ASSUME_ROLE_ARN }}
aws-region: ${{ env.AWS_DEFAULT_REGION }}
- name: Log in to AWS ECR
uses: docker/login-action@v2
with:
registry: public.ecr.aws
- name: Build snapshot with Gradle
uses: gradle/gradle-build-action@v2
with:
arguments: build integrationTests snapshot --stacktrace -PenableCoverage=true -PlocalDocker=true
env:
PUBLISH_USERNAME: ${{ secrets.PUBLISH_USERNAME }}
PUBLISH_PASSWORD: ${{ secrets.PUBLISH_PASSWORD }}
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
- name: Get current version
shell: bash
run: |
echo "ADOT_JAVA_VERSION=$(./gradlew printVersion -q )" >> $GITHUB_ENV
- name: Build and push Sample-Apps without Auto-Instrumentation Agent
uses: gradle/gradle-build-action@v2
with:
arguments: jibBuildWithoutAgent
env:
COMMIT_HASH: ${{ github.sha }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build image for testing
uses: docker/build-push-action@v5
with:
push: false
build-args: "ADOT_JAVA_VERSION=${{ env.ADOT_JAVA_VERSION }}"
context: .
platforms: linux/amd64
tags: ${{ env.TEST_TAG }}
load: true
- name: Test docker image
shell: bash
run: .github/scripts/test-adot-javaagent-image.sh "${{ env.TEST_TAG }}" "${{ env.ADOT_JAVA_VERSION }}"
- name: Upload to GitHub Actions
uses: actions/upload-artifact@v3
with:
name: aws-opentelemetry-agent.jar
path: otelagent/build/libs/aws-opentelemetry-agent-*.jar
- name: Get ADOT_JAVA_AGENT Image Tag
id: java_agent_versioning
run: |
shortsha="$(git rev-parse --short HEAD)"
java_agent_tag=${{ env.ADOT_JAVA_VERSION }}-$shortsha
echo "STAGING_TAG=$java_agent_tag" >> $GITHUB_OUTPUT
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.JAVA_INSTRUMENTATION_SNAPSHOT_ECR }}
aws-region: us-west-2
- name: Login to private staging ecr
uses: docker/login-action@v2
with:
registry: ${{ env.STAGING_ECR_REGISTRY }}
env:
AWS_REGION: us-west-2
- name: Build and push staging image for e2e integration test
uses: docker/build-push-action@v5
with:
push: true
build-args: "ADOT_JAVA_VERSION=${{ env.ADOT_JAVA_VERSION }}"
context: .
platforms: linux/amd64,linux/arm64
tags: |
${{ env.STAGING_ECR_REGISTRY }}/${{ env.STAGING_ECR_REPOSITORY }}:${{ steps.java_agent_versioning.outputs.STAGING_TAG }}
create-test-ref:
runs-on: ubuntu-latest
outputs:
testRef: ${{ steps.setRef.outputs.ref }}
steps:
- name: Set testRef output
id: setRef
run: |
if [[ ${{ github.ref_name }} == release/v* ]]; then
echo "ref=java-${{ github.ref_name }}" >> $GITHUB_OUTPUT
else
echo "ref=terraform" >> $GITHUB_OUTPUT
fi
# job to build testbatches for e2e integration test
get-testing-suites:
runs-on: ubuntu-latest
needs: [build, 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@v4
with:
repository: ${{ env.TESTING_FRAMEWORK_REPO }}
path: testing-framework
ref: ${{ needs.create-test-ref.outputs.testRef }}
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
path: aws-otel-java-instrumentation
- name: Set up Go 1.x
uses: actions/setup-go@v4
with:
go-version: '~1.18.9'
- name: Create test batch key values
id: set-batches
run: |
cd testing-framework/tools/batchTestGenerator
go build
./batchTestGenerator github --testCaseFilePath=$GITHUB_WORKSPACE/aws-otel-java-instrumentation/.github/workflows/testcases.json --maxBatch=${{ env.NUM_BATCHES }} \
--include=EKS_ADOT_OPERATOR,EKS_ADOT_OPERATOR_ARM64
- name: List testing suites
run: |
echo ${{ steps.set-batches.outputs.batch-keys }}
echo ${{ steps.set-batches.outputs.batch-values }}
# job to run the e2e integration tests
run-batch-job:
runs-on: ubuntu-latest
needs: [build, create-test-ref, get-testing-suites]
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.get-testing-suites.outputs.test-case-batch-key) }}
steps:
# required for versioning
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
path: aws-otel-java-instrumentation
- 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.5"
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.JAVA_INSTRUMENTATION_INTEG_TEST_ARN}}
aws-region: us-west-2
# 4 hours
role-duration-seconds: 14400
- name: Checkout testing framework
uses: actions/checkout@v4
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: run tests
run: |
export TTL_DATE=${{ steps.date.outputs.ttldate }}
export TF_VAR_java_auto_instrumentation_tag=${{ needs.build.outputs.java_agent_tag }}
export TF_VAR_java_auto_instrumentation_repository="${{ env.STAGING_ECR_REGISTRY }}/${{ env.STAGING_ECR_REPOSITORY }}"
export DDB_BATCH_CACHE_SK=${{ needs.build.outputs.java_agent_tag }}
cd testing-framework/terraform
make execute-batch-test
- name: output cache misses
if: ${{ failure() }}
run: |
export DDB_BATCH_CACHE_SK=${{ needs.build.outputs.java_agent_tag }}
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
build_Images_For_Testing_Sample_App_With_Java_Agent:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-java@v3
with:
java-version: 17
distribution: temurin
# cache local patch outputs
- name: Cache local Maven repository
uses: actions/cache@v3
with:
path: |
~/.m2/repository/io/opentelemetry/
key: ${{ runner.os }}-maven-local-${{ hashFiles('.github/patches/**/opentelemetry-java-*.patch') }}
- uses: gradle/wrapper-validation-action@v1
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_ASSUME_ROLE_ARN }}
aws-region: ${{ env.AWS_DEFAULT_REGION }}
- name: Log in to AWS ECR
uses: docker/login-action@v2
with:
registry: public.ecr.aws
- name: Build and push agent and testing docker images with Gradle
uses: gradle/gradle-build-action@v2
with:
arguments: jib
env:
COMMIT_HASH: ${{ github.sha }}
- uses: codecov/codecov-action@v3
test_Spring_App_With_Java_Agent:
name: Test Spring App with AWS OTel Java agent
needs: build_Images_For_Testing_Sample_App_With_Java_Agent
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v3
with:
java-version: 17
distribution: 'temurin'
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_ASSUME_ROLE_ARN }}
aws-region: ${{ env.AWS_DEFAULT_REGION }}
- name: Log in to AWS ECR
uses: docker/login-action@v2
with:
registry: public.ecr.aws
- name: Run test containers
run: docker-compose up --abort-on-container-exit
working-directory: .github/collector
env:
INSTANCE_ID: ${{ github.run_id }}-${{ github.run_number }}
LISTEN_ADDRESS: 0.0.0.0:8080
APP_IMAGE: public.ecr.aws/aws-otel-test/aws-otel-java-springboot:${{ github.sha }}
VALIDATOR_COMMAND: -c springboot-otel-trace-metric-validation.yml --endpoint http://app:8080 --metric-namespace aws-otel-integ-test -t ${{ github.run_id }}-${{ github.run_number }}
test_Spark_App_With_Java_Agent:
name: Test Spark App with AWS OTel Java agent
needs: build_Images_For_Testing_Sample_App_With_Java_Agent
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v3
with:
java-version: 17
distribution: 'temurin'
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_ASSUME_ROLE_ARN }}
aws-region: ${{ env.AWS_DEFAULT_REGION }}
- name: Log in to AWS ECR
uses: docker/login-action@v2
with:
registry: public.ecr.aws
- name: Run test containers
run: docker-compose up --abort-on-container-exit
working-directory: .github/collector
env:
INSTANCE_ID: ${{ github.run_id }}-${{ github.run_number }}
LISTEN_ADDRESS: 0.0.0.0:4567
APP_IMAGE: public.ecr.aws/aws-otel-test/aws-otel-java-spark:${{ github.sha }}
VALIDATOR_COMMAND: -c spark-otel-trace-metric-validation.yml --endpoint http://app:4567 --metric-namespace aws-otel-integ-test -t ${{ github.run_id }}-${{ github.run_number }}
test_Spark_AWS_SDK_V1_App_With_Java_Agent:
name: Test Spark App (AWS SDK v1) with AWS OTel Java agent
needs: build_Images_For_Testing_Sample_App_With_Java_Agent
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v3
with:
java-version: 17
distribution: 'temurin'
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_ASSUME_ROLE_ARN }}
aws-region: ${{ env.AWS_DEFAULT_REGION }}
- name: Log in to AWS ECR
uses: docker/login-action@v2
with:
registry: public.ecr.aws
- name: Run test containers
run: docker-compose up --abort-on-container-exit
working-directory: .github/collector
env:
INSTANCE_ID: ${{ github.run_id }}-${{ github.run_number }}
LISTEN_ADDRESS: 0.0.0.0:4567
APP_IMAGE: public.ecr.aws/aws-otel-test/aws-otel-java-spark-awssdkv1:${{ github.sha }}
VALIDATOR_COMMAND: -c spark-otel-trace-metric-validation.yml --endpoint http://app:4567 --metric-namespace aws-otel-integ-test -t ${{ github.run_id }}-${{ github.run_number }}
publish-build-status:
needs: [test_Spring_App_With_Java_Agent, test_Spark_App_With_Java_Agent, test_Spark_AWS_SDK_V1_App_With_Java_Agent, run-batch-job]
if: ${{ always() }}
uses: ./.github/workflows/publish-status.yml
with:
namespace: 'ADOT/GitHubActions'
repository: ${{ github.repository }}
branch: ${{ github.ref_name }}
workflow: main-build
success: ${{ needs.test_Spring_App_With_Java_Agent.result == 'success' &&
needs.test_Spark_App_With_Java_Agent.result == 'success' &&
needs.test_Spark_AWS_SDK_V1_App_With_Java_Agent.result == 'success' &&
needs.run-batch-job.result == 'success' }}
region: us-west-2
secrets:
roleArn: ${{ secrets.METRICS_ROLE_ARN }}