diff --git a/.codespellrc b/.codespellrc index 1e85aefda8..45c5dc4237 100644 --- a/.codespellrc +++ b/.codespellrc @@ -1,4 +1,4 @@ [codespell] # skipping auto generated folders -skip = ./.tox,./.mypy_cache,./docs/_build,./target,*/LICENSE,./venv +skip = ./.tox,./.mypy_cache,./docs/_build,./target,*/LICENSE,./venv,*-requirements*.txt ignore-words-list = ot diff --git a/.github/workflows/lint_1.yml b/.github/workflows/lint_1.yml new file mode 100644 index 0000000000..4465107bcf --- /dev/null +++ b/.github/workflows/lint_1.yml @@ -0,0 +1,41 @@ +name: lint 1 + +on: + push: + branches-ignore: + - 'release/*' + pull_request: +env: + CORE_REPO_SHA: 955c92e91b5cd4bcfb43c39efcef086b040471d2 + +jobs: + test-1: + 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: + package: + - "resource/opentelemetry-resource-detector-container" + - "sdk-extension/opentelemetry-sdk-extension-aws" + os: [ubuntu-20.04] + steps: + - name: Checkout Contrib Repo @ SHA - ${{ github.sha }} + uses: actions/checkout@v4 + - name: Set up Python ${{ env[matrix.python-version] }} + uses: actions/setup-python@v5 + with: + python-version: "3.11" + - name: Install tox + run: pip install tox + - name: Cache tox environment + # Preserves .tox directory between runs for faster installs + uses: actions/cache@v4 + with: + path: | + .tox + ~/.cache/pip + key: v7-build-tox-cache-${{ env.RUN_MATRIX_COMBINATION }}-${{ hashFiles('tox.ini', 'gen-requirements.txt', 'dev-requirements.txt') }} + - name: run tox + run: tox -c ${{ matrix.package }}/tox.ini -e lint diff --git a/.github/workflows/spellcheck_1.yml b/.github/workflows/spellcheck_1.yml new file mode 100644 index 0000000000..7767625752 --- /dev/null +++ b/.github/workflows/spellcheck_1.yml @@ -0,0 +1,41 @@ +name: spellcheck 1 + +on: + push: + branches-ignore: + - 'release/*' + pull_request: +env: + CORE_REPO_SHA: 955c92e91b5cd4bcfb43c39efcef086b040471d2 + +jobs: + test-1: + 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: + package: + - "resource/opentelemetry-resource-detector-container" + - "sdk-extension/opentelemetry-sdk-extension-aws" + os: [ubuntu-20.04] + steps: + - name: Checkout Contrib Repo @ SHA - ${{ github.sha }} + uses: actions/checkout@v4 + - name: Set up Python ${{ env[matrix.python-version] }} + uses: actions/setup-python@v5 + with: + python-version: "3.11" + - name: Install tox + run: pip install tox + - name: Cache tox environment + # Preserves .tox directory between runs for faster installs + uses: actions/cache@v4 + with: + path: | + .tox + ~/.cache/pip + key: v7-build-tox-cache-${{ env.RUN_MATRIX_COMBINATION }}-${{ hashFiles('tox.ini', 'gen-requirements.txt', 'dev-requirements.txt') }} + - name: run tox + run: tox -c ${{ matrix.package }}/tox.ini -e spellcheck diff --git a/.github/workflows/test_1.yml b/.github/workflows/test_1.yml new file mode 100644 index 0000000000..e5c6f6edf9 --- /dev/null +++ b/.github/workflows/test_1.yml @@ -0,0 +1,52 @@ +name: test 1 + +on: + push: + branches-ignore: + - 'release/*' + pull_request: +env: + CORE_REPO_SHA: 955c92e91b5cd4bcfb43c39efcef086b040471d2 + +jobs: + test-1: + env: + py38: 3.8 + py39: 3.9 + py310: "3.10" + py311: "3.11" + pypy3: pypy-3.8 + 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: [py38, py39, py310, py311, pypy3] + package: + - "resource/opentelemetry-resource-detector-container" + - "sdk-extension/opentelemetry-sdk-extension-aws" + os: [ubuntu-20.04] + exclude: + - python-version: py311 + package: "prometheus-remote-write" + - python-version: pypy3 + package: "prometheus-remote-write" + steps: + - name: Checkout Contrib Repo @ SHA - ${{ github.sha }} + uses: actions/checkout@v4 + - name: Set up Python ${{ env[matrix.python-version] }} + uses: actions/setup-python@v5 + with: + python-version: ${{ env[matrix.python-version] }} + - name: Install tox + run: pip install tox + - name: Cache tox environment + # Preserves .tox directory between runs for faster installs + uses: actions/cache@v4 + with: + path: | + .tox + ~/.cache/pip + key: v7-build-tox-cache-${{ env.RUN_MATRIX_COMBINATION }}-${{ hashFiles('tox.ini', 'gen-requirements.txt', 'dev-requirements.txt') }} + - name: run tox + run: tox -c ${{ matrix.package }}/tox.ini -e test-${{ matrix.python-version }} -- -ra diff --git a/.gitignore b/.gitignore index c359e13727..01e4e3750a 100644 --- a/.gitignore +++ b/.gitignore @@ -27,13 +27,14 @@ venv*/ # Installer logs pip-log.txt -# Unit test / coverage reports +# Unit test / coverage, benchmark reports coverage.xml .coverage .nox .tox .cache htmlcov +benchmark.json # Translations *.mo diff --git a/.isort.cfg b/.isort.cfg index afe42d3d41..472b99add6 100644 --- a/.isort.cfg +++ b/.isort.cfg @@ -14,6 +14,6 @@ profile=black ; docs: https://github.com/timothycrosley/isort#multi-line-output-modes multi_line_output=3 skip=target -skip_glob=**/gen/*,.venv*/*,venv*/*,.tox/* +skip_glob=**/gen/*,.venv*/*,venv*/*,.tox/*,**/.tox/* known_first_party=opentelemetry known_third_party=psutil,pytest,redis,redis_opentracing diff --git a/coverage-requirements.txt b/coverage-requirements.txt new file mode 100644 index 0000000000..45ecafb133 --- /dev/null +++ b/coverage-requirements.txt @@ -0,0 +1,2 @@ +coverage==7.5.1 +pytest-cov==5.0.0 diff --git a/lint-requirements.txt b/lint-requirements.txt new file mode 100644 index 0000000000..99790daa3f --- /dev/null +++ b/lint-requirements.txt @@ -0,0 +1,20 @@ +astroid==3.1.0 +black==24.4.2 +click==8.1.7 +Deprecated==1.2.14 +dill==0.3.8 +flake8==7.0.0 +importlib-metadata==7.0.0 +isort==5.13.2 +mccabe==0.7.0 +mypy-extensions==1.0.0 +packaging==24.0 +pathspec==0.12.1 +platformdirs==4.2.1 +pycodestyle==2.11.1 +pyflakes==3.2.0 +pylint==3.1.0 +tomlkit==0.12.4 +typing_extensions==4.11.0 +wrapt==1.16.0 +zipp==3.18.1 diff --git a/resource/opentelemetry-resource-detector-container/test-requirements.txt b/resource/opentelemetry-resource-detector-container/test-requirements.txt index 07dd186f30..1dfe2f07c6 100644 --- a/resource/opentelemetry-resource-detector-container/test-requirements.txt +++ b/resource/opentelemetry-resource-detector-container/test-requirements.txt @@ -10,4 +10,3 @@ tomli==2.0.1 typing_extensions==4.10.0 wrapt==1.16.0 zipp==3.17.0 --e resource/opentelemetry-resource-detector-container diff --git a/resource/opentelemetry-resource-detector-container/tox.ini b/resource/opentelemetry-resource-detector-container/tox.ini new file mode 100644 index 0000000000..8c2ad54efd --- /dev/null +++ b/resource/opentelemetry-resource-detector-container/tox.ini @@ -0,0 +1,48 @@ +[tox] +isolated_build = True +skipsdist = True +skip_missing_interpreters = True +envlist = + test-py3{8,9,10,11} + test-pypy3 + lint + coverage + spellcheck + +[testenv] +setenv = + ; override CORE_REPO_SHA via env variable when testing other branches/commits than main + ; i.e: CORE_REPO_SHA=dde62cebffe519c35875af6d06fae053b3be65ec tox -e + CORE_REPO_SHA={env:CORE_REPO_SHA:main} + CORE_REPO=git+https://github.com/open-telemetry/opentelemetry-python.git@{env:CORE_REPO_SHA} + +commands_pre = + test,lint,coverage: pip install opentelemetry-api@{env:CORE_REPO}\#egg=opentelemetry-api&subdirectory=opentelemetry-api + test,lint,coverage: pip install opentelemetry-semantic-conventions@{env:CORE_REPO}\#egg=opentelemetry-semantic-conventions&subdirectory=opentelemetry-semantic-conventions + test,lint,coverage: pip install opentelemetry-sdk@{env:CORE_REPO}\#egg=opentelemetry-sdk&subdirectory=opentelemetry-sdk + test,lint,coverage: pip install opentelemetry-test-utils@{env:CORE_REPO}\#egg=opentelemetry-test-utils&subdirectory=tests/opentelemetry-test-utils + test,lint,coverage: pip install -e . + + test,coverage: pip install -r {toxinidir}/test-requirements.txt + + lint: pip install -r {toxinidir}/../../lint-requirements.txt + + coverage: pip install -r {toxinidir}/../../coverage-requirements.txt + + spellcheck: pip install -r {toxinidir}/../../spellcheck-requirements.txt + +commands = + test: pytest {toxinidir}/tests {posargs} + + lint: black --diff --check --config {toxinidir}/../../pyproject.toml {toxinidir} + lint: isort --diff --check-only --settings-path {toxinidir}/../../.isort.cfg {toxinidir} + lint: flake8 --config {toxinidir}/../../.flake8 {toxinidir} + lint: pylint --rcfile={toxinidir}/../../.pylintrc {toxinidir}/src/opentelemetry + lint: pylint --rcfile={toxinidir}/../../.pylintrc {toxinidir}/tests + + coverage: coverage erase + coverage: pytest --cov={toxinidir}/src --cov-append --cov-branch --cov-report='' {toxinidir}/tests + coverage: coverage report --show-missing + coverage: coverage xml + + spellcheck: codespell --config {toxinidir}/../../.codespellrc {toxinidir} diff --git a/sdk-extension/opentelemetry-sdk-extension-aws/benchmark-requirements.txt b/sdk-extension/opentelemetry-sdk-extension-aws/benchmark-requirements.txt new file mode 100644 index 0000000000..44564857ef --- /dev/null +++ b/sdk-extension/opentelemetry-sdk-extension-aws/benchmark-requirements.txt @@ -0,0 +1 @@ +pytest-benchmark==4.0.0 diff --git a/sdk-extension/opentelemetry-sdk-extension-aws/tests/performance/benchmarks/trace/test_benchmark_aws_xray_ids_generator.py b/sdk-extension/opentelemetry-sdk-extension-aws/benchmarks/trace/test_benchmark_aws_xray_ids_generator.py similarity index 100% rename from sdk-extension/opentelemetry-sdk-extension-aws/tests/performance/benchmarks/trace/test_benchmark_aws_xray_ids_generator.py rename to sdk-extension/opentelemetry-sdk-extension-aws/benchmarks/trace/test_benchmark_aws_xray_ids_generator.py diff --git a/sdk-extension/opentelemetry-sdk-extension-aws/test-requirements.txt b/sdk-extension/opentelemetry-sdk-extension-aws/test-requirements.txt index 4ed081e748..1dfe2f07c6 100644 --- a/sdk-extension/opentelemetry-sdk-extension-aws/test-requirements.txt +++ b/sdk-extension/opentelemetry-sdk-extension-aws/test-requirements.txt @@ -6,9 +6,7 @@ packaging==24.0 pluggy==1.5.0 py-cpuinfo==9.0.0 pytest==7.4.4 -pytest-benchmark==4.0.0 tomli==2.0.1 typing_extensions==4.10.0 wrapt==1.16.0 zipp==3.17.0 --e sdk-extension/opentelemetry-sdk-extension-aws diff --git a/sdk-extension/opentelemetry-sdk-extension-aws/tox.ini b/sdk-extension/opentelemetry-sdk-extension-aws/tox.ini new file mode 100644 index 0000000000..def30c6916 --- /dev/null +++ b/sdk-extension/opentelemetry-sdk-extension-aws/tox.ini @@ -0,0 +1,52 @@ +[tox] +isolated_build = True +skipsdist = True +skip_missing_interpreters = True +envlist = + test-py3{8,9,10,11} + test-pypy3 + lint + coverage + spellcheck + +[testenv] +setenv = + ; override CORE_REPO_SHA via env variable when testing other branches/commits than main + ; i.e: CORE_REPO_SHA=dde62cebffe519c35875af6d06fae053b3be65ec tox -e + CORE_REPO_SHA={env:CORE_REPO_SHA:main} + CORE_REPO=git+https://github.com/open-telemetry/opentelemetry-python.git@{env:CORE_REPO_SHA} + +commands_pre = + test,lint,coverage,benchmark: pip install opentelemetry-api@{env:CORE_REPO}\#egg=opentelemetry-api&subdirectory=opentelemetry-api + test,lint,coverage,benchmark: pip install opentelemetry-semantic-conventions@{env:CORE_REPO}\#egg=opentelemetry-semantic-conventions&subdirectory=opentelemetry-semantic-conventions + test,lint,coverage,benchmark: pip install opentelemetry-sdk@{env:CORE_REPO}\#egg=opentelemetry-sdk&subdirectory=opentelemetry-sdk + test,lint,coverage,benchmark: pip install opentelemetry-test-utils@{env:CORE_REPO}\#egg=opentelemetry-test-utils&subdirectory=tests/opentelemetry-test-utils + test,lint,coverage,benchmark: pip install -e . + + test,coverage,benchmark: pip install -r {toxinidir}/test-requirements.txt + + lint: pip install -r {toxinidir}/../../lint-requirements.txt + + coverage: pip install -r {toxinidir}/../../coverage-requirements.txt + + spellcheck: pip install -r {toxinidir}/../../spellcheck-requirements.txt + + benchmark: pip install -r {toxinidir}/benchmark-requirements.txt + +commands = + test: pytest {toxinidir}/tests {posargs} + + lint: black --diff --check --config {toxinidir}/../../pyproject.toml {toxinidir} + lint: isort --diff --check-only --settings-path {toxinidir}/../../.isort.cfg {toxinidir} + lint: flake8 --config {toxinidir}/../../.flake8 {toxinidir} + lint: pylint --rcfile={toxinidir}/../../.pylintrc {toxinidir}/src/opentelemetry + lint: pylint --rcfile={toxinidir}/../../.pylintrc {toxinidir}/tests + + coverage: coverage erase + coverage: pytest --cov={toxinidir}/src --cov-append --cov-branch --cov-report='' {toxinidir}/tests + coverage: coverage report --show-missing + coverage: coverage xml + + spellcheck: codespell --config {toxinidir}/../../.codespellrc {toxinidir} + + benchmark: pytest {toxinidir}/benchmarks --benchmark-json=benchmark.json diff --git a/spellcheck-requirements.txt b/spellcheck-requirements.txt new file mode 100644 index 0000000000..e0a43e1384 --- /dev/null +++ b/spellcheck-requirements.txt @@ -0,0 +1 @@ +codespell==2.2.6 diff --git a/tox.ini b/tox.ini index 0cd5094cb8..41ba681010 100644 --- a/tox.ini +++ b/tox.ini @@ -377,7 +377,6 @@ deps = coverage: pytest coverage: pytest-cov - ; FIXME: add coverage testing ; FIXME: add mypy testing allowlist_externals = sh @@ -778,10 +777,6 @@ commands_pre = util-http: pip install -r {toxinidir}/util/opentelemetry-util-http/test-requirements.txt util-http: pip install {toxinidir}/util/opentelemetry-util-http -; In order to get a health coverage report, -; we have to install packages in editable mode. - coverage: python {toxinidir}/scripts/eachdist.py install --editable - commands = test-distro: pytest {toxinidir}/opentelemetry-distro/tests {posargs} lint-distro: black --diff --check --config {toxinidir}/pyproject.toml {toxinidir}/opentelemetry-distro @@ -1137,8 +1132,6 @@ commands = lint-exporter-prometheus-remote-write: flake8 --config {toxinidir}/.flake8 {toxinidir}/exporter/opentelemetry-exporter-prometheus-remote-write lint-exporter-prometheus-remote-write: sh -c "cd exporter && pylint --rcfile ../.pylintrc opentelemetry-exporter-prometheus-remote-write" - coverage: {toxinidir}/scripts/coverage.sh - [testenv:docs] deps = -c {toxinidir}/dev-requirements.txt