Update CI #460
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Python CI | |
| on: [pull_request] | |
| jobs: | |
| build: | |
| name: ${{ matrix.name }} ${{ matrix.build_type }} Python ${{ matrix.python_version }} | |
| runs-on: ${{ matrix.os }} | |
| env: | |
| CTEST_OUTPUT_ON_FAILURE: ON | |
| CTEST_PARALLEL_LEVEL: 2 | |
| CMAKE_BUILD_TYPE: ${{ matrix.build_type }} | |
| PYTHON_VERSION: ${{ matrix.python_version }} | |
| GTSAM_INSTALL_DIR_MACOS: ${{ github.workspace }}/gtsam_install_prefix | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| name: [ubuntu-22.04-gcc-9, ubuntu-22.04-clang-12, macOS-14-xcode-15.4] | |
| build_type: [Debug, Release] | |
| python_version: [3] | |
| include: | |
| - name: ubuntu-22.04-gcc-9 | |
| os: ubuntu-22.04 | |
| compiler: gcc | |
| version: "9" | |
| - name: ubuntu-22.04-clang-12 | |
| os: ubuntu-22.04 | |
| compiler: clang | |
| version: "12" | |
| - name: macOS-14-xcode-15.4 | |
| os: macOS-14 | |
| compiler: xcode | |
| version: "15.4" | |
| steps: | |
| - name: Checkout GTDynamics (Your Project) | |
| uses: actions/checkout@v4 | |
| - name: Install System Dependencies (Linux) | |
| if: runner.os == 'Linux' | |
| run: | | |
| sudo apt-get -y update | |
| if [ "${{ matrix.compiler }}" = "gcc" ]; then | |
| sudo apt-get install -y g++-${{ matrix.version }} g++-${{ matrix.version }}-multilib | |
| echo "CC=gcc-${{ matrix.version }}" >> $GITHUB_ENV | |
| echo "CXX=g++-${{ matrix.version }}" >> $GITHUB_ENV | |
| else | |
| sudo apt-get install -y clang-${{ matrix.version }} g++-multilib | |
| echo "CC=clang" >> $GITHUB_ENV | |
| echo "CXX=clang++" >> $GITHUB_ENV | |
| fi | |
| sudo sh -c 'echo "deb http://packages.osrfoundation.org/gazebo/ubuntu-stable `lsb_release -cs` main" > /etc/apt/sources.list.d/gazebo-stable.list' | |
| sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys D2486D2DD83DB69272AFE98867170598AF249743 | |
| sudo apt-get -y update | |
| sudo apt-get -y install libtbb-dev libboost-all-dev libsdformat15-dev | |
| - name: Install System Dependencies (macOS) | |
| if: runner.os == 'macOS' | |
| run: | | |
| if [ "${{ matrix.compiler }}" = "gcc" ]; then | |
| brew install gcc@${{ matrix.version }} | |
| echo "CC=gcc-${{ matrix.version }}" >> $GITHUB_ENV | |
| echo "CXX=g++-${{ matrix.version }}" >> $GITHUB_ENV | |
| else | |
| sudo xcode-select -switch /Applications/Xcode_${{ matrix.version }}.app | |
| echo "CC=clang" >> $GITHUB_ENV | |
| echo "CXX=clang++" >> $GITHUB_ENV | |
| fi | |
| brew install boost | |
| brew tap osrf/simulation | |
| brew install sdformat15 | |
| - name: Python Dependencies (Linux) | |
| if: runner.os == 'Linux' | |
| run: | | |
| pip3 install -U "setuptools<70" wheel numpy pyparsing pyyaml "pybind11-stubgen>=2.5.1" | |
| - name: Python Dependencies and venv Setup (macOS) | |
| if: runner.os == 'macOS' | |
| shell: bash | |
| run: | | |
| set -e | |
| python${{ env.PYTHON_VERSION }} -m venv venv | |
| source venv/bin/activate | |
| echo "VENV_PYTHON_EXECUTABLE=${{ github.workspace }}/venv/bin/python" >> $GITHUB_ENV | |
| echo "${{ github.workspace }}/venv/bin" >> $GITHUB_PATH | |
| python -m pip install --upgrade pip | |
| python -m pip install --break-system-packages -U "setuptools<70" wheel numpy pyparsing pyyaml "pybind11-stubgen>=2.5.1" | |
| - name: GTSAM (Linux) | |
| if: runner.os == 'Linux' | |
| run: | | |
| set -e | |
| git clone https://github.com/borglab/gtsam.git /tmp/gtsam_source_linux | |
| cd /tmp/gtsam_source_linux | |
| mkdir build && cd $_ | |
| cmake -D GTSAM_BUILD_EXAMPLES_ALWAYS=OFF -DGTSAM_BUILD_PYTHON=ON .. | |
| sudo make -j$(nproc) install | |
| make python-install | |
| sudo ldconfig | |
| cd ${{ github.workspace }} | |
| sudo rm -rf /tmp/gtsam_source_linux | |
| - name: GTSAM (macOS) | |
| if: runner.os == 'macOS' | |
| shell: bash | |
| run: | | |
| set -e | |
| git clone https://github.com/borglab/gtsam.git /tmp/gtsam_source_macos | |
| cd /tmp/gtsam_source_macos | |
| mkdir build && cd $_ | |
| cmake -D GTSAM_BUILD_EXAMPLES_ALWAYS=OFF \ | |
| -D GTSAM_BUILD_PYTHON=ON \ | |
| -D GTSAM_WITH_TBB=OFF \ | |
| -D PYTHON_EXECUTABLE=${{ env.VENV_PYTHON_EXECUTABLE }} \ | |
| -D CMAKE_INSTALL_PREFIX=${{ env.GTSAM_INSTALL_DIR_MACOS }} \ | |
| .. | |
| make -j$(sysctl -n hw.physicalcpu) install | |
| make -j$(sysctl -n hw.physicalcpu) python-install | |
| cd ${{ github.workspace }} | |
| rm -rf /tmp/gtsam_source_macos | |
| - name: Build Directory for GTDynamics | |
| run: mkdir build | |
| - name: Configure GTDynamics (Linux) | |
| if: runner.os == 'Linux' | |
| run: | | |
| set -e | |
| cmake -DGTDYNAMICS_BUILD_PYTHON=ON .. | |
| working-directory: ./build | |
| - name: Configure GTDynamics (macOS) | |
| if: runner.os == 'macOS' | |
| shell: bash | |
| run: | | |
| set -e | |
| GTSAM_CONFIG_DIR_PATH="${{ env.GTSAM_INSTALL_DIR_MACOS }}/lib/cmake/GTSAM" | |
| cmake -DGTDYNAMICS_BUILD_PYTHON=ON \ | |
| -DPYTHON_EXECUTABLE=${{ env.VENV_PYTHON_EXECUTABLE }} \ | |
| -DGTSAM_DIR="${GTSAM_CONFIG_DIR_PATH}" \ | |
| -DCMAKE_PREFIX_PATH="${{ env.GTSAM_INSTALL_DIR_MACOS }};$(brew --prefix)" \ | |
| .. | |
| working-directory: ./build | |
| - name: Build GTDynamics | |
| run: make -j$(if [[ "$(uname)" == "Darwin" ]]; then sysctl -n hw.physicalcpu; else nproc; fi) | |
| working-directory: ./build | |
| - name: Install GTDynamics Python Wrappers | |
| shell: bash | |
| run: | | |
| set -e | |
| if [[ "$RUNNER_OS" == "macOS" ]]; then | |
| make -j$(sysctl -n hw.physicalcpu) python-install | |
| else | |
| sudo make -j$(nproc) python-install | |
| fi | |
| working-directory: ./build | |
| - name: Test GTDynamics Python | |
| # For macOS, set DYLD_LIBRARY_PATH so the dynamic linker can find the installed GTSAM libraries. | |
| # Also, ensure the venv is active for the context of running the tests. | |
| if: runner.os == 'macOS' | |
| shell: bash | |
| run: | | |
| set -e | |
| source ${{ github.workspace }}/venv/bin/activate # Ensure venv Python and its site-packages are primary | |
| export DYLD_LIBRARY_PATH="${{ env.GTSAM_INSTALL_DIR_MACOS }}/lib${DYLD_LIBRARY_PATH:+:$DYLD_LIBRARY_PATH}" | |
| echo "DYLD_LIBRARY_PATH is set to: $DYLD_LIBRARY_PATH" | |
| make -j$(sysctl -n hw.physicalcpu) python-test | |
| working-directory: ./build | |
| - name: Test GTDynamics Python (Linux) | |
| if: runner.os == 'Linux' | |
| run: | | |
| set -e | |
| # On Linux, sudo ldconfig during GTSAM install should handle library paths for system-wide installs. | |
| # If GTSAM was installed to a custom prefix not in ldconfig paths, LD_LIBRARY_PATH would be needed. | |
| make -j$(nproc) python-test | |
| working-directory: ./build |