Skip to content

Migrate validate config from datadog_checks_dev to ddev#23653

Open
AAraKKe wants to merge 5 commits intomasterfrom
aarakke/migrate-validate-config
Open

Migrate validate config from datadog_checks_dev to ddev#23653
AAraKKe wants to merge 5 commits intomasterfrom
aarakke/migrate-validate-config

Conversation

@AAraKKe
Copy link
Copy Markdown
Contributor

@AAraKKe AAraKKe commented May 10, 2026

What does this PR do?

Migrates the validate config command from datadog_checks_dev/.../tooling/commands/validate/config.py to ddev/src/ddev/cli/validate/config.py, rewriting the implementation to use ddev's Application output style and Repository / Integration data model.

As part of this migration, two supporting modules ship natively in ddev for the first time. They are also consumed by PR 1.13 (validate models), which is unblocked by this PR:

  • ddev/src/ddev/validation/configuration/ — config-spec loader, validator, template engine, and consumers (ExampleConsumer, ModelConsumer). The bundled templates/ tree moves with it. ModelConsumer.create_code_formatter() now takes an optional repo_path argument so callers can pass app.repo.path instead of calling legacy tooling.constants.get_root(). No other public-surface changes.
  • ddev/src/ddev/validation/config_spec/ — the legacy YAML linter (validate_config, SEVERITY_ERROR, SEVERITY_WARNING, ValidatorError). Internals (config_block.py, utils.py) unchanged.

The legacy command file and its ALL_COMMANDS entry are deleted in this PR. The legacy test fixtures under datadog_checks_dev/tests/tooling/commands/validate/data/ are kept because validate models' legacy tests still consume them; they will be removed when that command migrates in PR 1.13.

