ci(tests): load schemas through infrahub-testcontainers with a pinned Infrahub

BA
9d ago
+1510-38

Jira: https://opsmill.atlassian.net/browse/INFP-697

What changes and why

The schema-test job started the latest Infrahub image with invoke start, so the Infrahub version was not pinned and a load failure showed only the output of one long task. It now runs pytest tests/integration through infrahub-testcontainers, pinned to Infrahub 1.12.1.

  • pyproject.toml and uv.lock: new integration dependency group with infrahub-testcontainers==1.12.1. It resolves with infrahub-sdk[all].
  • tests/unit/: test_docs.py and test_marketplace.py moved here. python-lint runs pytest tests/unit and syncs the integration group so mypy and pylint resolve the imports. A bare pytest without the group skips tests/integration instead of failing at collection.
  • tasks/schemas.py: public load_order(include_experimental=False), which load_all_schemas now uses. It returns only directories that can be loaded (the base/dcim-style keys are files and are left out).
  • tests/integration/: base class TestSchemaLibrary with infrahub_address and ctl. test_schema_load.py starts one Infrahub per class and runs one test per load_order() entry with infrahubctl schema load <path> --wait 60 on main. A test is skipped when a dependency from .metadata.yml failed to load. A load is retried up to twice when the command exits 1 but its output says the schema loaded, which happens when only the --wait poll fails.
  • ci.yml schema-test: single-entry matrix infrahub-version exported as INFRAHUB_TESTING_IMAGE_VER, PYTEST_DEBUG_TEMPROOT step, tini, uv sync --group dev --group integration. The existing needs, if and schema-validate lines are unchanged. pyproject.toml, uv.lock, tasks/schemas.py and tests/integration/** now trigger schema-test.
  • update-infrahub.yml: on trigger-infrahub-update or manual dispatch it validates the version as X.Y.Z, runs uv add --group integration infrahub-testcontainers==X.Y.Z, updates the matrix literal in ci.yml (so the two stay equal), adds a news fragment, pushes infrahub-update/vX.Y.Z and opens a pull request labelled changes/patch with opsmill/sa as reviewer. It does not merge.
  • .github/CODEOWNERS: * @opsmill/sa.
  • tasks/__init__.py: INFRAHUB_VERSION defaults to the installed testcontainers version, or stable when the package is not installed.
  • RELEASING.md: how the pin moves and how to run the test locally.

How it was verified

  • ruff check, ruff format --check, mypy, pylint, yamllint -s, rumdl check: pass. pytest tests/unit: 66 passed. A bare pytest in an environment without the integration group: 66 passed, 1 skipped. invoke --list works. actionlint is not installed locally.
  • Local integration runs on Infrahub 1.12.1 (OrbStack, 12 GB): not a clean pass. Seven full runs took between 4 and 37 minutes. Schemas reported "loaded successfully" in every run, and no schema was rejected. The failures were the --wait poll or the Infrahub server on the laptop (Timeout reading from cache:6379, Server disconnected, Unable to read from ... (timeout: 60 sec)), and in some runs the Docker daemon itself stopped. The retry described above was added after the first run. The last full run still had 4 failures (circuit_contract, routing_bgp, routing_policies_ospf, routing_policies_pim) and their dependents were skipped. That run was cut off before pytest printed the failure messages, so their cause is not known. The result on huge-runners in this pull request is the verification of the full load.

Steps outside this repository

  • Add opsmill/schema-library to the repo matrix in opsmill/infrahub/.github/workflows/repository-dispatch.yml.
  • Confirm that GH_UPDATE_PACKAGE_OTTO reaches this repository.
  • Confirm that @opsmill/sa has write access, which CODEOWNERS requires.

🤖 Generated with Claude Code