Port the WAS wealth imputation and regional property uprating as declarative source stages #1256
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 | |
| run: uv run pytest | |
| - 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 | |
| uv pip install --python /tmp/wheels-venv/bin/python 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: Run the suite against the installed wheels | |
| run: | | |
| env -u PYTHONPATH /tmp/wheels-venv/bin/python -I -m pytest \ | |
| packages/*/tests -p no:cacheprovider |