|
| 1 | +name: python (pybt) |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [master] |
| 6 | + paths: |
| 7 | + - 'python/**' |
| 8 | + - 'include/behaviortree_cpp/**' |
| 9 | + - 'src/**' |
| 10 | + - 'CMakeLists.txt' |
| 11 | + - '.github/workflows/python_test.yml' |
| 12 | + pull_request: |
| 13 | + types: [opened, synchronize, reopened] |
| 14 | + paths: |
| 15 | + - 'python/**' |
| 16 | + - 'include/behaviortree_cpp/**' |
| 17 | + - 'src/**' |
| 18 | + - 'CMakeLists.txt' |
| 19 | + - '.github/workflows/python_test.yml' |
| 20 | + workflow_dispatch: |
| 21 | + |
| 22 | +concurrency: |
| 23 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 24 | + cancel-in-progress: true |
| 25 | + |
| 26 | +jobs: |
| 27 | + # --------------------------------------------------------------------------- |
| 28 | + # Lint, type-check, smoke tests, and benchmarks across the supported Python |
| 29 | + # versions. STABLE_ABI means one abi3 wheel covers 3.12+, so the matrix is |
| 30 | + # just (3.12, 3.13) — plus 3.13t (free-threaded) as opt-in / allowed-to-fail. |
| 31 | + # --------------------------------------------------------------------------- |
| 32 | + test: |
| 33 | + name: test (cp${{ matrix.python }}) |
| 34 | + runs-on: ubuntu-22.04 |
| 35 | + strategy: |
| 36 | + fail-fast: false |
| 37 | + matrix: |
| 38 | + python: ["3.12", "3.13"] |
| 39 | + include: |
| 40 | + - python: "3.13t" |
| 41 | + continue-on-error: true |
| 42 | + continue-on-error: ${{ matrix.continue-on-error || false }} |
| 43 | + steps: |
| 44 | + - uses: actions/checkout@v6 |
| 45 | + with: |
| 46 | + fetch-depth: 0 # setuptools-scm needs full history |
| 47 | + |
| 48 | + - uses: actions/setup-python@v6 |
| 49 | + with: |
| 50 | + python-version: ${{ matrix.python }} |
| 51 | + |
| 52 | + - name: Cache pip |
| 53 | + uses: actions/cache@v4 |
| 54 | + with: |
| 55 | + path: ~/.cache/pip |
| 56 | + key: pip-${{ runner.os }}-py${{ matrix.python }}-${{ hashFiles('python/pyproject.toml') }} |
| 57 | + |
| 58 | + - name: Set up ccache |
| 59 | + uses: hendrikmuhs/ccache-action@v1.2 |
| 60 | + with: |
| 61 | + key: ccache-${{ runner.os }}-py${{ matrix.python }} |
| 62 | + |
| 63 | + - name: Install pybt (editable, with dev extras) |
| 64 | + run: pip install -e python/[dev] -v |
| 65 | + |
| 66 | + - name: ruff check |
| 67 | + run: ruff check python/ |
| 68 | + |
| 69 | + - name: mypy |
| 70 | + run: mypy python/src/pybt/ |
| 71 | + continue-on-error: true # mypy on a fresh nanobind extension surfaces noise until stub gen lands |
| 72 | + |
| 73 | + - name: pytest -m smoke |
| 74 | + run: pytest python/tests -n auto -m smoke |
| 75 | + |
| 76 | + - name: pytest benchmarks (record only, no thresholds yet) |
| 77 | + run: pytest python/benchmarks/ --benchmark-only --benchmark-json=bench.json |
| 78 | + |
| 79 | + - name: Upload benchmark results |
| 80 | + if: always() |
| 81 | + uses: actions/upload-artifact@v4 |
| 82 | + with: |
| 83 | + name: bench-cp${{ matrix.python }} |
| 84 | + path: bench.json |
| 85 | + if-no-files-found: ignore |
| 86 | + |
| 87 | + # --------------------------------------------------------------------------- |
| 88 | + # Symbol hygiene: assert that no Python/nanobind symbols appear in |
| 89 | + # libbehaviortree_cpp. |
| 90 | + # --------------------------------------------------------------------------- |
| 91 | + symbol-hygiene: |
| 92 | + name: symbol hygiene (nm scan) |
| 93 | + runs-on: ubuntu-22.04 |
| 94 | + steps: |
| 95 | + - uses: actions/checkout@v6 |
| 96 | + |
| 97 | + - uses: actions/setup-python@v6 |
| 98 | + with: |
| 99 | + python-version: "3.12" |
| 100 | + |
| 101 | + - name: Install nanobind (for CMake config) |
| 102 | + run: pip install "nanobind>=2.5,<3" |
| 103 | + |
| 104 | + - name: Configure + build (BTCPP_PYTHON=ON, no examples/tools/tests on core) |
| 105 | + run: | |
| 106 | + cmake -S . -B build \ |
| 107 | + -DBTCPP_PYTHON=ON \ |
| 108 | + -DBTCPP_BUILD_TOOLS=OFF \ |
| 109 | + -DBTCPP_EXAMPLES=OFF \ |
| 110 | + -DBUILD_TESTING=OFF \ |
| 111 | + -DBTCPP_GROOT_INTERFACE=OFF \ |
| 112 | + -DBTCPP_SQLITE_LOGGING=OFF \ |
| 113 | + -Dnanobind_DIR=$(python -c "import nanobind, pathlib; print(pathlib.Path(nanobind.__file__).parent / 'cmake')") |
| 114 | + cmake --build build --parallel |
| 115 | +
|
| 116 | + - name: ctest -R pybt_no_python_symbols_in_core |
| 117 | + run: ctest --test-dir build --output-on-failure -R pybt_no_python_symbols_in_core |
| 118 | + |
| 119 | + # --------------------------------------------------------------------------- |
| 120 | + # Hidden-visibility + LTO build. `import pybt` must still resolve cleanly here. |
| 121 | + # --------------------------------------------------------------------------- |
| 122 | + hidden-lto: |
| 123 | + name: hidden-visibility + LTO import |
| 124 | + runs-on: ubuntu-22.04 |
| 125 | + steps: |
| 126 | + - uses: actions/checkout@v6 |
| 127 | + |
| 128 | + - uses: actions/setup-python@v6 |
| 129 | + with: |
| 130 | + python-version: "3.12" |
| 131 | + |
| 132 | + - name: Install nanobind (for CMake config) |
| 133 | + run: pip install "nanobind>=2.5,<3" |
| 134 | + |
| 135 | + - name: Configure + build with -fvisibility=hidden -flto |
| 136 | + run: | |
| 137 | + cmake -S . -B build \ |
| 138 | + -DBTCPP_PYTHON=ON \ |
| 139 | + -DBTCPP_BUILD_TOOLS=OFF \ |
| 140 | + -DBTCPP_EXAMPLES=OFF \ |
| 141 | + -DBUILD_TESTING=OFF \ |
| 142 | + -DBTCPP_GROOT_INTERFACE=OFF \ |
| 143 | + -DBTCPP_SQLITE_LOGGING=OFF \ |
| 144 | + -DCMAKE_C_FLAGS="-fvisibility=hidden -flto" \ |
| 145 | + -DCMAKE_CXX_FLAGS="-fvisibility=hidden -flto" \ |
| 146 | + -Dnanobind_DIR=$(python -c "import nanobind, pathlib; print(pathlib.Path(nanobind.__file__).parent / 'cmake')") |
| 147 | + cmake --build build --parallel |
| 148 | +
|
| 149 | + - name: ctest -R pybt_import_under_hidden_lto |
| 150 | + run: ctest --test-dir build --output-on-failure -R pybt_import_under_hidden_lto |
0 commit comments