Skip to content

Commit

Permalink
Improve build process by moving to script (#63)
Browse files Browse the repository at this point in the history
In this commit, we are moving the build and install distro steps to a
script to make it easier to run. As well, we are moving
`set-up-contract-tests.sh` to the scripts folder for consistency.

By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice.
  • Loading branch information
thpierce authored Feb 15, 2024
1 parent 12c070b commit ec3011e
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ jobs:

- name: Set up and run contract tests with pytest
run: |
bash contract-tests/set-up-contract-tests.sh
bash scripts/set-up-contract-tests.sh
pip install pytest
pytest contract-tests/tests
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:

- name: Set up and run contract tests with pytest
run: |
bash contract-tests/set-up-contract-tests.sh
bash scripts/set-up-contract-tests.sh
pip install pytest
pytest contract-tests/tests
Expand Down
17 changes: 3 additions & 14 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,10 @@ documentation, we greatly value feedback and contributions from our community.
Please read through this document before submitting any issues or pull requests to ensure we have all the necessary
information to effectively respond to your bug report or contribution.

## Build a Wheel file locally
**First time setup**
## Build and install distro locally
From `aws-otel-python-instrumentation` dir, execute:
```sh
pip install --upgrade pip setuptools wheel packaging build
mkdir -p ./dist
```
**Updating the wheel file**
```sh
rm -rf ./dist/*
cd ./aws-opentelemetry-distro
python3 -m build --outdir ../dist
cd ../dist
pkg_version=$(grep '__version__' ../aws-opentelemetry-distro/src/amazon/opentelemetry/distro/version.py | awk -F '"' '{print $2}')
pip install aws_opentelemetry_distro-${pkg_version}-py3-none-any.whl --force-reinstall
cd ..
./scripts/build_and_install_distro.sh
```

## Test a sample App
Expand Down
10 changes: 5 additions & 5 deletions contract-tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ The steps to add a new test for a library or framework are:

Pre-requirements:
* Have `docker` installed and running - verify by running the `docker` command.
* Ensure the `aws_opentelemetry_distro` wheel file exists in to `aws-otel-python-instrumentation/dist` folder

From `aws-otel-python-instrumentation` dir, execute:

```
./contract-tests/set-up-contract-tests.sh
Steps:
* From `aws-otel-python-instrumentation` dir, execute:
```sh
./scripts/build_and_install_distro.sh
./scripts/set-up-contract-tests.sh
pytest contract-tests/tests
```
23 changes: 23 additions & 0 deletions scripts/build_and_install_distro.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash
# Check script is running in contract-tests
current_path=`pwd`
current_dir="${current_path##*/}"
if [ "$current_dir" != "aws-otel-python-instrumentation" ]; then
echo "Please run from aws-otel-python-instrumentation dir"
exit
fi

# Setup - update dependencies and create/empty dist dir
pip install --upgrade pip setuptools wheel packaging build
mkdir dist
rm -rf dist/aws_opentelemetry_distro*

# Build distro
cd aws-opentelemetry-distro
python3 -m build --outdir ../dist

# Install distro
cd ../dist
DISTRO=(aws_opentelemetry_distro-*-py3-none-any.whl)
pip install $DISTRO --force-reinstall
cd ..
File renamed without changes.

0 comments on commit ec3011e

Please sign in to comment.