Skip to content

Commit

Permalink
use tox-uv
Browse files Browse the repository at this point in the history
  • Loading branch information
emdneto committed Jul 15, 2024
1 parent 7590ec4 commit 5bb44f7
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 22 deletions.
15 changes: 13 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,17 @@ See
[`tox.ini`](https://github.com/open-telemetry/opentelemetry-python-contrib/blob/main/tox.ini)
for more detail on available tox commands.

### Tox UV support (experimental)

You can run tox wi th `uv` support with the following commands:
```sh
pip install tox-uv
```

```sh
TOX_UV="uv" tox -e py312-test-instrumentation-aiopg
```

### Troubleshooting

> Some packages may require additional system wide dependencies to be installed. For example, you may need to install `libpq-dev` to run the postgresql client libraries instrumentation tests. or `libsnappy-dev` to run the prometheus exporter tests. If you encounter a build error, please check the installation instructions for the package you are trying to run tests for.
Expand Down Expand Up @@ -141,7 +152,7 @@ Run tests:

```sh
# make sure you have all supported versions of Python installed
$ pip install tox # only first time.
$ pip install tox tox-uv # only first time.
$ tox # execute in the root of the repository
```

Expand Down Expand Up @@ -213,7 +224,7 @@ For a deeper discussion, see: https://github.com/open-telemetry/opentelemetry-sp
## Running Tests Locally

1. Go to your Contrib repo directory. `git clone [email protected]:open-telemetry/opentelemetry-python-contrib.git && cd opentelemetry-python-contrib`.
2. Make sure you have `tox` installed. `pip install tox`.
2. Make sure you have `tox` installed. `pip install tox tox-uv`.
3. Run `tox` without any arguments to run tests for all the packages. Read more about [tox](https://tox.readthedocs.io/en/latest/).

Some tests can be slow due to pre-steps that do dependencies installs. To help with that, you can run tox a first time, and after that run the tests using previous installed dependencies in toxdir as following:
Expand Down
37 changes: 17 additions & 20 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -373,17 +373,8 @@ envlist =

generate

[testenv:base]
core =
opentelemetry-api@{env:CORE_REPO}\#egg=opentelemetry-api&subdirectory=opentelemetry-api \
opentelemetry-semantic-conventions@{env:CORE_REPO}\#egg=opentelemetry-semantic-conventions&subdirectory=opentelemetry-semantic-conventions \
opentelemetry-sdk@{env:CORE_REPO}\#egg=opentelemetry-sdk&subdirectory=opentelemetry-sdk
utils =
opentelemetry-test-utils@{env:CORE_REPO}\#egg=opentelemetry-test-utils&subdirectory=tests/opentelemetry-test-utils

[testenv]
deps =
uv
lint: -r dev-requirements.txt
coverage: pytest
coverage: pytest-cov
Expand All @@ -397,22 +388,28 @@ setenv =
; i.e: CORE_REPO_SHA=dde62cebffe519c35875af6d06fae053b3be65ec tox -e <env to test>
CORE_REPO_SHA={env:CORE_REPO_SHA:main}
CORE_REPO=git+https://github.com/open-telemetry/opentelemetry-python.git@{env:CORE_REPO_SHA}
CORE_PACKAGES=\
opentelemetry-api@{env:CORE_REPO}\#egg=opentelemetry-api&subdirectory=opentelemetry-api \
opentelemetry-semantic-conventions@{env:CORE_REPO}\#egg=opentelemetry-semantic-conventions&subdirectory=opentelemetry-semantic-conventions \
opentelemetry-sdk@{env:CORE_REPO}\#egg=opentelemetry-sdk&subdirectory=opentelemetry-sdk
TEST_UTILS_PACKAGE=opentelemetry-test-utils@{env:CORE_REPO}\#egg=opentelemetry-test-utils&subdirectory=tests/opentelemetry-test-utils
UV_CMD={env:TOX_UV:}

commands_pre =
opentelemetry-instrumentation: uv pip install {[testenv:base]core} {[testenv:base]utils}
opentelemetry-instrumentation: uv pip install -r {toxinidir}/opentelemetry-instrumentation/test-requirements.txt
opentelemetry-instrumentation: {env:UV_CMD} pip install {env:CORE_PACKAGES} {env:TEST_UTILS_PACKAGE}
opentelemetry-instrumentation: {env:UV_CMD} pip install -r {toxinidir}/opentelemetry-instrumentation/test-requirements.txt

distro: uv pip install {[testenv:base]core} {[testenv:base]utils}
distro: uv pip install -r {toxinidir}/opentelemetry-distro/test-requirements.txt
distro: {env:UV_CMD} pip install {env:CORE_PACKAGES} {env:TEST_UTILS_PACKAGE}
distro: {env:UV_CMD} pip install -r {toxinidir}/opentelemetry-distro/test-requirements.txt

asgi: uv pip install {[testenv:base]core} {[testenv:base]utils}
asgi: uv pip install -r {toxinidir}/instrumentation/opentelemetry-instrumentation-asgi/test-requirements.txt
asgi: {env:UV_CMD} pip install {env:CORE_PACKAGES} {env:TEST_UTILS_PACKAGE}
asgi: {env:UV_CMD} pip install -r {toxinidir}/instrumentation/opentelemetry-instrumentation-asgi/test-requirements.txt

celery: uv pip install {[testenv:base]core} {[testenv:base]utils}
py3{8,9}-test-instrumentation-celery: uv pip install -r {toxinidir}/instrumentation/opentelemetry-instrumentation-celery/test-requirements-0.txt
py3{10,11,12}-test-instrumentation-celery: uv pip install -r {toxinidir}/instrumentation/opentelemetry-instrumentation-celery/test-requirements-1.txt
pypy3-test-instrumentation-celery: uv pip install -r {toxinidir}/instrumentation/opentelemetry-instrumentation-celery/test-requirements-1.txt
lint-instrumentation-celery: uv pip install -r {toxinidir}/instrumentation/opentelemetry-instrumentation-celery/test-requirements-1.txt
celery: {env:UV_CMD} pip install {env:CORE_PACKAGES} {env:TEST_UTILS_PACKAGE}
py3{8,9}-test-instrumentation-celery: {env:UV_CMD} pip install -r {toxinidir}/instrumentation/opentelemetry-instrumentation-celery/test-requirements-0.txt
py3{10,11,12}-test-instrumentation-celery: {env:UV_CMD} pip install -r {toxinidir}/instrumentation/opentelemetry-instrumentation-celery/test-requirements-1.txt
pypy3-test-instrumentation-celery: {env:UV_CMD} pip install -r {toxinidir}/instrumentation/opentelemetry-instrumentation-celery/test-requirements-1.txt
lint-instrumentation-celery: {env:UV_CMD} pip install -r {toxinidir}/instrumentation/opentelemetry-instrumentation-celery/test-requirements-1.txt

sio-pika: pip install opentelemetry-api@{env:CORE_REPO}\#egg=opentelemetry-api&subdirectory=opentelemetry-api
sio-pika: pip install opentelemetry-semantic-conventions@{env:CORE_REPO}\#egg=opentelemetry-semantic-conventions&subdirectory=opentelemetry-semantic-conventions
Expand Down

0 comments on commit 5bb44f7

Please sign in to comment.