Helper gap notes

  • tooling.commands.console.annotate_error (GitHub Actions annotations): ddev has no equivalent. Error messages still flow through app.display_error; GH annotations are dropped. (Tracked separately: an app.annotate_* primitive will be added in a follow-up infrastructure PR; this command will be retrofitted then.)
  • tooling.testing.process_checks_option: replaced with _iter_target_checks, which uses app.repo.integrations.iter_all(...) / iter_changed_code() and preserves the datadog_checks_dev/datadog_checks_base fallback semantics from legacy.
  • tooling.utils.get_data_directory / get_version_string / get_config_files: replaced with small private helpers in the migrated file. get_version_string reads __about__.py directly via the Integration.package_directory accessor.
  • tooling.constants.get_rootapp.repo.path. tooling.utils.complete_valid_checks autocomplete is dropped (ddev's native validate commands do not use shell completion for the [CHECK] argument).

Test plan

  • ddev validate config --help output unchanged from master
  • ddev validate config postgres produces identical output and exit code to master
  • ddev validate config all produces identical output to master (539/539 valid)
  • ddev --no-interactive test ddev passes the new test_config suite (4 happy + error path tests covering core/extras/marketplace and sync flow)
  • ddev --no-interactive test datadog_checks_dev passes (428/428)

Motivation

Part of the datadog_checks_devddev CLI migration wave (PR 1.4). Every CLI command currently registered in datadog_checks_dev's legacy tooling tree is being moved into ddev as native code, with the legacy tooling/ directory deleted at the end of the multi-phase migration. This PR is the heaviest in the validate wave because it ships not only the migrated command but also the two supporting modules (validation/configuration/ and validation/config_spec/) that PR 1.13 (validate models) will reuse. Landing this PR is the gate for the rest of the validate wave.

Review checklist (to be filled by reviewers)

  • Feature or bugfix MUST have appropriate tests (unit, integration, e2e)
  • Add the qa/skip-qa label if the PR doesn't need to be tested during QA.
  • If you need to backport this PR to another branch, you can add the backport/<branch-name> label to the PR and it will automatically open a backport PR once this one is merged

Port the `validate config` command, the `tooling/configuration/` spec
loader, and the `tooling/config_validator/` legacy YAML linter from
`datadog_checks_dev` into ddev:

- ddev/src/ddev/cli/validate/config.py: native command using the ddev
  Application/Integration model, with the same CLI surface (`[CHECK]`,
  `--sync/-s`, `--verbose/-v`).
- ddev/src/ddev/validation/configuration/: spec loader, validator,
  template engine, and consumers (ExampleConsumer + ModelConsumer). The
  bundled templates directory moves with it. ModelConsumer
  .create_code_formatter() now takes an optional repo_path argument so
  callers can pass app.repo.path instead of relying on legacy get_root.
- ddev/src/ddev/validation/config_spec/: legacy YAML linter ported
  one-to-one. Public surface (validate_config, SEVERITY_ERROR,
  SEVERITY_WARNING) unchanged.
- Legacy command file, its entry in ALL_COMMANDS, and the legacy
  test_config.py are deleted; the bundled my_check / tokumx fixtures
  stay because validate models tests still consume them.
- Tests rewritten as plain pytest functions in ddev/tests/cli/validate
  /test_config.py using fake_repo/fake_extras_repo/fake_marketplace_repo.

PR 1.13 (validate models) will reuse `ddev.validation.configuration`
unchanged.
@AAraKKe AAraKKe added the qa/skip-qa Automatically skip this PR for the next QA label May 10, 2026
@github-actions
Copy link
Copy Markdown
Contributor

⚠️ Major version bump
The changelog type changed or removed was used in this Pull Request, so the next release will bump major version. Please make sure this is a breaking change, or use the fixed or added type instead.

@datadog-datadog-prod-us1
Copy link
Copy Markdown
Contributor

datadog-datadog-prod-us1 Bot commented May 10, 2026

Tests

Fix all issues with BitsAI or with Cursor

⚠️ Warnings

🧪 1 Test failed

❄️ Known flaky: test_e2e_profile_cisco_asr_1001x from test_e2e_core_vs_python.py   View in Datadog   (Fix with Cursor)
[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] 01-check-apikey.sh: executing... 
[cont-init.d] 01-check-apikey.sh: exited 0.
[cont-init.d] 50-ci.sh: executing... 
[cont-init.d] 50-ci.sh: exited 0.
[cont-init.d] 50-ecs-managed.sh: executing... 
...

ℹ️ Info

No other issues found (see more)

❄️ No new flaky tests detected

🎯 Code Coverage (details)
Patch Coverage: 30.24%
Overall Coverage: 86.39% (-0.87%)

Useful? React with 👍 / 👎

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 5f259a4 | Docs | Datadog PR Page | Give us feedback!

@codecov
Copy link
Copy Markdown

codecov Bot commented May 10, 2026

Codecov Report

❌ Patch coverage is 30.24334% with 1204 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.27%. Comparing base (03b790e) to head (5f259a4).

Additional details and impacted files
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

- Widen validate_fields fields_dict to Mapping[str, object] (read-only key access).
- Correct ModelConsumer.render() return type to Dict[str, Dict[str, Tuple[str, List[str]]]] to match runtime; tighten related helpers and local dicts.
- Annotate openapi_document containers and let _build_type_data return dict | None.
- Annotate spec.files_validator local dicts.
@AAraKKe AAraKKe marked this pull request as ready for review May 10, 2026 21:44
@AAraKKe AAraKKe requested a review from a team as a code owner May 10, 2026 21:44
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 364a36020a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread ddev/src/ddev/cli/validate/config.py Outdated
Comment on lines +151 to +156
if check is None or check.lower() == 'all':
selection = ()
names = sorted({integration.name for integration in app.repo.integrations.iter_all(selection)})
elif check.lower() == 'changed':
changed = sorted({integration.name for integration in app.repo.integrations.iter_changed_code()})
valid = {integration.name for integration in app.repo.integrations.iter_all(())}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Pass an explicit all selection here

When check is omitted or set to all on a dirty checkout/PR, this uses iter_all(()), but IntegrationRegistry.__finalize_selection treats an empty selection as “changed root entries” when any files have changed. As a result ddev validate config all silently validates only changed integrations instead of all valid checks; the same empty-selection lookup on line 156 also prevents the datadog_checks_dev/datadog_checks_base changed case from expanding to the full set. Use the registry's explicit all selection (or another unfiltered path) for these all-check lookups.

Useful? React with 👍 / 👎.

@dd-octo-sts
Copy link
Copy Markdown
Contributor

dd-octo-sts Bot commented May 10, 2026

Validation Report

Validation Description Status
config Validate default configuration files against spec.yaml

Run ddev validate all changed --fix to attempt to auto-fix supported validations.

Passed validations (19)
Validation Description Status
agent-reqs Verify check versions match the Agent requirements file
ci Validate CI configuration and Codecov settings
codeowners Validate every integration has a CODEOWNERS entry
dep Verify dependency pins are consistent and Agent-compatible
http Validate integrations use the HTTP wrapper correctly
imports Validate check imports do not use deprecated modules
integration-style Validate check code style conventions
jmx-metrics Validate JMX metrics definition files and config
labeler Validate PR labeler config matches integration directories
legacy-signature Validate no integration uses the legacy Agent check signature
license-headers Validate Python files have proper license headers
licenses Validate third-party license attribution list
metadata Validate metadata.csv metric definitions
models Validate configuration data models match spec.yaml
openmetrics Validate OpenMetrics integrations disable the metric limit
package Validate Python package metadata and naming
readmes Validate README files have required sections
saved-views Validate saved view JSON file structure and fields
version Validate version consistency between package and changelog

View full run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant