@@ -310,6 +310,215 @@ jobs:
310310 env :
311311 CODECOV_TOKEN : ${{ secrets.CODECOV_TOKEN }}
312312
313+ # ------------------------------------------ Dependency Bounds ------------------------------------------
314+ # `unit-tests` installs what uv.lock pins, so it never exercises the ranges in pyproject.toml.
315+ # Upper bounds are tracked separately: an upstream release could turn such a job red on its own.
316+
317+ # Deterministic enough to gate on, since floors only move when pyproject.toml does. Development
318+ # dependencies mask some floors; `dependency-lower-bounds-no-harness` below reaches those.
319+ dependency-lower-bounds :
320+ env :
321+ # workaround for Rich table column width
322+ COLUMNS : 140
323+ if : |
324+ always() && !cancelled() &&
325+ !contains(needs.*.result, 'failure') &&
326+ !contains(needs.*.result, 'cancelled') &&
327+ needs.files-changed.outputs.python == 'true'
328+ needs : ["prepare-environment", "files-changed", "yaml-lint", "python-lint"]
329+ runs-on : ubuntu-latest
330+ timeout-minutes : 30
331+ steps :
332+ - name : " Check out repository code"
333+ uses : " actions/checkout@v7"
334+ # Oldest supported interpreter: pyarrow 14, pyyaml 6.0 and ujson 5.0 have no wheels past
335+ # cp312, so a newer one would build them from source. Bump when requires-python changes.
336+ - name : Set up Python
337+ uses : actions/setup-python@v7
338+ with :
339+ python-version : " 3.10"
340+ - name : Install UV
341+ uses : astral-sh/setup-uv@v7
342+ with :
343+ version : " ${{ needs.prepare-environment.outputs.UV_VERSION }}"
344+ python-version : " 3.10"
345+ # Rewrites uv.lock in the checkout, which is discarded with the runner.
346+ - name : " Re-resolve at the declared lower bounds"
347+ run : uv lock --resolution lowest-direct
348+ - name : Install dependencies
349+ run : uv sync --frozen --all-groups --all-extras
350+ - name : " Report the resolved versions"
351+ run : uv pip list
352+ - name : Unit Tests
353+ run : uv run --frozen pytest --cov infrahub_sdk tests/unit/
354+
355+ # Proves a plain install works on every supported interpreter, which the uv.lock-based jobs cannot.
356+ install-matrix :
357+ strategy :
358+ matrix :
359+ python-version : ["3.10", "3.11", "3.12", "3.13", "3.14"]
360+ if : |
361+ always() && !cancelled() &&
362+ !contains(needs.*.result, 'failure') &&
363+ !contains(needs.*.result, 'cancelled') &&
364+ needs.files-changed.outputs.python == 'true'
365+ needs : ["prepare-environment", "files-changed", "yaml-lint", "python-lint"]
366+ runs-on : ubuntu-latest
367+ timeout-minutes : 15
368+ steps :
369+ - name : " Check out repository code"
370+ uses : " actions/checkout@v7"
371+ with :
372+ # hatch-vcs derives the version from git tags, and a shallow clone has none.
373+ fetch-depth : 0
374+ - name : Set up Python ${{ matrix.python-version }}
375+ uses : actions/setup-python@v7
376+ with :
377+ python-version : ${{ matrix.python-version }}
378+ - name : Install UV
379+ uses : astral-sh/setup-uv@v7
380+ with :
381+ version : " ${{ needs.prepare-environment.outputs.UV_VERSION }}"
382+ python-version : ${{ matrix.python-version }}
383+ - name : " Build the wheel"
384+ run : uv build --wheel --out-dir dist/
385+ # Not `uv sync`: a fresh resolution of the built wheel is what a user actually gets.
386+ - name : " Install the wheel with every extra"
387+ run : |
388+ uv venv --python ${{ matrix.python-version }} .venv-install
389+ uv pip install --python .venv-install "$(echo dist/*.whl)[all]"
390+ - name : " Report the resolved versions"
391+ run : uv pip list --python .venv-install
392+ # Run from elsewhere: `python -` puts the working directory on sys.path, so from the checkout
393+ # this would import the source tree rather than the wheel.
394+ - name : " Import every shipped module"
395+ working-directory : ${{ runner.temp }}
396+ run : |
397+ ${{ github.workspace }}/.venv-install/bin/python - <<'PY'
398+ import importlib, pkgutil, sys
399+ import infrahub_sdk
400+
401+ failures = []
402+ for module in pkgutil.walk_packages(infrahub_sdk.__path__, "infrahub_sdk."):
403+ try:
404+ importlib.import_module(module.name)
405+ except BaseException as exc: # noqa: BLE001
406+ failures.append(f"{module.name}: {type(exc).__name__}: {exc}")
407+ for failure in failures:
408+ print(f"FAIL {failure}")
409+ print(f"{len(failures)} module(s) failed to import")
410+ sys.exit(1 if failures else 0)
411+ PY
412+ - name : " Run the CLI"
413+ run : |
414+ .venv-install/bin/infrahubctl --help
415+ .venv-install/bin/infrahubctl schema --help
416+ .venv-install/bin/infrahubctl branch --help
417+
418+ # With no dependency groups, nothing pulls pytest, pydantic, anyio or typing-extensions above
419+ # their declared floors, so this is the only job that validates those four. httpx and
420+ # graphql-core stay out of reach: ariadne-codegen requires httpx>=0.28 and graphql-core>=3.2.
421+ # It cannot run the unit suite without the harness, so it checks the surface a user touches.
422+ dependency-lower-bounds-no-harness :
423+ if : |
424+ always() && !cancelled() &&
425+ !contains(needs.*.result, 'failure') &&
426+ !contains(needs.*.result, 'cancelled') &&
427+ needs.files-changed.outputs.python == 'true'
428+ needs : ["prepare-environment", "files-changed", "yaml-lint", "python-lint"]
429+ runs-on : ubuntu-latest
430+ timeout-minutes : 15
431+ steps :
432+ - name : " Check out repository code"
433+ uses : " actions/checkout@v7"
434+ with :
435+ # hatch-vcs derives the version from git tags, and a shallow clone has none.
436+ fetch-depth : 0
437+ # The oldest supported interpreter, for the same wheel-availability reason as the job above.
438+ - name : Set up Python
439+ uses : actions/setup-python@v7
440+ with :
441+ python-version : " 3.10"
442+ - name : Install UV
443+ uses : astral-sh/setup-uv@v7
444+ with :
445+ version : " ${{ needs.prepare-environment.outputs.UV_VERSION }}"
446+ python-version : " 3.10"
447+ - name : " Build the wheel"
448+ run : uv build --wheel --out-dir dist/
449+ # From pyproject.toml, not the wheel: `--resolution lowest-direct` only lowers what is named
450+ # on the command line, so asking for the wheel leaves its dependencies at their newest.
451+ - name : " Resolve the extras at their declared lower bounds"
452+ run : |
453+ uv pip compile pyproject.toml --extra ctl --extra testing \
454+ --resolution lowest-direct --python-version 3.10 -o floors.txt
455+ - name : " Install the wheel against those floors, with no dependency groups"
456+ run : |
457+ uv venv --python 3.10 .venv-floors
458+ uv pip install --python .venv-floors -r floors.txt
459+ uv pip install --python .venv-floors --no-deps "$(echo dist/*.whl)"
460+ - name : " Report the resolved versions"
461+ run : uv pip list --python .venv-floors
462+ # From outside the checkout, so this tests the wheel in site-packages and not the source tree.
463+ - name : " Import every shipped module"
464+ working-directory : ${{ runner.temp }}
465+ run : |
466+ ${{ github.workspace }}/.venv-floors/bin/python - <<'PY'
467+ import importlib, pkgutil, sys
468+ import infrahub_sdk
469+
470+ # `testing.docker` needs the testcontainers extra, which is deliberately absent here.
471+ skip = {"infrahub_sdk.testing.docker"}
472+ failures = []
473+ for module in pkgutil.walk_packages(infrahub_sdk.__path__, "infrahub_sdk."):
474+ if module.name in skip:
475+ continue
476+ try:
477+ importlib.import_module(module.name)
478+ except BaseException as exc: # noqa: BLE001
479+ failures.append(f"{module.name}: {type(exc).__name__}: {exc}")
480+ for failure in failures:
481+ print(f"FAIL {failure}")
482+ print(f"{len(failures)} module(s) failed to import")
483+ sys.exit(1 if failures else 0)
484+ PY
485+ - name : " Run the CLI"
486+ run : |
487+ .venv-floors/bin/infrahubctl --help
488+ .venv-floors/bin/infrahubctl schema --help
489+ .venv-floors/bin/infrahubctl branch --help
490+ # Collection is where the plugin does its work; importing it would prove far less.
491+ - name : " Collect a test through the bundled pytest plugin"
492+ working-directory : ${{ runner.temp }}
493+ run : |
494+ rm -rf plugin-check && mkdir -p plugin-check/templates && cd plugin-check
495+ cat > infrahub_config.yml <<'YAML'
496+ ---
497+ jinja2_transforms:
498+ - name: bgp_config
499+ description: "Template for BGP config base"
500+ query: "bgp_sessions"
501+ template_path: "templates/bgp_config.j2"
502+ YAML
503+ cat > test_bgp.yml <<'YAML'
504+ ---
505+ infrahub_tests:
506+ - resource: "Jinja2Transform"
507+ resource_name: "bgp_config"
508+ tests:
509+ - name: smoke
510+ spec:
511+ kind: "jinja2-transform-smoke"
512+ YAML
513+ printf 'router bgp {{ asn }}\n' > templates/bgp_config.j2
514+ # The default shell is `bash -e` without pipefail, so a pytest failure would otherwise
515+ # be reported as a grep failure.
516+ set -o pipefail
517+ ${{ github.workspace }}/.venv-floors/bin/python -m pytest \
518+ --infrahub-repo-config=infrahub_config.yml --strict-markers --collect-only -q \
519+ | tee collected.txt
520+ grep -q "infrahub_jinja2_transform__bgp_config__smoke" collected.txt
521+
313522 # ------------------------------------------ Integration Tests ------------------------------------------
314523 integration-tests-latest-infrahub :
315524 if : |
@@ -450,6 +659,9 @@ jobs:
450659 - validate-documentation-style
451660 - unit-tests
452661 - integration-tests-latest-infrahub
662+ - dependency-lower-bounds
663+ - dependency-lower-bounds-no-harness
664+ - install-matrix
453665 runs-on : " ubuntu-latest"
454666 timeout-minutes : 5
455667 steps :
0 commit comments