-
Notifications
You must be signed in to change notification settings - Fork 13
231 lines (209 loc) · 9.26 KB
/
common-ci.yml
File metadata and controls
231 lines (209 loc) · 9.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
name: Common CI
on: [pull_request]
# Cancels any in-progress workflow runs for the same PR when a new push is made,
# allowing the runner to become available more quickly for the latest changes.
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
build:
name: ${{ matrix.name }} ${{ matrix.build_type }} C++/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-24.04-gcc-11, ubuntu-24.04-clang-16, macOS-14-xcode-15.4]
build_type: [Debug, Release]
python_version: [3]
include:
- name: ubuntu-24.04-gcc-11
os: ubuntu-24.04
compiler: gcc
version: "11"
- name: ubuntu-24.04-clang-16
os: ubuntu-24.04
compiler: clang
version: "16"
- 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: |
set -e
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
# GTDynamics C++ tests use CppUnitLite (not provided by default on the runner).
git clone https://github.com/borglab/CppUnitLite.git /tmp/CppUnitLite
cd /tmp/CppUnitLite
mkdir build && cd build
# CppUnitLite's CMakeLists uses an old minimum CMake version; newer CMake
# requires explicitly opting into older policy compatibility.
# Force a modern C++ standard for newer Boost headers (Homebrew Boost requires C++11+).
cmake -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -DCMAKE_CXX_STANDARD=17 -DCMAKE_CXX_STANDARD_REQUIRED=ON ..
sudo make -j$(nproc) install
cd ${{ github.workspace }}
sudo rm -rf /tmp/CppUnitLite
- name: Install System Dependencies (macOS)
if: runner.os == 'macOS'
run: |
set -e
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
# GTDynamics C++ tests use CppUnitLite (install it once per job).
git clone https://github.com/borglab/CppUnitLite.git /tmp/CppUnitLite
cd /tmp/CppUnitLite
mkdir build && cd build
# CppUnitLite's CMakeLists uses an old minimum CMake version; newer CMake
# requires explicitly opting into older policy compatibility.
# Force a modern C++ standard for newer Boost headers (Homebrew Boost requires C++11+).
cmake -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -DCMAKE_CXX_STANDARD=17 -DCMAKE_CXX_STANDARD_REQUIRED=ON ..
sudo make -j$(sysctl -n hw.physicalcpu) install
cd ${{ github.workspace }}
rm -rf /tmp/CppUnitLite
- 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: Test GTDynamics C++ (macOS)
# Mirror the python-test linker settings: GTSAM is installed to a local prefix.
if: runner.os == 'macOS'
shell: bash
run: |
set -e
export DYLD_LIBRARY_PATH="${{ env.GTSAM_INSTALL_DIR_MACOS }}/lib${DYLD_LIBRARY_PATH:+:$DYLD_LIBRARY_PATH}"
make -j$(sysctl -n hw.physicalcpu) check
working-directory: ./build
- name: Test GTDynamics C++ (Linux)
if: runner.os == 'Linux'
run: |
set -e
make -j$(nproc) check
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