From 5d6c1b507a2430005b0466d474fe850f998f4e04 Mon Sep 17 00:00:00 2001 From: Min Xia Date: Mon, 7 Oct 2024 13:28:41 -0700 Subject: [PATCH] Init Python Layer e2e workflow in main-build --- .../actions/lambda_artifacts_build/action.yml | 50 +++++++++++++++++++ .../application-signals-e2e-test.yml | 15 ++++-- .github/workflows/main_build.yml | 11 ++++ 3 files changed, 72 insertions(+), 4 deletions(-) create mode 100644 .github/actions/lambda_artifacts_build/action.yml diff --git a/.github/actions/lambda_artifacts_build/action.yml b/.github/actions/lambda_artifacts_build/action.yml new file mode 100644 index 000000000..ee01d2d8c --- /dev/null +++ b/.github/actions/lambda_artifacts_build/action.yml @@ -0,0 +1,50 @@ +name: Build and Push aws-opentelemetry-python-distro Layer +description: | + This action assumes that the repo was checked out. Builds and push Lambda Layer and sample app to S3 bucket for + the further end to end tests. + +inputs: + aws-region: + required: false + description: "AWS Region, required only if push_image is true" + snapshot-ecr-role: + required: false + description: "IAM Role used for pushing to snapshot ecr, required only if push_image is true" + python_version: + required: true + description: "The python version used in actions" + layer_directory: + required: true + description: 'The role use to publish lambda layer' + staging_s3_bucket: + required: true + description: 'S3 bucket holds SDK artifact tarball' + os: + required: true + description: "The os" + + +runs: + using: "composite" + steps: + - name: Build sample lambda function + shell: bash + working-directory: ${{ inputs.layer_directory }}/sample-apps + run: ./package-lambda-function.sh + - name: Build layers + shell: bash + working-directory: ${{ inputs.layer_directory }}/src + run: | + ./build-lambda-layer.sh + pip install tox + tox + - name: Upload Layer to S3 + shell: bash + run: | + aws s3 cp ./build/aws-opentelemetry-python-layer.zip s3://${{ inputs.staging_s3_bucket }}/layer-${{ github.run_id }}.zip + working-directory: ${{ inputs.layer_directory }}/src + - name: Upload Sample App to S3 + shell: bash + run: | + aws s3 cp ./build/function.zip s3://${{ inputs.staging_s3_bucket }}/function-${{ github.run_id }}.zip + working-directory: ${{ inputs.layer_directory }}/sample-apps \ No newline at end of file diff --git a/.github/workflows/application-signals-e2e-test.yml b/.github/workflows/application-signals-e2e-test.yml index ce83c7353..97a6e3b83 100644 --- a/.github/workflows/application-signals-e2e-test.yml +++ b/.github/workflows/application-signals-e2e-test.yml @@ -100,7 +100,7 @@ jobs: python-version: '3.12' cpu-architecture: 'x86_64' staging-wheel-name: ${{ inputs.staging-wheel-name }} - + # # DOCKER DISTRIBUTION LANGUAGE VERSION COVERAGE # DEFAULT SETTING: {Python Version}, EKS, AMD64, AL2 @@ -174,7 +174,7 @@ jobs: caller-workflow-name: 'main-build' python-version: '3.9' staging-wheel-name: ${{ inputs.staging-wheel-name }} - + # # DOCKER DISTRIBUTION PLATFORM COVERAGE # DEFAULT SETTING: Python 3.10, {Platform}, AMD64, AL2 @@ -215,5 +215,12 @@ jobs: cpu-architecture: 'arm64' staging-wheel-name: ${{ inputs.staging-wheel-name }} - - + # + # Lambda layer integration tests + lambda: + uses: aws-observability/aws-application-signals-test-framework/.github/workflows/python-lambda-test.yml@main + secrets: inherit + with: + aws-region: us-east-1 + python-version: '3.12' + caller-workflow-name: 'main-build' diff --git a/.github/workflows/main_build.yml b/.github/workflows/main_build.yml index 86a8f18ac..434230019 100644 --- a/.github/workflows/main_build.yml +++ b/.github/workflows/main_build.yml @@ -5,6 +5,7 @@ on: branches: - main - "release/v*" + - ci-workflow workflow_dispatch: # be able to run the workflow on demand env: AWS_DEFAULT_REGION: us-east-1 @@ -71,6 +72,16 @@ jobs: cd ./dist cp aws_opentelemetry_distro-${{ steps.python_output.outputs.ADOT_PYTHON_VERSION}}-py3-none-any.whl $staging_wheel + - name: Build and Publish Lambda Staging Layer + uses: ./.github/actions/lambda_artifacts_build + with: + aws-region: ${{ env.AWS_DEFAULT_REGION }} + snapshot-ecr-role: ${{ secrets.AWS_ASSUME_ROLE_ARN }} + python_version: "3.12" + layer_directory: lambda-layer + staging_s3_bucket: ${{ env.STAGING_S3_BUCKET }} + os: ubuntu-latest + - name: Upload wheel to S3 run: | aws s3 cp dist/${{ steps.staging_wheel_output.outputs.STAGING_WHEEL}} s3://${{ env.STAGING_S3_BUCKET }}