|
12 | 12 |
|
13 | 13 | nox -s lint |
14 | 14 | nox -s typecheck_core |
| 15 | + nox -s typecheck_functions_package |
15 | 16 | nox -s core_tests-3.10 |
16 | 17 | nox -s azuremanaged_tests-3.10 |
17 | 18 | nox -s functions_unit-3.13 |
|
27 | 28 | import shutil |
28 | 29 | import socket |
29 | 30 | import subprocess |
| 31 | +import tarfile |
30 | 32 | import time |
31 | 33 | import uuid |
| 34 | +import zipfile |
32 | 35 | from pathlib import Path |
33 | 36 | from typing import Sequence |
34 | 37 |
|
@@ -323,6 +326,79 @@ def typecheck_functions(session: nox.Session) -> None: |
323 | 326 | ) |
324 | 327 |
|
325 | 328 |
|
| 329 | +@nox.session(python=["3.13"]) |
| 330 | +def typecheck_functions_package(session: nox.Session) -> None: |
| 331 | + """Check the installed Functions and core wheels with strict Pyright.""" |
| 332 | + session.install("build", "pyright") |
| 333 | + temp_dir = Path(session.create_tmp()) |
| 334 | + artifact_dir = temp_dir / "functions-dist" |
| 335 | + core_artifact_dir = temp_dir / "core-dist" |
| 336 | + if artifact_dir.exists(): |
| 337 | + shutil.rmtree(artifact_dir) |
| 338 | + if core_artifact_dir.exists(): |
| 339 | + shutil.rmtree(core_artifact_dir) |
| 340 | + session.run( |
| 341 | + "python", |
| 342 | + "-m", |
| 343 | + "build", |
| 344 | + "--outdir", |
| 345 | + str(artifact_dir), |
| 346 | + str(AZURE_FUNCTIONS_DURABLE), |
| 347 | + ) |
| 348 | + session.run( |
| 349 | + "python", |
| 350 | + "-m", |
| 351 | + "build", |
| 352 | + "--wheel", |
| 353 | + "--outdir", |
| 354 | + str(core_artifact_dir), |
| 355 | + str(REPO_ROOT), |
| 356 | + ) |
| 357 | + |
| 358 | + wheels = list(artifact_dir.glob("azure_functions_durable-*.whl")) |
| 359 | + sdists = list(artifact_dir.glob("azure_functions_durable-*.tar.gz")) |
| 360 | + core_wheels = list(core_artifact_dir.glob("durabletask-*.whl")) |
| 361 | + if len(wheels) != 1 or len(sdists) != 1 or len(core_wheels) != 1: |
| 362 | + session.error( |
| 363 | + "Expected one provider wheel, provider source distribution, " |
| 364 | + "and core wheel") |
| 365 | + wheel = wheels[0] |
| 366 | + sdist = sdists[0] |
| 367 | + core_wheel = core_wheels[0] |
| 368 | + marker = "azure/durable_functions/py.typed" |
| 369 | + with zipfile.ZipFile(wheel) as archive: |
| 370 | + if marker not in archive.namelist(): |
| 371 | + session.error(f"{marker} is missing from {wheel.name}") |
| 372 | + with tarfile.open(sdist, "r:gz") as archive: |
| 373 | + if not any(name.endswith(f"/{marker}") for name in archive.getnames()): |
| 374 | + session.error(f"{marker} is missing from {sdist.name}") |
| 375 | + |
| 376 | + session.install(str(core_wheel), str(wheel)) |
| 377 | + session.run( |
| 378 | + "python", |
| 379 | + "-m", |
| 380 | + "pip", |
| 381 | + "install", |
| 382 | + "--force-reinstall", |
| 383 | + "--no-deps", |
| 384 | + str(core_wheel), |
| 385 | + str(wheel), |
| 386 | + ) |
| 387 | + python_path = session.run( |
| 388 | + "python", |
| 389 | + "-c", |
| 390 | + "import sys; print(sys.executable)", |
| 391 | + silent=True, |
| 392 | + ).strip() |
| 393 | + session.run( |
| 394 | + "pyright", |
| 395 | + "--pythonpath", |
| 396 | + python_path, |
| 397 | + "-p", |
| 398 | + "tests/azure-functions-durable/typing/pyrightconfig.json", |
| 399 | + ) |
| 400 | + |
| 401 | + |
326 | 402 | @nox.session(python=PYTHON_VERSIONS) |
327 | 403 | def core_tests(session: nox.Session) -> None: |
328 | 404 | """Run core SDK tests against an automatically started Blob Azurite.""" |
@@ -459,6 +535,7 @@ def ci(session: nox.Session) -> None: |
459 | 535 | session.notify("lint", ()) |
460 | 536 | session.notify("typecheck_core", ()) |
461 | 537 | session.notify("typecheck_functions", ()) |
| 538 | + session.notify("typecheck_functions_package", ()) |
462 | 539 | session.notify(f"core_tests-{python_version}", ()) |
463 | 540 | session.notify(f"azuremanaged_tests-{python_version}", ()) |
464 | 541 | session.notify("functions_unit-3.13", ()) |
|
0 commit comments