[envs.lint]
detached = true
python = "3.10"
dependencies = [
    "black==23.10.1",
    "click==8.1.7",
    "cython-lint==0.15.0",
    "codespell==2.4.1",
    "bandit==1.8.2",
    "mypy==1.15.0",
    "coverage==7.3.0",
    "envier==0.6.1",
    "types-docutils==0.19.1.1",
    "types-protobuf==3.20.4.5",
    "types-PyYAML==6.0.12.2",
    "types-setuptools==65.6.0.0",
    "ddapm-test-agent>=1.2.0",
    "packaging==23.1",
    "pygments==2.16.1",
    "riot==0.20.1",
    "ruff==0.11.11",
    "clang-format==18.1.5",
    "cmake-format==0.6.13",
    "ruamel.yaml==0.18.6",
    "ast-grep-cli==0.39.4",
]

[envs.lint.scripts]
black_check = [
    "black --check {args:.}",
]
cmakeformat_check = [
    "bash scripts/cmake-format.sh"
]
cformat_check = [
    "bash scripts/cformat.sh"
]
style = [
    "black_check",
    "ruff check {args:.}",
    "cython-lint {args:.}",
    "cformat_check",
    "cmakeformat_check",
]
fmt = [
    "black {args:.}",
    "ruff check --fix {args:.}",
    "style",
]
# checks should encapsulate all rules used in pre-check
checks = [
    "style",
    "typing",
    "spelling",
    "riot",
    "security",
    "test",
    "suitespec-check",
    "error-log-check",
    "sg",
    "sg-test",
]
spelling = [
    "codespell -I docs/spelling_wordlist.txt --skip='ddwaf.h,*cassettes*,tests/tracer/fixtures/urls.txt,tests/appsec/iast/fixtures/*' {args:ddtrace/ tests/ releasenotes/ docs/}",
]
typing = [
    "mypy {args}",
]
security = [
    "bandit -c pyproject.toml {args:-r ddtrace/}",
]
fmt-snapshots = [
    "ddapm-test-agent-fmt {args:tests/snapshots/}",
]
riot = [
    "python -m doctest {args} riotfile.py"
]
suitespec-check = [
    "python scripts/check_suitespec_coverage.py"
]
error-log-check = [
    "python scripts/check_constant_log_message.py"
]
sg = [
    "ast-grep scan {args:.}",
]
sg-test = [
    "ast-grep test {args}",
]

[envs.scripts]
detached = true
python = "3.10"
extra-dependencies = [
    "lxml==5.3.0",
    "packaging==23.1",
    "ruamel.yaml==0.18.6",
    "vcrpy==6.0.2",
]

[envs.scripts.scripts]
test = [
    "python -m doctest {args} scripts/get-target-milestone.py scripts/needs_testrun.py tests/suitespec.py",
]
needs_testrun = [
  "scripts/needs_testrun.py {args}",
]


## ASM Appsec Aggregated Leak Testing

[envs.iast_aggregated_leak_testing]
template = "iast_aggregated_leak_testing"
dependencies = [
    "pytest",
    "pytest-cov",
    "hypothesis",
    "requests",
    "pytest-asyncio",
    "anyio",
    "pydantic",
    "pydantic-settings",
]

[envs.iast_aggregated_leak_testing.env-vars]
DD_IAST_ENABLED = "true"
_DD_IAST_PATCH_MODULES = "benchmarks.,tests.appsec.,scripts.iast."
DD_FAST_BUILD = "0"

[envs.iast_aggregated_leak_testing.scripts]
test = [
    "uname -a",
    "pip freeze",
    # We use --no-cov due to a pytest-cov problem with eval https://github.com/pytest-dev/pytest-cov/issues/676
    "python -m pytest --no-cov tests/appsec/iast_aggregated_memcheck/test_aggregated_memleaks.py",
]

[[envs.iast_aggregated_leak_testing.matrix]]
python = ["3.10", "3.11", "3.12"]

## pytorch profiling test

[envs.profiling_pytorch]
dependencies = [
    "pytest",
    "pytest-cov",
    "requests",
    "hypothesis",
    "torch>=1.8.1",
    "torchvision",
    "zstandard",
]

[envs.profiling_pytorch.env-vars]
DD_PROFILING_ENABLED = "true"
DD_PROFILING_PYTORCH_ENABLED = "true"

[envs.profiling_pytorch.scripts]
test = [
    "uname -a",
    "pip freeze",
    "python -m pytest tests/profiling_v2/test_pytorch.py -vvv --capture=tee-sys",
]

[[envs.profiling_pytorch.matrix]]
python = ["3.12"]

## Multiple OS tests

[envs.multiple_os_tests]
dependencies = [
    "pytest",
    "pytest-cov",
    "requests",
    "hypothesis",
    "flask",
    "asgiref",
    "botocore",
    "dnspython",
]

[envs.multiple_os_tests.env-vars]
DD_IAST_ENABLED = "false"
DD_REMOTE_CONFIGURATION_ENABLED = "false"
CMAKE_BUILD_PARALLEL_LEVEL="6"
CARGO_BUILD_JOBS = "6"

[envs.multiple_os_tests.scripts]
test = [
    "uname -a",
    "pip freeze",
    "python -m pytest tests/internal/service_name/test_extra_services_names.py -v -s",
    "python -m pytest tests/appsec/architectures/test_appsec_loading_modules.py -v -s",
]

[[envs.multiple_os_tests.matrix]]
python = ["3.14", "3.12", "3.10", "3.8"]

[envs.snapshot_viewer]
dev-mode = false
detached = true
template = "snapshot_viewer"
dependencies = [
    "PrettyPrintTree"
]

[envs.snapshot_viewer.scripts]
view = [
    "python scripts/ci_visibility/view_snapshot.py {args:}",
]

