diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 97ee1f7..df08a5c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,6 +10,27 @@ env: UV_PYTHON: "3.11" jobs: + wheel: + name: Unit tests (installed wheel) + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: astral-sh/setup-uv@v4 + with: + version: "latest" + - run: uv python install 3.11 + - name: Build and install the candidate wheel + run: | + uv build --wheel --out-dir "$RUNNER_TEMP/wheel-dist" + sha256sum "$RUNNER_TEMP"/wheel-dist/*.whl + uv venv --python 3.11 "$RUNNER_TEMP/wheel-env" + wheel=("$RUNNER_TEMP"/wheel-dist/*.whl) + test "${#wheel[@]}" -eq 1 + uv pip install --python "$RUNNER_TEMP/wheel-env/bin/python" "${wheel[0]}[dev,all]" + - name: Run the unit suite against the installed wheel + run: | + "$RUNNER_TEMP/wheel-env/bin/python" -I scripts/check_wheel.py + lint: name: Lint runs-on: ubuntu-latest diff --git a/scripts/check_wheel.py b/scripts/check_wheel.py new file mode 100644 index 0000000..e28ca38 --- /dev/null +++ b/scripts/check_wheel.py @@ -0,0 +1,31 @@ +"""Run the unit suite against the wheel installed in this environment, not the checkout.""" + +import sys +from importlib.metadata import version +from pathlib import Path + +import pytest + +import arc_client + +repo = Path(__file__).resolve().parents[1] +package = Path(arc_client.__file__).resolve().parent +assert repo not in package.parents, f"Imported checkout instead of wheel: {package}" +assert Path(sys.prefix).resolve() in package.parents, f"Package outside environment: {package}" +print(f"arc-tsdb-client {version('arc-tsdb-client')}: {package}", flush=True) + + +def check_imports(): + for name, module in tuple(sys.modules.items()): + if name == "arc_client" or name.startswith("arc_client."): + origin = Path(module.__file__).resolve() + assert package in origin.parents, f"Source import during wheel tests: {name}: {origin}" + + +check_imports() +# The whole unit suite, so a module or data file the wheel leaves out fails +# here whichever feature it belongs to. Install with [dev,all]: without pandas +# and polars their tests skip instead of running. +result = pytest.main(["--import-mode=importlib", "-o", "addopts=", "-q", str(repo / "tests/unit")]) +check_imports() +sys.exit(result)