Skip to content

Commit 2c48ec9

Browse files
Harden Python SDK built package smoke
Harden SDK built package smoke Verify the installed wheel exposes package metadata, PEP 561 typing marker, public exports, and reference modules from site-packages before replaying the README quickstart.
1 parent 95b4ee0 commit 2c48ec9

1 file changed

Lines changed: 41 additions & 1 deletion

File tree

scripts/smoke-built-package.py

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ def main() -> int:
4949
wheel = find_wheel((repo_root / args.dist).resolve() if not args.dist.is_absolute() else args.dist.resolve())
5050

5151
smoke_code = r'''
52+
import importlib
53+
import importlib.metadata
5254
import os
5355
import re
5456
from pathlib import Path
@@ -74,6 +76,44 @@ def completed(result):
7476
if package_file.is_relative_to(repo_root):
7577
raise AssertionError(f"durable_workflow imported from source checkout: {package_file}")
7678
79+
metadata_version = importlib.metadata.version("durable-workflow")
80+
if durable_workflow.__version__ != metadata_version:
81+
raise AssertionError(
82+
f"durable_workflow.__version__={durable_workflow.__version__!r} "
83+
f"does not match installed metadata {metadata_version!r}"
84+
)
85+
86+
typed_marker = package_file.parent / "py.typed"
87+
if not typed_marker.is_file():
88+
raise AssertionError(f"installed package is missing PEP 561 marker: {typed_marker}")
89+
90+
missing_exports = [name for name in durable_workflow.__all__ if not hasattr(durable_workflow, name)]
91+
if missing_exports:
92+
raise AssertionError(f"durable_workflow.__all__ names missing exports: {missing_exports}")
93+
94+
reference_modules = [
95+
"durable_workflow.activity",
96+
"durable_workflow.auth_composition",
97+
"durable_workflow.client",
98+
"durable_workflow.errors",
99+
"durable_workflow.external_storage",
100+
"durable_workflow.external_task_input",
101+
"durable_workflow.external_task_result",
102+
"durable_workflow.invocable",
103+
"durable_workflow.metrics",
104+
"durable_workflow.retry_policy",
105+
"durable_workflow.serializer",
106+
"durable_workflow.sync",
107+
"durable_workflow.testing",
108+
"durable_workflow.worker",
109+
"durable_workflow.workflow",
110+
]
111+
for module_name in reference_modules:
112+
module = importlib.import_module(module_name)
113+
module_file = Path(module.__file__).resolve()
114+
if module_file.is_relative_to(repo_root):
115+
raise AssertionError(f"{module_name} imported from source checkout: {module_file}")
116+
77117
readme = Path(os.environ["DW_README"])
78118
text = readme.read_text(encoding="utf-8")
79119
match = re.search(r"## Quickstart\s+```python\n(?P<code>.*?)\n```", text, flags=re.DOTALL)
@@ -96,7 +136,7 @@ def completed(result):
96136
assert isinstance(final, CompleteWorkflow)
97137
assert final.result == "hello, world"
98138
print(f"README quickstart smoke passed using {package_file}")
99-
'''
139+
'''
100140

101141
with tempfile.TemporaryDirectory(prefix="dw-sdk-wheel-smoke-") as tmp:
102142
tmp_path = Path(tmp)

0 commit comments

Comments
 (0)