|
| 1 | +--- |
| 2 | +summary: Add a CI job that installs each optional extra in isolation and imports lite_bootstrap (catching undeclared transitive dependencies the `--all-extras`-only suite masks), and fix the litestar bug it found — the `litestar.plugins.prometheus` import is guarded by litestar presence but needs prometheus_client, so `lite-bootstrap[litestar]` crashed on import. |
| 3 | +--- |
| 4 | + |
| 5 | +# Design: Per-extra isolation install-check + fix the litestar/prometheus import |
| 6 | + |
| 7 | +## Summary |
| 8 | + |
| 9 | +Existing CI only ever installs `--all-extras`, so any extra that imports a |
| 10 | +package it does not declare passes CI while breaking a real single-extra install. |
| 11 | +This shipped twice (the bare-core `typing_extensions` crash in 1.3.1, and the |
| 12 | +litestar bug below). Add a CI job that installs **each** extra in its own clean |
| 13 | +venv and imports `lite_bootstrap`, and fix the one live bug a local sweep found. |
| 14 | + |
| 15 | +## Motivation |
| 16 | + |
| 17 | +An isolation sweep (clean venv per extra → `import lite_bootstrap`) across all 28 |
| 18 | +extras on Python 3.10 and 3.12 found: |
| 19 | + |
| 20 | +- **`litestar`, `litestar-sentry`, `litestar-otl`, `litestar-logging` crash on |
| 21 | + import** (both versions): `litestar_bootstrapper.py:36` does |
| 22 | + `from litestar.plugins.prometheus import PrometheusConfig, PrometheusController` |
| 23 | + under the `is_litestar_installed` guard, but that litestar plugin imports |
| 24 | + `prometheus_client`, which the `litestar` extra does not install (only |
| 25 | + `litestar-metrics` does). `litestar-metrics`/`litestar-all` pass because they |
| 26 | + pull `prometheus-client` in. So `pip install lite-bootstrap[litestar]` + |
| 27 | + `import lite_bootstrap` raises `MissingDependencyException: prometheus_client`. |
| 28 | +- Everything else (bare core + 24 extras) imports clean. |
| 29 | +- (`fastmcp` on local macOS-arm 3.10 hit a `cryptography` Rust source-build |
| 30 | + failure — a local toolchain artifact, not a bug: `cryptography` supports ≥3.9 |
| 31 | + via abi3 wheels, so it installs on Linux CI. The check runs on Linux.) |
| 32 | + |
| 33 | +## Design |
| 34 | + |
| 35 | +### 1. Fix the litestar/prometheus import |
| 36 | + |
| 37 | +Move line 36 into its own guard (the usage sites at `litestar_bootstrapper.py:209,219` |
| 38 | +already run only when `check_dependencies() → is_prometheus_client_installed`, |
| 39 | +so this only tightens the import to match — same shape as the otl-exporter guard): |
| 40 | + |
| 41 | +```python |
| 42 | +if import_checker.is_litestar_installed and import_checker.is_prometheus_client_installed: |
| 43 | + from litestar.plugins.prometheus import PrometheusConfig, PrometheusController |
| 44 | +``` |
| 45 | + |
| 46 | +TDD: `emulate_package_missing_with_module_reload("prometheus_client", ["...litestar_bootstrapper"])` |
| 47 | +must not crash the reload; assert `import_checker.is_prometheus_client_installed` |
| 48 | +is False and the bootstrapper module reimports. Fails on current code, green after. |
| 49 | + |
| 50 | +### 2. Isolation install-check CI job |
| 51 | + |
| 52 | +A single `install-isolation` job in `.github/workflows/_checks.yml`, Python |
| 53 | +**3.10** (the floor — the undeclared-dep class is version-independent, and the |
| 54 | +floor surfaces the most gated behavior; the `--all-extras` pytest matrix already |
| 55 | +covers all versions, and the ft legs cover per-extra installs on 3.13t/3.14t): |
| 56 | + |
| 57 | +```yaml |
| 58 | + install-isolation: |
| 59 | + runs-on: ubuntu-latest |
| 60 | + steps: |
| 61 | + - uses: actions/checkout@v6 |
| 62 | + - uses: astral-sh/setup-uv@v8.2.0 |
| 63 | + with: |
| 64 | + enable-cache: true |
| 65 | + cache-dependency-glob: "**/pyproject.toml" |
| 66 | + - run: uv python install 3.10 |
| 67 | + - name: Each extra installs and imports in isolation |
| 68 | + run: | |
| 69 | + set -uo pipefail |
| 70 | + extras="orjson sentry pyroscope otl otl-http logging free-all \ |
| 71 | + fastapi fastapi-sentry fastapi-otl fastapi-logging fastapi-metrics fastapi-all \ |
| 72 | + litestar litestar-sentry litestar-otl litestar-logging litestar-metrics litestar-all \ |
| 73 | + faststream faststream-sentry faststream-otl faststream-logging faststream-metrics faststream-all \ |
| 74 | + fastmcp fastmcp-metrics fastmcp-all" |
| 75 | + failed="" |
| 76 | + # bare core first |
| 77 | + uv venv --python 3.10 .v-bare >/dev/null |
| 78 | + uv pip install --python .v-bare/bin/python . >/dev/null 2>&1 \ |
| 79 | + && .v-bare/bin/python -c "import lite_bootstrap" \ |
| 80 | + || failed="$failed __bare__" |
| 81 | + rm -rf .v-bare |
| 82 | + for e in $extras; do |
| 83 | + uv venv --python 3.10 ".v-$e" >/dev/null |
| 84 | + if uv pip install --python ".v-$e/bin/python" ".[$e]" >/dev/null 2>&1 \ |
| 85 | + && ".v-$e/bin/python" -c "import lite_bootstrap"; then :; else failed="$failed $e"; fi |
| 86 | + rm -rf ".v-$e" |
| 87 | + done |
| 88 | + if [ -n "$failed" ]; then echo "::error::extras failed isolated install+import:$failed"; exit 1; fi |
| 89 | + echo "all extras install and import in isolation" |
| 90 | +``` |
| 91 | +
|
| 92 | +Collects **all** failures (does not stop at first) and fails listing them. |
| 93 | +
|
| 94 | +## Non-goals |
| 95 | +
|
| 96 | +- Multi-version isolation matrix (floor-only per the reasoning above). |
| 97 | +- Running a bootstrap per extra (import is the cheap, sufficient signal for the |
| 98 | + undeclared-dependency class). |
| 99 | +
|
| 100 | +## Testing |
| 101 | +
|
| 102 | +- The litestar fix's unit test (above); `just test` 100% coverage; `just lint-ci` clean. |
| 103 | +- The new CI job is the systemic proof: green means every extra imports in isolation. |
| 104 | + |
| 105 | +## Risk |
| 106 | + |
| 107 | +- **The isolation job surfaces a genuine install gap on 3.10 (e.g. an extra whose |
| 108 | + dep truly lacks a 3.10 Linux wheel).** That is the job doing its work; handle |
| 109 | + case-by-case (a `python_version` marker on the extra, or documentation). Not |
| 110 | + expected for the current matrix. |
0 commit comments