Skip to content

Update Dockerfile (#921) #616

Update Dockerfile (#921)

Update Dockerfile (#921) #616

Workflow file for this run

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@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build image for testing
uses: docker/build-push-action@v4
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@v4
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 }}