Skip to content

Commit

Permalink
infra: improve tox for local development (#4238)
Browse files Browse the repository at this point in the history
  • Loading branch information
emdneto authored Oct 30, 2024
1 parent 966750a commit 897e8c9
Showing 1 changed file with 66 additions and 79 deletions.
145 changes: 66 additions & 79 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -103,73 +103,70 @@ deps =
coverage: pytest
coverage: pytest-cov

allowlist_externals = sh
mypy,mypyinstalled: -r {toxinidir}/mypy-requirements.txt

setenv =
; override CONTRIB_REPO_SHA via env variable when testing other branches/commits than main
; i.e: CONTRIB_REPO_SHA=dde62cebffe519c35875af6d06fae053b3be65ec tox -e <env to test>
CONTRIB_REPO_SHA={env:CONTRIB_REPO_SHA:main}
CONTRIB_REPO=git+https://github.com/open-telemetry/opentelemetry-python-contrib.git@{env:CONTRIB_REPO_SHA}
mypy: MYPYPATH={toxinidir}/opentelemetry-api/src/:{toxinidir}/opentelemetry-semantic-conventions/src/:{toxinidir}/opentelemetry-sdk/src/:{toxinidir}/tests/opentelemetry-test-utils/src/
api: -r {toxinidir}/opentelemetry-api/test-requirements.txt

commands_pre =
sdk: -r {toxinidir}/opentelemetry-sdk/test-requirements.txt
benchmark-opentelemetry-sdk: -r {toxinidir}/opentelemetry-sdk/benchmark-requirements.txt

mypy,mypyinstalled: pip install -r {toxinidir}/mypy-requirements.txt
semantic-conventions: -r {toxinidir}/opentelemetry-semantic-conventions/test-requirements.txt

api: pip install -r {toxinidir}/opentelemetry-api/test-requirements.txt
test-utils: -r {toxinidir}/tests/opentelemetry-test-utils/test-requirements.txt

sdk: pip install -r {toxinidir}/opentelemetry-sdk/test-requirements.txt
benchmark-opentelemetry-sdk: pip install -r {toxinidir}/opentelemetry-sdk/benchmark-requirements.txt
opentelemetry-proto-protobuf5: -r {toxinidir}/opentelemetry-proto/test-requirements.txt

semantic-conventions: pip install -r {toxinidir}/opentelemetry-semantic-conventions/test-requirements.txt
exporter-opencensus: -r {toxinidir}/exporter/opentelemetry-exporter-opencensus/test-requirements.txt

test-utils: pip install -r {toxinidir}/tests/opentelemetry-test-utils/test-requirements.txt
exporter-otlp-proto-common: -r {toxinidir}/exporter/opentelemetry-exporter-otlp-proto-common/test-requirements.txt

opentelemetry-proto-protobuf5: pip install -r {toxinidir}/opentelemetry-proto/test-requirements.txt
exporter-otlp-combined: -r {toxinidir}/exporter/opentelemetry-exporter-otlp/test-requirements.txt

getting-started: pip install -r {toxinidir}/docs/getting_started/tests/requirements.txt
getting-started: pip install -e {env:CONTRIB_REPO}\#egg=opentelemetry-util-http&subdirectory=util/opentelemetry-util-http
getting-started: pip install -e {env:CONTRIB_REPO}\#egg=opentelemetry-instrumentation&subdirectory=opentelemetry-instrumentation
getting-started: pip install -e {env:CONTRIB_REPO}\#egg=opentelemetry-instrumentation-requests&subdirectory=instrumentation/opentelemetry-instrumentation-requests
getting-started: pip install -e {env:CONTRIB_REPO}\#egg=opentelemetry-instrumentation-wsgi&subdirectory=instrumentation/opentelemetry-instrumentation-wsgi
getting-started: pip install -e {env:CONTRIB_REPO}\#egg=opentelemetry-instrumentation-flask&subdirectory=instrumentation/opentelemetry-instrumentation-flask
opentelemetry-exporter-otlp-proto-grpc: -r {toxinidir}/exporter/opentelemetry-exporter-otlp-proto-grpc/test-requirements.txt
benchmark-exporter-otlp-proto-grpc: -r {toxinidir}/exporter/opentelemetry-exporter-otlp-proto-grpc/benchmark-requirements.txt

exporter-opencensus: pip install -r {toxinidir}/exporter/opentelemetry-exporter-opencensus/test-requirements.txt
opentelemetry-exporter-otlp-proto-http: -r {toxinidir}/exporter/opentelemetry-exporter-otlp-proto-http/test-requirements.txt

exporter-otlp-proto-common: pip install -r {toxinidir}/exporter/opentelemetry-exporter-otlp-proto-common/test-requirements.txt
opentracing-shim: -r {toxinidir}/shim/opentelemetry-opentracing-shim/test-requirements.txt

exporter-otlp-combined: pip install -r {toxinidir}/exporter/opentelemetry-exporter-otlp/test-requirements.txt
opencensus-shim: -r {toxinidir}/shim/opentelemetry-opencensus-shim/test-requirements.txt

opentelemetry-exporter-otlp-proto-grpc: pip install -r {toxinidir}/exporter/opentelemetry-exporter-otlp-proto-grpc/test-requirements.txt
benchmark-exporter-otlp-proto-grpc: pip install -r {toxinidir}/exporter/opentelemetry-exporter-otlp-proto-grpc/benchmark-requirements.txt
exporter-prometheus: -r {toxinidir}/exporter/opentelemetry-exporter-prometheus/test-requirements.txt

opentelemetry-exporter-otlp-proto-http: pip install -r {toxinidir}/exporter/opentelemetry-exporter-otlp-proto-http/test-requirements.txt
exporter-zipkin-combined: -r {toxinidir}/exporter/opentelemetry-exporter-zipkin/test-requirements.txt

opentracing-shim: pip install -r {toxinidir}/shim/opentelemetry-opentracing-shim/test-requirements.txt
exporter-zipkin-proto-http: -r {toxinidir}/exporter/opentelemetry-exporter-zipkin-proto-http/test-requirements.txt

opencensus-shim: pip install -r {toxinidir}/shim/opentelemetry-opencensus-shim/test-requirements.txt
exporter-zipkin-json: -r {toxinidir}/exporter/opentelemetry-exporter-zipkin-json/test-requirements.txt

exporter-prometheus: pip install -r {toxinidir}/exporter/opentelemetry-exporter-prometheus/test-requirements.txt
propagator-b3: -r {toxinidir}/propagator/opentelemetry-propagator-b3/test-requirements.txt
benchmark-opentelemetry-propagator-b3: -r {toxinidir}/propagator/opentelemetry-propagator-b3/benchmark-requirements.txt

exporter-zipkin-combined: pip install -r {toxinidir}/exporter/opentelemetry-exporter-zipkin/test-requirements.txt
propagator-jaeger: -r {toxinidir}/propagator/opentelemetry-propagator-jaeger/test-requirements.txt

exporter-zipkin-proto-http: pip install -r {toxinidir}/exporter/opentelemetry-exporter-zipkin-proto-http/test-requirements.txt
mypyinstalled: -e {toxinidir}/opentelemetry-api

exporter-zipkin-json: pip install -r {toxinidir}/exporter/opentelemetry-exporter-zipkin-json/test-requirements.txt
getting-started: -r {toxinidir}/docs/getting_started/tests/requirements.txt
getting-started: {env:CONTRIB_REPO}\#egg=opentelemetry-util-http&subdirectory=util/opentelemetry-util-http
getting-started: {env:CONTRIB_REPO}\#egg=opentelemetry-instrumentation&subdirectory=opentelemetry-instrumentation
getting-started: {env:CONTRIB_REPO}\#egg=opentelemetry-instrumentation-requests&subdirectory=instrumentation/opentelemetry-instrumentation-requests
getting-started: {env:CONTRIB_REPO}\#egg=opentelemetry-instrumentation-wsgi&subdirectory=instrumentation/opentelemetry-instrumentation-wsgi
getting-started: {env:CONTRIB_REPO}\#egg=opentelemetry-instrumentation-flask&subdirectory=instrumentation/opentelemetry-instrumentation-flask

propagator-b3: pip install -r {toxinidir}/propagator/opentelemetry-propagator-b3/test-requirements.txt
benchmark-opentelemetry-propagator-b3: pip install -r {toxinidir}/propagator/opentelemetry-propagator-b3/benchmark-requirements.txt
allowlist_externals = sh

propagator-jaeger: pip install -r {toxinidir}/propagator/opentelemetry-propagator-jaeger/test-requirements.txt
setenv =
; override CONTRIB_REPO_SHA via env variable when testing other branches/commits than main
; i.e: CONTRIB_REPO_SHA=dde62cebffe519c35875af6d06fae053b3be65ec tox -e <env to test>
CONTRIB_REPO_SHA={env:CONTRIB_REPO_SHA:main}
CONTRIB_REPO=git+https://github.com/open-telemetry/opentelemetry-python-contrib.git@{env:CONTRIB_REPO_SHA}
mypy: MYPYPATH={toxinidir}/opentelemetry-api/src/:{toxinidir}/opentelemetry-semantic-conventions/src/:{toxinidir}/opentelemetry-sdk/src/:{toxinidir}/tests/opentelemetry-test-utils/src/

; In order to get a healthy coverage report,
; we have to install packages in editable mode.
commands_pre =
; In order to get a healthy coverage report,
; we have to install packages in editable mode.
coverage: python {toxinidir}/scripts/eachdist.py install --editable

; Using file:// here because otherwise tox invokes just "pip install
; opentelemetry-api", leading to an error
mypyinstalled: pip install file://{toxinidir}/opentelemetry-api/

commands =
test-opentelemetry-api: pytest {toxinidir}/opentelemetry-api/tests {posargs}
lint-opentelemetry-api: pylint {toxinidir}/opentelemetry-api
Expand Down Expand Up @@ -278,19 +275,17 @@ deps =
flask~=2.3
requests~=2.7
markupsafe~=2.1
-e {toxinidir}/opentelemetry-api
-e {toxinidir}/opentelemetry-semantic-conventions
-e {toxinidir}/opentelemetry-sdk
-e {env:CONTRIB_REPO}\#egg=opentelemetry-util-http&subdirectory=util/opentelemetry-util-http
-e {env:CONTRIB_REPO}\#egg=opentelemetry-instrumentation&subdirectory=opentelemetry-instrumentation
-e {env:CONTRIB_REPO}\#egg=opentelemetry-instrumentation-requests&subdirectory=instrumentation/opentelemetry-instrumentation-requests
-e {env:CONTRIB_REPO}\#egg=opentelemetry-instrumentation-wsgi&subdirectory=instrumentation/opentelemetry-instrumentation-wsgi

allowlist_externals =
{toxinidir}/scripts/tracecontext-integration-test.sh

commands_pre =
pip install -e {toxinidir}/opentelemetry-api \
-e {toxinidir}/opentelemetry-semantic-conventions \
-e {toxinidir}/opentelemetry-sdk \
-e {env:CONTRIB_REPO}\#egg=opentelemetry-util-http&subdirectory=util/opentelemetry-util-http \
-e {env:CONTRIB_REPO}\#egg=opentelemetry-instrumentation&subdirectory=opentelemetry-instrumentation \
-e {env:CONTRIB_REPO}\#egg=opentelemetry-instrumentation-requests&subdirectory=instrumentation/opentelemetry-instrumentation-requests \
-e {env:CONTRIB_REPO}\#egg=opentelemetry-instrumentation-wsgi&subdirectory=instrumentation/opentelemetry-instrumentation-wsgi

commands =
{toxinidir}/scripts/tracecontext-integration-test.sh

Expand All @@ -303,25 +298,25 @@ deps =
docker<7
docker-compose==1.29.2
requests==2.28.2
; core packages
-e {toxinidir}/opentelemetry-api
-e {toxinidir}/opentelemetry-semantic-conventions
-e {toxinidir}/opentelemetry-sdk
-e {toxinidir}/tests/opentelemetry-test-utils
; OTLP packages
otlpexporter: -e {toxinidir}/opentelemetry-proto
otlpexporter: -e {toxinidir}/exporter/opentelemetry-exporter-otlp-proto-common
otlpexporter: -e {toxinidir}/exporter/opentelemetry-exporter-otlp-proto-grpc
otlpexporter: -e {toxinidir}/exporter/opentelemetry-exporter-otlp-proto-http
otlpexporter: -e {toxinidir}/exporter/opentelemetry-exporter-otlp

opencensus: -e {toxinidir}/exporter/opentelemetry-exporter-opencensus

changedir =
tests/opentelemetry-docker-tests/tests

commands_pre =
pip freeze
pip install -e {toxinidir}/opentelemetry-api \
-e {toxinidir}/opentelemetry-semantic-conventions \
-e {toxinidir}/opentelemetry-sdk \
-e {toxinidir}/tests/opentelemetry-test-utils

otlpexporter: pip install -e {toxinidir}/opentelemetry-proto
otlpexporter: pip install -e {toxinidir}/exporter/opentelemetry-exporter-otlp-proto-common
otlpexporter: pip install -e {toxinidir}/exporter/opentelemetry-exporter-otlp-proto-grpc
otlpexporter: pip install -e {toxinidir}/exporter/opentelemetry-exporter-otlp-proto-http
otlpexporter: pip install -e {toxinidir}/exporter/opentelemetry-exporter-otlp

opencensus: pip install -e {toxinidir}/exporter/opentelemetry-exporter-opencensus

docker-compose up -d
commands =
otlpexporter: pytest otlpexporter {posargs}
Expand All @@ -339,32 +334,24 @@ commands =
python {toxinidir}/scripts/public_symbols_checker.py

[testenv:generate-workflows]

commands_pre =
pip install -e {env:CONTRIB_REPO}\#egg=generate_workflows_lib&subdirectory=.github/workflows/generate_workflows_lib

deps =
{env:CONTRIB_REPO}\#egg=generate_workflows_lib&subdirectory=.github/workflows/generate_workflows_lib
commands =
python {toxinidir}/.github/workflows/generate_workflows.py

[testenv:shellcheck]

commands_pre =
sh -c "sudo apt update -y && sudo apt install --assume-yes shellcheck"

commands =
sh -c "find {toxinidir} -name \*.sh | xargs shellcheck --severity=warning"

[testenv:pyright]
basepython: python3

allowlist_externals = pyright

commands_pre =
pip install -r {toxinidir}/pyright-requirements.txt \
-e {toxinidir}/opentelemetry-api \
-e {toxinidir}/opentelemetry-semantic-conventions \
-e {toxinidir}/opentelemetry-sdk

deps =
-r {toxinidir}/pyright-requirements.txt
-e {toxinidir}/opentelemetry-api
-e {toxinidir}/opentelemetry-semantic-conventions
-e {toxinidir}/opentelemetry-sdk
commands =
pyright --version
pyright
Expand Down

0 comments on commit 897e8c9

Please sign in to comment.