Python Instrumentation Main Build #409
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # This workflow build the aws-opentelemetry-distro wheel file, upload to staging S3 bucket, and build project docker image then push to staging ECR | |
| name: Python Instrumentation Main Build | |
| on: | |
| push: | |
| branches: | |
| - main | |
| - "release/v*" | |
| - ci-workflow | |
| workflow_dispatch: # be able to run the workflow on demand | |
| workflow_call: | |
| inputs: | |
| ref: | |
| description: 'Git ref to checkout' | |
| required: false | |
| type: string | |
| env: | |
| AWS_DEFAULT_REGION: us-east-1 | |
| STAGING_ECR_REGISTRY: 637423224110.dkr.ecr.us-east-1.amazonaws.com | |
| STAGING_ECR_REPOSITORY: aws-observability/adot-autoinstrumentation-python-staging | |
| STAGING_S3_BUCKET: ${{ secrets.STAGING_BUCKET_NAME }} | |
| concurrency: | |
| group: python-instrumentation-main-build | |
| cancel-in-progress: false | |
| permissions: | |
| id-token: write | |
| contents: read | |
| jobs: | |
| # SCRATCH (serviceevents/eks-e2e branch only — DO NOT MERGE): | |
| # Validate the EKS Service Events reusable workflow under this repo's | |
| # cluster-authorized OIDC identity. main-build is used only as the registered | |
| # workflow_dispatch doorway; the heavy build job below is gated off so the run | |
| # is just the single SE-EKS job (no distro build, no other e2e cells). | |
| service-events-eks: | |
| name: "Service Events EKS Test (scratch validation)" | |
| uses: aws-observability/aws-application-signals-test-framework/.github/workflows/python-eks-service-events-test.yml@serviceevents/eks-e2e | |
| secrets: inherit | |
| permissions: | |
| id-token: write | |
| contents: read | |
| with: | |
| aws-region: us-east-1 | |
| test-cluster-name: e2e-python-adot-test | |
| caller-workflow-name: 'eks-se-validation' | |
| build: | |
| # SCRATCH (serviceevents/eks-e2e branch only): gate off so only service-events-eks runs. | |
| if: ${{ false }} | |
| runs-on: ubuntu-latest | |
| outputs: | |
| aws_default_region: ${{ steps.python_output.outputs.awsDefaultRegion}} | |
| python_image_tag: ${{ steps.python_output.outputs.python_image_tag}} | |
| staging_image: ${{ steps.python_output.outputs.stagingImage}} | |
| staging_registry: ${{ steps.python_output.outputs.stagingRegistry}} | |
| staging_repository: ${{ steps.python_output.outputs.stagingRepository}} | |
| staging_wheel_file: ${{ steps.staging_wheel_output.outputs.STAGING_WHEEL}} | |
| pkg_version: ${{ steps.python_output.outputs.ADOT_PYTHON_VERSION }} | |
| steps: | |
| - name: Checkout Repo @ SHA - ${{ github.sha }} | |
| uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 #5.0.0 | |
| with: | |
| ref: ${{ inputs.ref || github.sha }} | |
| - name: Get Python Distro Output | |
| id: python_output | |
| run: | | |
| pkg_version=$(grep '__version__' ./aws-opentelemetry-distro/src/amazon/opentelemetry/distro/version.py | awk -F '"' '{print $2}') | |
| echo "ADOT_PYTHON_VERSION=$pkg_version" >> $GITHUB_OUTPUT | |
| shortsha="$(git rev-parse --short HEAD)" | |
| echo "SHORT_SHA=$shortsha" >> $GITHUB_ENV | |
| python_distro_tag=$pkg_version-$shortsha | |
| echo "awsDefaultRegion=${{ env.AWS_DEFAULT_REGION }}" >> $GITHUB_OUTPUT | |
| echo "python_image_tag=$python_distro_tag" >> $GITHUB_OUTPUT | |
| echo "stagingRegistry=${{ env.STAGING_ECR_REGISTRY }}" >> $GITHUB_OUTPUT | |
| echo "stagingRepository=${{ env.STAGING_ECR_REPOSITORY }}" >> $GITHUB_OUTPUT | |
| echo "stagingImage=${{ env.STAGING_ECR_REGISTRY }}/${{ env.STAGING_ECR_REPOSITORY }}:$python_distro_tag" >> $GITHUB_OUTPUT | |
| - name: Build and Push Wheel and Image Files | |
| uses: ./.github/actions/artifacts_build | |
| with: | |
| aws-region: ${{ env.AWS_DEFAULT_REGION }} | |
| image_uri_with_tag: ${{ steps.python_output.outputs.stagingImage}} | |
| image_registry: ${{ env.STAGING_ECR_REGISTRY }} | |
| snapshot-ecr-role: ${{ secrets.AWS_ASSUME_ROLE_ARN }} | |
| push_image: true | |
| load_image: false | |
| python_version: "3.10" | |
| package_name: aws-opentelemetry-distro | |
| os: ubuntu-latest | |
| platforms: linux/amd64,linux/arm64 | |
| # workaround: prefixing the short-sha with a 0 to create a valid | |
| # wheel file name as per https://peps.python.org/pep-0427/#file-name-convention | |
| - name: Output Wheel File Name | |
| id: staging_wheel_output | |
| run: | | |
| staging_wheel="aws_opentelemetry_distro-${{ steps.python_output.outputs.ADOT_PYTHON_VERSION}}-0${{ env.SHORT_SHA }}-py3-none-any.whl" | |
| echo "STAGING_WHEEL=$staging_wheel" >> $GITHUB_OUTPUT | |
| 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 Lambda Layer to GitHub Actions | |
| uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 #v4.6.2 | |
| with: | |
| name: layer.zip | |
| path: lambda-layer/src/build/aws-opentelemetry-python-layer.zip | |
| - name: Upload wheel to S3 | |
| run: | | |
| aws s3 cp dist/${{ steps.staging_wheel_output.outputs.STAGING_WHEEL}} s3://${{ env.STAGING_S3_BUCKET }} | |
| - name: Upload Wheel to GitHub Actions | |
| uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 #v4.6.2 | |
| with: | |
| name: ${{ steps.staging_wheel_output.outputs.STAGING_WHEEL}} | |
| path: dist/${{ steps.staging_wheel_output.outputs.STAGING_WHEEL}} | |
| - name: Upload release artifacts to GitHub Actions | |
| uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 #v4.6.2 | |
| with: | |
| name: release-artifacts | |
| path: | | |
| dist/aws_opentelemetry_distro-${{ steps.python_output.outputs.ADOT_PYTHON_VERSION }}-py3-none-any.whl | |
| dist/aws_opentelemetry_distro-${{ steps.python_output.outputs.ADOT_PYTHON_VERSION }}.tar.gz | |
| - name: Upload distro wheel | |
| uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 #v4.6.2 | |
| with: | |
| name: distro-wheel | |
| path: dist/aws_opentelemetry_distro-${{ steps.python_output.outputs.ADOT_PYTHON_VERSION }}-py3-none-any.whl | |
| retention-days: 1 | |
| unit-tests: | |
| runs-on: ubuntu-latest | |
| needs: build | |
| strategy: | |
| fail-fast: false # ensures the entire test matrix is run, even if one permutation fails | |
| matrix: | |
| python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"] | |
| steps: | |
| - name: Checkout Repo @ SHA - ${{ github.sha }} | |
| uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 #5.0.0 | |
| with: | |
| ref: ${{ inputs.ref || github.sha }} | |
| - name: Download distro wheel | |
| uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 #v5.0.0 | |
| with: | |
| name: distro-wheel | |
| path: dist | |
| - name: Resolve wheel path | |
| id: wheel | |
| run: echo "path=$(ls dist/aws_opentelemetry_distro-*-py3-none-any.whl)" >> "$GITHUB_OUTPUT" | |
| - name: Set up and run unit tests | |
| uses: ./.github/actions/unit_tests | |
| with: | |
| python_version: ${{ matrix.python-version }} | |
| package_name: aws-opentelemetry-distro | |
| os: ubuntu-latest | |
| wheel_path: ${{ steps.wheel.outputs.path }} | |
| contract-tests: | |
| needs: build | |
| strategy: | |
| fail-fast: false # ensures the entire test matrix is run, even if one permutation fails | |
| matrix: | |
| python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"] | |
| uses: ./.github/workflows/contract-tests.yml | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| ref: ${{ inputs.ref || github.sha }} | |
| application-signals-e2e-test: | |
| name: "Application Signals E2E Test" | |
| needs: [ build ] | |
| uses: ./.github/workflows/application-signals-e2e-test.yml | |
| secrets: inherit | |
| permissions: | |
| id-token: write | |
| contents: read | |
| with: | |
| staging-wheel-name: ${{ needs.build.outputs.staging_wheel_file }} | |
| adot-image-name: ${{ needs.build.outputs.staging_registry }}/aws-observability/adot-autoinstrumentation-python-staging:${{ needs.build.outputs.python_image_tag }} | |
| build-agentcore-collector: | |
| name: "Build AgentCore Runtime Collector" | |
| needs: [ build ] | |
| uses: ./.github/workflows/build-agentcore-collector.yml | |
| secrets: inherit | |
| permissions: | |
| id-token: write | |
| contents: read | |
| actions: write | |
| publish-main-build-status: | |
| name: "Publish Main Build Status" | |
| needs: [ build, unit-tests, contract-tests, application-signals-e2e-test ] | |
| runs-on: ubuntu-latest | |
| if: always() && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/release/v')) | |
| steps: | |
| - name: Configure AWS Credentials for emitting metrics | |
| uses: aws-actions/configure-aws-credentials@a03048d87541d1d9fcf2ecf528a4a65ba9bd7838 #5.0.0 | |
| with: | |
| role-to-assume: ${{ secrets.MONITORING_ROLE_ARN }} | |
| aws-region: ${{ env.AWS_DEFAULT_REGION }} | |
| - name: Publish main build status | |
| run: | | |
| value="${{ needs.build.result == 'success' && needs.unit-tests.result == 'success' && needs.contract-tests.result == 'success' && needs.application-signals-e2e-test.result == 'success' && '0.0' || '1.0'}}" | |
| aws cloudwatch put-metric-data --namespace 'ADOT/GitHubActions' \ | |
| --metric-name Failure \ | |
| --dimensions repository=${{ github.repository }},branch=${{ github.ref_name }},workflow=main_build \ | |
| --value $value |