-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
280 additions
and
31 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,179 @@ | ||
# 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 | ||
- contract-tests-workflow | ||
- "release/v*" | ||
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 | ||
S3_INTEGRATION_BUCKET: ${{ secrets.S3_INTEGRATION_BUCKET }} | ||
|
||
concurrency: | ||
group: python-instrumentation-main-build | ||
cancel-in-progress: false | ||
|
||
permissions: | ||
id-token: write | ||
contents: read | ||
|
||
jobs: | ||
build: | ||
env: | ||
py311: "3.11" | ||
RUN_MATRIX_COMBINATION: ${{ matrix.python-version }}-${{ matrix.package }}-${{ matrix.os }} | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
fail-fast: false # ensures the entire test matrix is run, even if one permutation fails | ||
matrix: | ||
python-version: [ py311 ] | ||
package: [ "aws-opentelemetry-distro" ] | ||
os: [ ubuntu-latest ] | ||
outputs: | ||
python_distro_tag: ${{ steps.python_distro_versioning.outputs.STAGING_TAG}} | ||
#staging-image-name: ${{ steps.imageNameOutput.outputs.imageName }} | ||
staging_wheel_file: ${{ steps.staging_wheel_build.outputs.STAGING_WHEEL}} | ||
steps: | ||
- name: Checkout Contrib Repo @ SHA - ${{ github.sha }} | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ env[matrix.python-version] }} | ||
|
||
- name: Install tox | ||
run: pip install tox==3.27.1 tox-factor | ||
|
||
- name: Cache tox environment | ||
# Preserves .tox directory between runs for faster installs | ||
uses: actions/cache@v1 | ||
with: | ||
path: | | ||
.tox | ||
~/.cache/pip | ||
key: v7-build-tox-cache-${{ env.RUN_MATRIX_COMBINATION }}-${{ hashFiles('tox.ini', 'dev-requirements.txt') }} | ||
|
||
# - name: run tox | ||
# run: tox -f ${{ matrix.python-version }}-${{ matrix.package }} -- -ra --benchmark-json=${{ env.RUN_MATRIX_COMBINATION }}-benchmark.json | ||
|
||
- name: Install Dependencies and Build Wheel | ||
id: staging_wheel_build | ||
run: | | ||
pip install --upgrade pip setuptools wheel packaging build | ||
rm -rf ./dist/* | ||
cd ./aws-opentelemetry-distro | ||
python -m build --outdir ../dist | ||
cd ../dist | ||
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 "STAGING_WHEEL=aws_opentelemetry_distro-$pkg_version-$shortsha.whl" >> $GITHUB_OUTPUT | ||
cp aws_opentelemetry_distro-$pkg_version-py3-none-any.whl aws_opentelemetry_distro-$pkg_version-$shortsha.whl | ||
- name: Run setup script | ||
run: bash contract-tests/set-up-contract-tests.sh | ||
|
||
- name: Run contract tests | ||
run: | | ||
pip install pytest | ||
pytest contract-tests/tests | ||
- name: Upload to GitHub Actions | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: aws_opentelemetry_distro.whl | ||
path: dist/${{ steps.staging_wheel_build.outputs.STAGING_WHEEL}} | ||
|
||
- 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: Upload wheel to S3 | ||
run: aws s3 cp dist/${{ steps.staging_wheel_build.outputs.STAGING_WHEEL}} ${{ env.S3_INTEGRATION_BUCKET }} | ||
|
||
# - name: Set up QEMU | ||
# uses: docker/setup-qemu-action@v3 | ||
# | ||
# - name: Set up Docker Buildx | ||
# uses: docker/setup-buildx-action@v3 | ||
# | ||
# - name: Log in to AWS ECR | ||
# uses: docker/login-action@v3 | ||
# with: | ||
# registry: ${{ env.STAGING_ECR_REGISTRY }} | ||
# env: | ||
# AWS_REGION: ${{ env.AWS_DEFAULT_REGION }} | ||
# | ||
# - name: Get Python Distro Image Tag | ||
# id: python_distro_versioning | ||
# run: | | ||
# shortsha="$(git rev-parse --short HEAD)" | ||
# python_distro_tag=${{ steps.staging_wheel_build.outputs.ADOT_PYTHON_VERSION }}-$shortsha | ||
# echo "STAGING_TAG=$python_distro_tag" >> $GITHUB_OUTPUT | ||
# | ||
# - name: Build and push staging image | ||
# uses: docker/build-push-action@v5 | ||
# with: | ||
# push: true | ||
# context: . | ||
# file: ./Dockerfile | ||
# platforms: linux/amd64 | ||
# tags: | | ||
# ${{ env.STAGING_ECR_REGISTRY }}/${{ env.STAGING_ECR_REPOSITORY }}:${{ steps.python_distro_versioning.outputs.STAGING_TAG }} | ||
# | ||
# - name: Set image name to output | ||
# id: imageNameOutput | ||
# run: echo "imageName=${{ env.STAGING_ECR_REGISTRY }}/${{ env.STAGING_ECR_REPOSITORY }}:${{ steps.python_distro_versioning.outputs.STAGING_TAG }}" >> "$GITHUB_OUTPUT" | ||
|
||
contract-tests: | ||
runs-on: ubuntu-latest | ||
needs: build | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.11" | ||
# | ||
# - 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@v3 | ||
# with: | ||
# registry: public.ecr.aws | ||
# | ||
# # cache local patch outputs | ||
# - name: Cache local Maven repository | ||
# id: cache-local-maven-repo | ||
# uses: actions/cache@v3 | ||
# with: | ||
# path: | | ||
# ~/.m2/repository/io/opentelemetry/ | ||
# key: ${{ runner.os }}-maven-local-${{ hashFiles('.github/patches/opentelemetry-java*.patch') }} | ||
# | ||
# - name: Pull base image of Contract Tests Sample Apps | ||
# run: docker pull public.ecr.aws/docker/library/python:3.11-slim | ||
|
||
|
||
- name: Whereami | ||
#working-directory: ${{ github.workspace }}/aws-otel-python-instrumentation | ||
run: pwd; ls -R | ||
|
||
- name: Run setup script | ||
run: bash contract-tests/set-up-contract-tests.sh | ||
|
||
- name: Run contract tests | ||
run: pytest contract-tests/tests |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# To build one auto-instrumentation image for Python, please: | ||
# - Ensure the packages are installed in the `/autoinstrumentation` directory. This is required as when instrumenting the pod, | ||
# one init container will be created to copy all the content in `/autoinstrumentation` directory to your app's container. Then | ||
# update the `PYTHONPATH` environment variable accordingly. To achieve this, you can mimic the one in `autoinstrumentation/python/Dockerfile` | ||
# by using multi-stage builds. In the first stage, install all the required packages in one custom directory with `pip install --target`. | ||
# Then in the second stage, copy the directory to `/autoinstrumentation`. | ||
# - Ensure you have `opentelemetry-distro` and `opentelemetry-instrumentation` or your customized alternatives installed. | ||
# Those two packages are essential to Python auto-instrumentation. | ||
# - Grant the necessary access to `/autoinstrumentation` directory. `chmod -R go+r /autoinstrumentation` | ||
# - For auto-instrumentation by container injection, the Linux command cp is | ||
# used and must be available in the image. | ||
FROM python:3.10 AS build | ||
|
||
WORKDIR /operator-build | ||
|
||
ADD aws-opentelemetry-distro/ ./aws-opentelemetry-distro/ | ||
|
||
RUN mkdir workspace && pip install --target workspace ./aws-opentelemetry-distro | ||
|
||
FROM busybox | ||
|
||
COPY --from=build /operator-build/workspace /autoinstrumentation | ||
|
||
RUN chmod -R go+r /autoinstrumentation |
This file contains 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 file contains 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 file contains 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 file contains 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 file contains 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