Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.12.8
hooks:
# Run the linter.
- id: ruff
args: ["--fix", "--show-fixes"]
# Run the formatter.
- id: ruff-format
5 changes: 4 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ Automated testing of this repo uses [tox](https://tox.readthedocs.io) and runs i

1. Create and run a Docker build container as described above.
2. To run all tests for a specific version, provide tox options as a string. For example, to run in Python 3.9: `make tox OPTIONS="-e py39-test"`.
3. (WARNING: slow!) To run all tests for all supported Python environments, as well as linting and formatting: `make tox`
3. To run tests specific to Lambda instrumentation in Python 3.13: `make tox OPTIONS="-e py313-lambda"`.
4. (WARNING: slow!) To run all tests for all supported Python environments, as well as linting and formatting: `make tox`

Other regular `tox` arguments can be included in `OPTIONS`. Some examples:

Expand Down Expand Up @@ -78,6 +79,8 @@ make tox OPTIONS="-e py312-lint -- --check-only"
make tox OPTIONS="-e py39-lint"
```

`ruff` is also available to fix formatting: `make tox OPTIONS="-e ruff"`.

Remotely, CodeQL can be run on GitHub with the [CodeQL Analysis](https://github.com/solarwinds/apm-python/actions/workflows/codeql_analysis.yaml) workflow.

### Install locally and instrument a test app
Expand Down
28 changes: 17 additions & 11 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,38 +5,37 @@ envlist =
py3{9,10,11,12,13}-test
py3{9,10,11,12,13}-lambda
py3{9,10,11,12,13}-lint
ruff

[testenv]
setenv =
OTEL_PYTHON_DISABLED_INSTRUMENTATIONS = urllib3
SW_APM_DEBUG_LEVEL = 3
allowlist_externals = echo
usedevelop = true
deps =
-rdev-requirements.txt
commands_pre =
py3{9,10,11,12,13}: pip install --upgrade pip
py3{9,10,11,12,13}: pip install -Ie {toxinidir}
-r {toxinidir}/dev-requirements.txt
commands =
pytest {posargs}

[testenv:py3{9,10,11,12,13}-test]
changedir = tests
deps =
{[testenv]deps}
-e {toxinidir}
setenv =
SW_APM_COLLECTOR = apm.collector.st-ssp.solarwinds.com
SW_APM_SERVICE_KEY = foo-bar:service-key

[testenv:py3{9,10,11,12,13}-lambda]
changedir = lambda/tests
commands_pre =
py3{9,10,11,12,13}-lambda: pip install -r requirements.txt

[testenv:py3{9,10,11,12,13}-lambda-gh]
changedir = lambda/tests
commands_pre =
py3{9,10,11,12,13}-lambda: pip install -r requirements.txt
deps =
{[testenv]deps}
-r {toxinidir}/lambda/tests/requirements.txt

[testenv:py3{9,10,11,12,13}-lint]
deps =
{[testenv]deps}
opentelemetry-api
opentelemetry-sdk
opentelemetry-instrumentation
Expand All @@ -49,3 +48,10 @@ deps =
psutil
commands =
python scripts/lint_and_format.py {posargs}

[testenv:ruff]
basepython: python3
deps =
pre-commit
commands =
pre-commit run --color=always --all-files {posargs}
Loading