Skip to content

Commit

Permalink
Extract python building to a bash script
Browse files Browse the repository at this point in the history
  • Loading branch information
RafalSumislawski committed Jul 15, 2024
1 parent 535cab5 commit 00eb5b7
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 24 deletions.
28 changes: 4 additions & 24 deletions .github/workflows/publish-python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ jobs:
runs-on: ubuntu-22.04
if: ${{ github.ref == 'refs/heads/coralogix-python-autoinstrumentation' || inputs.environment == 'test' }}
environment: ${{ inputs.environment }}
env:
OPENTELEMETRY_PYTHON_CONTRIB_PATH: ${{ github.workspace }}/opentelemetry-python-contrib
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v3
Expand All @@ -23,30 +25,8 @@ jobs:
repository: coralogix/opentelemetry-python-contrib
ref: refs/heads/coralogix-python-dev
ssh-key: ${{ secrets.OPENTELEMETRY_CI_GITHUB_KEY }}
- name: build opentelemetry-instrumentation-aws-lambda
working-directory: ./python/sample-apps/otel
run: pip3 wheel -e ../../../opentelemetry-python-contrib/instrumentation/opentelemetry-instrumentation-aws-lambda
- name: build opentelemetry-instrumentation-botocore
working-directory: ./python/sample-apps/otel
run: pip3 wheel -e ../../../opentelemetry-python-contrib/instrumentation/opentelemetry-instrumentation-botocore
- name: build layer
working-directory: ./python/sample-apps/otel
run: |
mkdir -p ./build
python3 -m pip install -r ./otel_sdk/requirements.txt -t ./build/python
python3 -m pip install -r ./otel_sdk/requirements-nodeps.txt -t ./build/tmp --no-deps
cp -r ./build/tmp/* ./build/python/
rm -rf ./build/tmp
cp ./otel_sdk/otel-instrument ./build/otel-instrument
chmod 755 ./build/otel-instrument
cp ./otel_sdk/otel-instrument ./build/otel-handler
chmod 755 ./build/otel-handler
cp ./otel_sdk/otel_wrapper.py ./build/python/
rm -rf ./build/python/boto*
rm -rf ./build/python/urllib3*
- name: package layer
working-directory: ./python/sample-apps/otel/build
run: zip -r layer.zip *
- name: Build python layer
run: ./ci-script/build_python_layer.sh
- uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ vars.SIGNER_AWS_ACCESS_KEY_ID }}
Expand Down
36 changes: 36 additions & 0 deletions ci-scripts/build_python_layer.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/bash

set -euo pipefail

if [ -z "${OPENTELEMETRY_PYTHON_CONTRIB_PATH:-}" ]; then
echo "OPENTELEMETRY_PYTHON_CONTRIB_PATH is not set"
exit 1
fi
OPENTELEMETRY_PYTHON_CONTRIB_PATH=$(realpath $OPENTELEMETRY_PYTHON_CONTRIB_PATH)

CWD=$(pwd)

echo OPENTELEMETRY_PYTHON_CONTRIB_PATH=$OPENTELEMETRY_PYTHON_CONTRIB_PATH
echo CWD=$CWD

# Build build opentelemetry-instrumentation-aws-lambda
pushd ./python/sample-apps/otel
pip3 wheel -e $OPENTELEMETRY_PYTHON_CONTRIB_PATH/instrumentation/opentelemetry-instrumentation-aws-lambda
pip3 wheel -e $OPENTELEMETRY_PYTHON_CONTRIB_PATH/instrumentation/opentelemetry-instrumentation-botocore
mkdir -p ./build
python3 -m pip install -r ./otel_sdk/requirements.txt -t ./build/python
python3 -m pip install -r ./otel_sdk/requirements-nodeps.txt -t ./build/tmp --no-deps
cp -r ./build/tmp/* ./build/python/
rm -rf ./build/tmp
cp ./otel_sdk/otel-instrument ./build/otel-instrument
chmod 755 ./build/otel-instrument
cp ./otel_sdk/otel-instrument ./build/otel-handler
chmod 755 ./build/otel-handler
cp ./otel_sdk/otel_wrapper.py ./build/python/
rm -rf ./build/python/boto*
rm -rf ./build/python/urllib3*
popd > /dev/null

pushd ./python/sample-apps/otel/build
zip -r layer.zip *
popd > /dev/null

0 comments on commit 00eb5b7

Please sign in to comment.