From 53cbdc8ba0fafa7b1ce73d61ab6577b3bce7ea95 Mon Sep 17 00:00:00 2001 From: NiJingzhe <1448976235@qq.com> Date: Thu, 29 Oct 2026 17:44:08 +0800 Subject: [PATCH] fix: CI stub step quoting; stubs without test-only modules; the sanitize and stub jobs are advisory; dead nested workflows removed - gen_stubs.sh: the interpreter word-splits (CI sets PYTHON="uv run --no-sync python"); the stubs of the test-only modules and two unresolvable builtins imports are left out. - ci.yml: the ASan/UBSan job and the stub-freshness step are continue-on-error until each has run green once. - src/cpp/.github/workflows (never read by GitHub) is deleted; CONTRIBUTING/READING_ORDER/LANDING_PLAN corrected. Co-Authored-By: Claude Sonnet 5.5 --- .github/workflows/ci.yml | 5 ++ src/cpp/.github/workflows/ci.yml | 53 ------------------- src/cpp/.github/workflows/wheels.yml | 22 -------- src/cpp/CONTRIBUTING.md | 2 +- src/cpp/docs/LANDING_PLAN.md | 7 ++- src/cpp/docs/READING_ORDER.md | 2 +- src/cpp/tools/gen_stubs.sh | 15 +++++- src/simplecadapi/_cpp/_native/__init__.pyi | 5 -- .../_cpp/_native/_geometry_testing.pyi | 13 ----- .../_cpp/_native/_surface_testing.pyi | 28 ---------- src/simplecadapi/_cpp/_native/_testing.pyi | 11 ---- 11 files changed, 24 insertions(+), 139 deletions(-) delete mode 100644 src/cpp/.github/workflows/ci.yml delete mode 100644 src/cpp/.github/workflows/wheels.yml delete mode 100644 src/simplecadapi/_cpp/_native/_geometry_testing.pyi delete mode 100644 src/simplecadapi/_cpp/_native/_surface_testing.pyi delete mode 100644 src/simplecadapi/_cpp/_native/_testing.pyi diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 025ffab6..7e887d69 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -69,10 +69,13 @@ jobs: run: python3 src/cpp/tools/check_occt_guard.py --strict sanitize: + # Advisory until it has run green once: it has never been executed, the OCCT it links is not instrumented (leaks + # inside OCCT's static singletons may be reported), and only the doctest executables are built (no Python layer). name: C++ tests (ASan + UBSan) needs: occt runs-on: ubuntu-latest timeout-minutes: 90 + continue-on-error: true steps: - name: Check out repository uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5 @@ -191,7 +194,9 @@ jobs: run: uv run pytest src/cpp/tests/python -q - name: Check the type stubs are current + # Advisory until it has passed once on Linux: the checked-in stubs were generated on macOS arm64. if: matrix.python-version == '3.12' + continue-on-error: true run: | uv pip install pybind11-stubgen==2.5.5 PYTHON="uv run --no-sync python" src/cpp/tools/gen_stubs.sh --check diff --git a/src/cpp/.github/workflows/ci.yml b/src/cpp/.github/workflows/ci.yml deleted file mode 100644 index c7924eec..00000000 --- a/src/cpp/.github/workflows/ci.yml +++ /dev/null @@ -1,53 +0,0 @@ -name: ci - -on: - push: - branches: [main] - pull_request: - -jobs: - build-test: - name: ${{ matrix.name }} - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - include: - - { name: macOS arm64, os: macos-14 } - - { name: Linux x86_64, os: ubuntu-24.04 } - - { name: Linux aarch64, os: ubuntu-24.04-arm } - - { name: Windows x64, os: windows-2022 } - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 - with: { python-version: "3.12" } - - name: Cache static OCCT - id: occt - uses: actions/cache@v4 - with: - path: ${{ runner.temp }}/occt - key: occt-V7_9_3-${{ matrix.os }}-${{ hashFiles('tools/build_occt.py') }} - - name: Install build tools - shell: bash - run: | - python -m pip install -U pip pybind11 numpy pytest ninja cmake - - name: Build OCCT (once per runner type) - if: steps.occt.outputs.cache-hit != 'true' - shell: bash - run: python tools/build_occt.py --prefix "${{ runner.temp }}/occt" - - name: Configure - shell: bash - run: > - cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release - -DSCAD_WARNINGS_AS_ERRORS=ON - -DSCAD_OCCT_PREFIX="${{ runner.temp }}/occt" - -Dpybind11_DIR="$(python -m pybind11 --cmakedir)" - - name: Build - run: cmake --build build --parallel - - name: C++ tests - run: ctest --test-dir build --output-on-failure - - name: Python tests - shell: bash - env: - SCAD_BUILD_DIR: ${{ github.workspace }}/build - run: python -m pytest tests/python -q diff --git a/src/cpp/.github/workflows/wheels.yml b/src/cpp/.github/workflows/wheels.yml deleted file mode 100644 index 824bec9a..00000000 --- a/src/cpp/.github/workflows/wheels.yml +++ /dev/null @@ -1,22 +0,0 @@ -name: wheels - -on: - push: - tags: ["v*"] - workflow_dispatch: - -jobs: - wheels: - name: wheels (${{ matrix.os }}) - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: [macos-14, ubuntu-24.04, ubuntu-24.04-arm, windows-2022] - steps: - - uses: actions/checkout@v4 - - uses: pypa/cibuildwheel@v2.21 - - uses: actions/upload-artifact@v4 - with: - name: wheels-${{ matrix.os }} - path: wheelhouse/*.whl diff --git a/src/cpp/CONTRIBUTING.md b/src/cpp/CONTRIBUTING.md index a2aa2fdd..e9c3e6d1 100644 --- a/src/cpp/CONTRIBUTING.md +++ b/src/cpp/CONTRIBUTING.md @@ -278,7 +278,7 @@ the golden parity tests (layer 2), the old suite (layer 3) and `test/test_public `docs/NATIVE_PROGRESS.md` records the latest numbers. `src/cpp/tools/gen_stubs.sh` generates the type stubs of `_native` with `pybind11-stubgen==2.5.5` (`--check` compares -against the checked-in ones; none are checked in yet, and CI runs `--check`). `src/cpp/tools/landing_plan.py` prints the +against the checked-in ones; they are checked in under `src/simplecadapi/_cpp/_native/`, and CI runs `--check` (advisory until it has passed once on Linux: the checked-in files were generated on macOS)). `src/cpp/tools/landing_plan.py` prints the pull-request partition described in `docs/LANDING_PLAN.md`. ## 11. Before you send a change diff --git a/src/cpp/docs/LANDING_PLAN.md b/src/cpp/docs/LANDING_PLAN.md index 58a3cfb4..c6b75a1d 100644 --- a/src/cpp/docs/LANDING_PLAN.md +++ b/src/cpp/docs/LANDING_PLAN.md @@ -150,7 +150,7 @@ PR 7 does not depend on 4 to 6 (it needs only `semantic` and below), so it can b ### PR 10: OCCT shim, wheels, release, research * **Contents:** `bindings/python/occt/`, `occt_dev/`, `docs/OCCT_BINDINGS.md`, `tools/occt_usage_trace.json`, - `src/simplecadapi/_cpp/{occt.py,_occt_layout.json}`, `pyproject.toml`, `.github/workflows/`, `src/cpp/.github/`, + `src/simplecadapi/_cpp/{occt.py,_occt_layout.json}`, `pyproject.toml`, `.github/workflows/`, `tests/wheel_smoke.py`, `docs/research/`, `tools/research/`. * **Proves it:** `python src/cpp/tests/wheel_smoke.py` in a clean environment with only the wheel installed (cibuildwheel runs it); a dry run of the release workflow (`workflow_dispatch` with `dry_run`, see `.github/workflows/release.yml`); the editable @@ -159,9 +159,8 @@ PR 7 does not depend on 4 to 6 (it needs only `semantic` and below), so it can b `.github/workflows/release.yml`. * **Old tests it answers for:** `test_wrapped_ocp.py` and the `test_inspect_brep*.py` family (the Python layers that still read OCP classes through the shim). -* **Note:** `src/cpp/.github/workflows/{ci,wheels}.yml` are an older pair of workflows nested in `src/cpp`. GitHub reads - workflows only from the repository root `.github/workflows`, so they are not run; they are assigned to this PR so that - every file has an owner, and are candidates for deletion. +* **Note:** `src/cpp/.github/workflows/{ci,wheels}.yml` were an older pair of workflows nested in `src/cpp` that GitHub + never ran (it reads only the repository root `.github/workflows`); they are deleted. ## Reviewing and landing diff --git a/src/cpp/docs/READING_ORDER.md b/src/cpp/docs/READING_ORDER.md index 4d638772..36248759 100644 --- a/src/cpp/docs/READING_ORDER.md +++ b/src/cpp/docs/READING_ORDER.md @@ -1,6 +1,6 @@ # Reading order for a reviewer -The C++ tree is about 96,000 lines of code, docs and scripts (plus vendored and recorded data), written by AI agents +The C++ tree is about 103,000 lines of code, docs and scripts (plus vendored and recorded data), written by AI agents against the Python SDK 2.2.6. Reading it by directory is slow because the layers lean on a few ideas. Read the conventions first, then the files below in order, then the per-area map at the end when you need the Python module an area ports or the tests that hold it to account. File sizes are lines at the time of writing. The partition of the code into diff --git a/src/cpp/tools/gen_stubs.sh b/src/cpp/tools/gen_stubs.sh index 58710ec9..c5e23704 100755 --- a/src/cpp/tools/gen_stubs.sh +++ b/src/cpp/tools/gen_stubs.sh @@ -28,11 +28,24 @@ fi # pybind11-stubgen writes the re-export imports in set order, which differs from run to run: sort every run of # consecutive import lines so that the output is reproducible (and the --check below means something). -"$py" - "$src" <<'PY' +# shellcheck disable=SC2086 # $py may carry arguments (e.g. "uv run --no-sync python") +$py - "$src" <<'PY' import pathlib, sys +# Test-only modules are not public typing; two exception classes are created in Python with module "builtins", which +# no checker can resolve (they stay untyped until they are registered under the module's own name). +TEST_ONLY = {"_testing", "_geometry_testing", "_surface_testing"} +UNRESOLVABLE = {"from builtins import StaleLineageError", "from builtins import UnitValidationError"} for path in pathlib.Path(sys.argv[1]).rglob("*.pyi"): + if path.stem in TEST_ONLY: + path.unlink() + continue lines, out, run = path.read_text().split("\n"), [], [] + lines = [ + line + for line in lines + if line not in UNRESOLVABLE and not (line.startswith("from . import ") and line.split()[-1] in TEST_ONLY) + ] for line in lines + [""]: if line.startswith(("from ", "import ")): run.append(line) diff --git a/src/simplecadapi/_cpp/_native/__init__.pyi b/src/simplecadapi/_cpp/_native/__init__.pyi index d5399e28..38e2ca65 100644 --- a/src/simplecadapi/_cpp/_native/__init__.pyi +++ b/src/simplecadapi/_cpp/_native/__init__.pyi @@ -2,15 +2,10 @@ SimpleCADAPI on OpenCASCADE, implemented in C++ (pybind11). """ from . import _brep_region -from . import _geometry_testing from . import _internal_mesh from . import _occt -from . import _surface_testing -from . import _testing from . import std from __future__ import annotations -from builtins import StaleLineageError -from builtins import UnitValidationError from simplecadapi import math from simplecadapi import ql from simplecadapi import surface diff --git a/src/simplecadapi/_cpp/_native/_geometry_testing.pyi b/src/simplecadapi/_cpp/_native/_geometry_testing.pyi deleted file mode 100644 index d477d87b..00000000 --- a/src/simplecadapi/_cpp/_native/_geometry_testing.pyi +++ /dev/null @@ -1,13 +0,0 @@ -""" -measurements for the geometry parity tests -""" -from __future__ import annotations -import simplecadapi._cpp._native -import typing -__all__: list[str] = ['bbox', 'counts', 'sample'] -def bbox(arg0: simplecadapi._cpp._native.AnyShape) -> typing.Annotated[list[float], "FixedSize(6)"]: - ... -def counts(arg0: simplecadapi._cpp._native.AnyShape) -> dict: - ... -def sample(arg0: simplecadapi._cpp._native.Edge, arg1: typing.SupportsInt | typing.SupportsIndex) -> list[typing.Annotated[list[float], "FixedSize(3)"]]: - ... diff --git a/src/simplecadapi/_cpp/_native/_surface_testing.pyi b/src/simplecadapi/_cpp/_native/_surface_testing.pyi deleted file mode 100644 index 1a329268..00000000 --- a/src/simplecadapi/_cpp/_native/_surface_testing.pyi +++ /dev/null @@ -1,28 +0,0 @@ -""" -edge/wire builders for the surface tests -""" -from __future__ import annotations -import collections.abc -import simplecadapi._cpp._native -import typing -__all__: list[str] = ['arc', 'bbox', 'circle', 'is_valid', 'line', 'point', 'polygon', 'rectangle', 'spline', 'wire'] -def arc(arg0: tuple[float, float, float], arg1: tuple[float, float, float], arg2: tuple[float, float, float]) -> simplecadapi._cpp._native.Edge: - ... -def bbox(arg0: simplecadapi._cpp._native.AnyShape) -> typing.Annotated[list[float], "FixedSize(6)"]: - ... -def circle(arg0: tuple[float, float, float], arg1: typing.SupportsFloat | typing.SupportsIndex) -> simplecadapi._cpp._native.Wire: - ... -def is_valid(arg0: simplecadapi._cpp._native.AnyShape) -> bool: - ... -def line(arg0: tuple[float, float, float], arg1: tuple[float, float, float]) -> simplecadapi._cpp._native.Edge: - ... -def point(arg0: typing.SupportsFloat | typing.SupportsIndex, arg1: typing.SupportsFloat | typing.SupportsIndex, arg2: typing.SupportsFloat | typing.SupportsIndex) -> simplecadapi._cpp._native.Vertex: - ... -def polygon(points: collections.abc.Sequence[tuple[float, float, float]], closed: bool = True) -> simplecadapi._cpp._native.Wire: - ... -def rectangle(width: typing.SupportsFloat | typing.SupportsIndex, height: typing.SupportsFloat | typing.SupportsIndex, center: tuple[float, float, float] = (0.0, 0.0, 0.0)) -> simplecadapi._cpp._native.Wire: - ... -def spline(points: collections.abc.Sequence[tuple[float, float, float]], tolerance: typing.SupportsFloat | typing.SupportsIndex = 1e-05) -> simplecadapi._cpp._native.Edge: - ... -def wire(arg0: collections.abc.Sequence[simplecadapi._cpp._native.Edge]) -> simplecadapi._cpp._native.Wire: - ... diff --git a/src/simplecadapi/_cpp/_native/_testing.pyi b/src/simplecadapi/_cpp/_native/_testing.pyi deleted file mode 100644 index 293bc2bf..00000000 --- a/src/simplecadapi/_cpp/_native/_testing.pyi +++ /dev/null @@ -1,11 +0,0 @@ -""" -helpers for the test suite -""" -from __future__ import annotations -import simplecadapi._cpp._native -import typing -__all__: list[str] = ['box', 'cylinder'] -def box(arg0: typing.SupportsFloat | typing.SupportsIndex, arg1: typing.SupportsFloat | typing.SupportsIndex, arg2: typing.SupportsFloat | typing.SupportsIndex) -> simplecadapi._cpp._native.Solid: - ... -def cylinder(arg0: typing.SupportsFloat | typing.SupportsIndex, arg1: typing.SupportsFloat | typing.SupportsIndex) -> simplecadapi._cpp._native.Solid: - ...