Skip to content

Commit

Permalink
Address comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
zzhlogin committed Feb 7, 2024
1 parent 14068ff commit 45b19e8
Show file tree
Hide file tree
Showing 3 changed files with 157 additions and 14 deletions.
45 changes: 38 additions & 7 deletions .github/workflows/main_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ on:
env:
AWS_DEFAULT_REGION: us-east-1
STAGING_ECR_REGISTRY: 637423224110.dkr.ecr.us-east-1.amazonaws.com
STAGING_ECR_REPOSITORY: eks/observability/adot-autoinstrumentation-python
STAGING_ECR_REPOSITORY: aws-observability/adot-autoinstrumentation-python-staging
S3_INTEGRATION_BUCKET: ${{ secrets.S3_INTEGRATION_BUCKET }}

concurrency:
Expand All @@ -25,19 +25,43 @@ permissions:

jobs:
build:
runs-on: ubuntu-latest
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@v2
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.11"
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
Expand All @@ -49,8 +73,15 @@ jobs:
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
pip wheel --no-deps aws_opentelemetry_distro-$pkg_version.tar.gz
echo "STAGING_WHEEL=aws_opentelemetry_distro-$pkg_version-py3-none-any.whl" >> $GITHUB_OUTPUT
shortsha="$(git rev-parse --short HEAD)"
mv aws_opentelemetry_distro-$pkg_version-py3-none-any.whl aws_opentelemetry_distro-$pkg_version-$shortsha.whl
echo "STAGING_WHEEL=aws_opentelemetry_distro-$pkg_version-$shortsha.whl" >> $GITHUB_OUTPUT
- name: Upload to GitHub Actions
uses: actions/upload-artifact@v3
with:
name: aws_opentelemetry_distro.whl
path: dist/aws_opentelemetry_distro-*.whl

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
Expand Down Expand Up @@ -87,7 +118,7 @@ jobs:
push: true
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm64
platforms: linux/amd64
tags: |
${{ env.STAGING_ECR_REGISTRY }}/${{ env.STAGING_ECR_REPOSITORY }}:${{ steps.python_distro_versioning.outputs.STAGING_TAG }}
Expand Down
89 changes: 89 additions & 0 deletions .github/workflows/pr_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
name: Python Instrumentation PR Build
on:
pull_request:
branches:
- main
- "release/v*"
env:
AWS_DEFAULT_REGION: us-east-1
TEST_TAG: 637423224110.dkr.ecr.us-east-1.amazonaws.com/eks/observability/adot-autoinstrumentation-python:test

jobs:
build:
env:
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:
staging-image-name: ${{ steps.imageNameOutput.outputs.imageName }}
staging_wheel_file: ${{ steps.pr_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: pr_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)"
mv aws_opentelemetry_distro-$pkg_version-py3-none-any.whl aws_opentelemetry_distro-$pkg_version-$shortsha.whl
echo "STAGING_WHEEL=aws_opentelemetry_distro-$pkg_version-$shortsha.whl" >> $GITHUB_OUTPUT
- name: Upload to GitHub Actions
uses: actions/upload-artifact@v3
with:
name: aws_opentelemetry_distro.whl
path: dist/aws_opentelemetry_distro-*.whl

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build image for testing
uses: docker/build-push-action@v5
with:
push: false
context: .
file: ./Dockerfile
platforms: linux/amd64
tags: ${{ env.TEST_TAG }}
load: true

- name: Set image name to output
id: imageNameOutput
run: echo "imageName=${{ env.TEST_TAG }}" >> "$GITHUB_OUTPUT"

# TODO: Add Contract test and E2E test
37 changes: 30 additions & 7 deletions .github/workflows/release_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,48 @@ on:
required: true
env:
AWS_DEFAULT_REGION: us-east-1
STAGING_ECR_REGISTRY: 637423224110.dkr.ecr.us-east-1.amazonaws.com
STAGING_ECR_REPOSITORY: eks/observability/adot-autoinstrumentation-python
ECR_REGISTRY: 637423224110.dkr.ecr.us-east-1.amazonaws.com
ECR_REPOSITORY: eks/observability/adot-autoinstrumentation-python

permissions:
id-token: write
contents: read

jobs:
build:
runs-on: ubuntu-latest
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 ]
steps:
- name: Checkout Contrib Repo @ SHA - ${{ github.sha }}
uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.11"
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
Expand All @@ -36,7 +60,6 @@ jobs:
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
pip wheel --no-deps aws_opentelemetry_distro-$pkg_version.tar.gz
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
Expand All @@ -53,7 +76,7 @@ jobs:
- name: Log in to AWS ECR
uses: docker/login-action@v3
with:
registry: ${{ env.STAGING_ECR_REGISTRY }}
registry: ${{ env.ECR_REGISTRY }}
env:
AWS_REGION: ${{ env.AWS_DEFAULT_REGION }}

Expand All @@ -65,7 +88,7 @@ jobs:
file: ./Dockerfile
platforms: linux/amd64,linux/arm64
tags: |
${{ env.STAGING_ECR_REGISTRY }}/${{ env.STAGING_ECR_REPOSITORY }}:v${{ github.event.inputs.version }}
${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:v${{ github.event.inputs.version }}
- name: Create release
env:
Expand Down

0 comments on commit 45b19e8

Please sign in to comment.