Refresh the UK Universal Credit target contract #1273
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Tests | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| python-version: ["3.13", "3.14"] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: astral-sh/setup-uv@v6 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Sync workspace with US engine metadata | |
| # The pool-input sweeps are live PolicyEngine-US ownership and consumer | |
| # existence guards. Installing the US extra makes an upstream formula or | |
| # consumer change fail here instead of being skipped until a remote build. | |
| run: uv sync --all-packages --extra us | |
| - name: Behavioral contract suite + unit tests | |
| # One pytest process per shard. A single process accumulates the | |
| # engine plus every shard's fixtures and repeatedly OOM-killed the | |
| # 7 GB runner at ~91% (the runner-shutdown signature, three runs in | |
| # a row); per-shard processes bound residency and give per-shard | |
| # attribution if one shard ever outgrows the runner on its own. | |
| run: | | |
| for shard in packages/*/; do | |
| uv run pytest "${shard}tests" -p no:cacheprovider | |
| done | |
| - name: Lint | |
| run: uv run ruff check . | |
| wheels: | |
| # The charter-mandated packaging gate: editable installs hide packaging | |
| # breaks (path hacks, missing package dirs, namespace mistakes — the | |
| # microcosm.build/.gitignore incident is the canonical example). Build | |
| # real wheels for every shard, install them into a clean venv with pip | |
| # semantics, and run the suite against the installed constellation. | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| python-version: ["3.13", "3.14"] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: astral-sh/setup-uv@v6 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Build wheels for every shard | |
| run: | | |
| for shard in packages/*/; do | |
| uv build --wheel "$shard" --out-dir dist/ | |
| done | |
| ls -l dist/ | |
| - name: Install from wheels into a clean venv | |
| run: | | |
| uv venv /tmp/wheels-venv | |
| # Constrain third-party resolution to the locked dependency set: | |
| # the seed protocol's normative surface includes RNG library | |
| # versions (generator behavior changes draws), so an unpinned | |
| # install produces a genuinely different — unsupported — spec | |
| # identity and fails the sha pins by design. | |
| uv export --all-packages --no-emit-workspace --no-hashes --quiet \ | |
| --format requirements.txt --output-file /tmp/wheel-constraints.txt | |
| uv pip install --python /tmp/wheels-venv/bin/python \ | |
| --constraint /tmp/wheel-constraints.txt dist/*.whl pytest | |
| - name: Verify clean wheel boundary and import every shard | |
| run: | | |
| env -u PYTHONPATH /tmp/wheels-venv/bin/python -I - <<'PY' | |
| from importlib import metadata, util | |
| from pathlib import Path | |
| import sys | |
| import microcosm.build | |
| import microcosm.calibrate | |
| import microcosm.data | |
| import microcosm.fit | |
| import microcosm.frame | |
| assert util.find_spec("policyengine_us") is None | |
| try: | |
| metadata.distribution("policyengine-us") | |
| except metadata.PackageNotFoundError: | |
| pass | |
| else: | |
| raise AssertionError("policyengine-us must be absent from the base wheel gate") | |
| prefix = Path(sys.prefix).resolve() | |
| modules = ( | |
| microcosm.frame, | |
| microcosm.fit, | |
| microcosm.calibrate, | |
| microcosm.build, | |
| microcosm.data, | |
| ) | |
| for module in modules: | |
| path = Path(module.__file__).resolve() | |
| assert path.is_relative_to(prefix), f"source import escaped wheel venv: {path}" | |
| print(module.__name__, module.__version__, path) | |
| PY | |
| - name: Spec identity section digests (cross-environment diffing aid) | |
| run: env -u PYTHONPATH /tmp/wheels-venv/bin/python -I tools/spec_envelope_digests.py be uk | |
| - name: Run the suite against the installed wheels | |
| run: | | |
| env -u PYTHONPATH /tmp/wheels-venv/bin/python -I -m pytest \ | |
| packages/*/tests -p no:cacheprovider |