| 1 |
name: COLMAP (Ubuntu) |
| 2 |
|
| 3 |
concurrency: |
| 4 |
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} |
| 5 |
cancel-in-progress: ${{ github.event_name == 'pull_request' }} |
| 6 |
|
| 7 |
on: |
| 8 |
push: |
| 9 |
branches: |
| 10 |
- main |
| 11 |
- release/* |
| 12 |
pull_request: |
| 13 |
types: [ assigned, opened, synchronize, reopened ] |
| 14 |
release: |
| 15 |
types: [ published, edited ] |
| 16 |
|
| 17 |
jobs: |
| 18 |
build: |
| 19 |
name: ${{ matrix.config.os }} ${{ matrix.config.cmakeBuildType }} ${{ matrix.config.cudaEnabled && 'CUDA' || '' }} ${{ matrix.config.asanEnabled && 'ASan' || '' }} ${{ matrix.config.coverageEnabled && 'Coverage' || '' }} |
| 20 |
runs-on: ${{ matrix.config.os }} |
| 21 |
strategy: |
| 22 |
matrix: |
| 23 |
config: [ |
| 24 |
{ |
| 25 |
os: ubuntu-26.04, |
| 26 |
qtVersion: 6, |
| 27 |
cmakeBuildType: Release, |
| 28 |
asanEnabled: false, |
| 29 |
guiEnabled: true, |
| 30 |
cudaEnabled: false, |
| 31 |
casparEnabled: false, |
| 32 |
e2eTests: false, |
| 33 |
checkCodeFormat: false, |
| 34 |
coverageEnabled: false, |
| 35 |
ccacheMaxSize: 100M, |
| 36 |
}, |
| 37 |
{ |
| 38 |
os: ubuntu-24.04, |
| 39 |
qtVersion: 6, |
| 40 |
cmakeBuildType: Release, |
| 41 |
asanEnabled: false, |
| 42 |
guiEnabled: true, |
| 43 |
cudaEnabled: false, |
| 44 |
casparEnabled: false, |
| 45 |
e2eTests: false, |
| 46 |
checkCodeFormat: true, |
| 47 |
coverageEnabled: true, |
| 48 |
ccacheMaxSize: 120M, |
| 49 |
}, |
| 50 |
{ |
| 51 |
os: ubuntu-22.04, |
| 52 |
qtVersion: 6, |
| 53 |
cmakeBuildType: Release, |
| 54 |
asanEnabled: false, |
| 55 |
guiEnabled: true, |
| 56 |
cudaEnabled: false, |
| 57 |
casparEnabled: false, |
| 58 |
e2eTests: true, |
| 59 |
checkCodeFormat: true, |
| 60 |
coverageEnabled: false, |
| 61 |
ccacheMaxSize: 100M, |
| 62 |
}, |
| 63 |
{ |
| 64 |
os: ubuntu-22.04, |
| 65 |
qtVersion: 5, |
| 66 |
cmakeBuildType: Release, |
| 67 |
asanEnabled: false, |
| 68 |
guiEnabled: false, |
| 69 |
cudaEnabled: true, |
| 70 |
casparEnabled: true, |
| 71 |
e2eTests: false, |
| 72 |
checkCodeFormat: false, |
| 73 |
coverageEnabled: false, |
| 74 |
ccacheMaxSize: 120M, |
| 75 |
}, |
| 76 |
{ |
| 77 |
os: ubuntu-24.04, |
| 78 |
qtVersion: 6, |
| 79 |
cmakeBuildType: Release, |
| 80 |
asanEnabled: true, |
| 81 |
guiEnabled: false, |
| 82 |
cudaEnabled: false, |
| 83 |
casparEnabled: false, |
| 84 |
e2eTests: false, |
| 85 |
checkCodeFormat: false, |
| 86 |
coverageEnabled: false, |
| 87 |
ccacheMaxSize: 120M, |
| 88 |
}, |
| 89 |
{ |
| 90 |
os: ubuntu-24.04, |
| 91 |
qtVersion: 6, |
| 92 |
cmakeBuildType: ClangTidy, |
| 93 |
asanEnabled: false, |
| 94 |
guiEnabled: false, |
| 95 |
cudaEnabled: false, |
| 96 |
casparEnabled: false, |
| 97 |
e2eTests: false, |
| 98 |
checkCodeFormat: false, |
| 99 |
coverageEnabled: false, |
| 100 |
ccacheMaxSize: 150M, |
| 101 |
}, |
| 102 |
] |
| 103 |
|
| 104 |
env: |
| 105 |
COMPILER_CACHE_DIR: ${{ github.workspace }}/compiler-cache |
| 106 |
CCACHE_DIR: ${{ github.workspace }}/compiler-cache/ccache |
| 107 |
CCACHE_BASEDIR: ${{ github.workspace }} |
| 108 |
CCACHE_NOHASHDIR: "true" |
| 109 |
CCACHE_COMPILERCHECK: content |
| 110 |
CCACHE_MAXSIZE: ${{ matrix.config.ccacheMaxSize }} |
| 111 |
CTCACHE_DIR: ${{ github.workspace }}/compiler-cache/ctcache |
| 112 |
GLOG_v: 2 |
| 113 |
GLOG_logtostderr: 1 |
| 114 |
|
| 115 |
steps: |
| 116 |
- uses: actions/checkout@v7 |
| 117 |
|
| 118 |
- name: Check code format |
| 119 |
if: matrix.config.checkCodeFormat |
| 120 |
run: | |
| 121 |
set +x -euo pipefail |
| 122 |
python -m pip install ruff==0.15.20 clang-format==22.1.5 |
| 123 |
./scripts/format/c++.sh --all |
| 124 |
./scripts/format/python.sh --all |
| 125 |
git diff --name-only |
| 126 |
git diff --exit-code || (echo "Code formatting failed" && exit 1) |
| 127 |
|
| 128 |
- name: Restore compiler cache |
| 129 |
uses: ./.github/actions/compiler-cache |
| 130 |
id: cache-compiler |
| 131 |
with: |
| 132 |
mode: restore |
| 133 |
path: ${{ env.COMPILER_CACHE_DIR }} |
| 134 |
key-suffix: ${{ matrix.config.os }}-${{ matrix.config.cmakeBuildType }}-qt_${{ matrix.config.qtVersion }}-gui_${{ matrix.config.guiEnabled }}-cuda_${{ matrix.config.cudaEnabled }}-asan_${{ matrix.config.asanEnabled }}-coverage_${{ matrix.config.coverageEnabled }}-caspar_${{ matrix.config.casparEnabled }} |
| 135 |
|
| 136 |
- name: Install compiler cache |
| 137 |
run: | |
| 138 |
mkdir -p "$CCACHE_DIR" "$CTCACHE_DIR" |
| 139 |
echo "$COMPILER_CACHE_DIR/bin" >> $GITHUB_PATH |
| 140 |
|
| 141 |
if [ ! -f "$COMPILER_CACHE_DIR/bin/ccache" ]; then |
| 142 |
set -x |
| 143 |
wget https://github.com/ccache/ccache/releases/download/v4.13.6/ccache-4.13.6-linux-x86_64-glibc.tar.xz |
| 144 |
echo "508b2a1217dc6e04a23e967c7b95a0fb45d8a7e16fde9e180919698f2e2be060 ccache-4.13.6-linux-x86_64-glibc.tar.xz" | sha256sum --check |
| 145 |
tar xfv ccache-4.13.6-linux-x86_64-glibc.tar.xz |
| 146 |
mkdir -p "$COMPILER_CACHE_DIR/bin" |
| 147 |
mv ./ccache-4.13.6-linux-x86_64-glibc/ccache "$COMPILER_CACHE_DIR/bin" |
| 148 |
ctcache_commit_id="66c3614175fc650591488519333c411b2eac15a3" |
| 149 |
wget https://github.com/matus-chochlik/ctcache/archive/${ctcache_commit_id}.zip |
| 150 |
echo "108b087f156a9fe7da0c796de1ef73f5855d2a33a27983769ea39061359a40fc ${ctcache_commit_id}.zip" | sha256sum --check |
| 151 |
unzip "${ctcache_commit_id}.zip" |
| 152 |
mv ctcache-${ctcache_commit_id}/clang-tidy* "$COMPILER_CACHE_DIR/bin" |
| 153 |
fi |
| 154 |
"$COMPILER_CACHE_DIR/bin/ccache" --zero-stats |
| 155 |
|
| 156 |
- name: Setup Ubuntu |
| 157 |
run: | |
| 158 |
if [ "${{ matrix.config.qtVersion }}" == "5" ]; then |
| 159 |
qt_packages="qtbase5-dev libqt5opengl5-dev libqt5svg5-dev libcgal-qt5-dev" |
| 160 |
elif [ "${{ matrix.config.qtVersion }}" == "6" ]; then |
| 161 |
qt_packages="qt6-base-dev libqt6opengl6-dev libqt6openglwidgets6" |
| 162 |
# The Svg dev package is named qt6-svg-dev on Ubuntu 24.04+ but |
| 163 |
# libqt6svg6-dev on Ubuntu 22.04. |
| 164 |
if [ "${{ matrix.config.os }}" == "ubuntu-22.04" ]; then |
| 165 |
qt_packages="$qt_packages libqt6svg6-dev" |
| 166 |
else |
| 167 |
qt_packages="$qt_packages qt6-svg-dev" |
| 168 |
fi |
| 169 |
fi |
| 170 |
|
| 171 |
# Ubuntu's apt Boost (1.74 on 22.04, 1.83 on 24.04) predates |
| 172 |
# boost::unordered_node_map (Boost >= 1.84), so COLMAP auto-selects the |
| 173 |
# STD hash map backend here. The BOOST backend is exercised on the |
| 174 |
# macOS (brew) and Windows (vcpkg) jobs. See COLMAP_HASH_MAP_BACKEND. |
| 175 |
sudo apt-get update && sudo apt-get install -y \ |
| 176 |
build-essential \ |
| 177 |
cmake \ |
| 178 |
ninja-build \ |
| 179 |
libboost-program-options-dev \ |
| 180 |
libboost-graph-dev \ |
| 181 |
libboost-system-dev \ |
| 182 |
libeigen3-dev \ |
| 183 |
libceres-dev \ |
| 184 |
libopenimageio-dev \ |
| 185 |
openimageio-tools \ |
| 186 |
libsuitesparse-dev \ |
| 187 |
libmetis-dev \ |
| 188 |
libgoogle-glog-dev \ |
| 189 |
libgtest-dev \ |
| 190 |
libgmock-dev \ |
| 191 |
libsqlite3-dev \ |
| 192 |
libglew-dev \ |
| 193 |
$qt_packages \ |
| 194 |
libcgal-dev \ |
| 195 |
libgl1-mesa-dri \ |
| 196 |
libunwind-dev \ |
| 197 |
libcurl4-openssl-dev \ |
| 198 |
libmkl-full-dev \ |
| 199 |
xvfb |
| 200 |
|
| 201 |
# Fix issue in Ubuntu's openimageio CMake config. |
| 202 |
# We don't depend on any of openimageio's OpenCV functionality, |
| 203 |
# but it still requires the OpenCV include directory to exist. |
| 204 |
sudo mkdir -p /usr/include/opencv4 |
| 205 |
|
| 206 |
if [ "${{ matrix.config.cudaEnabled }}" == "true" ]; then |
| 207 |
if [ "${{ matrix.config.os }}" == "ubuntu-22.04" ]; then |
| 208 |
sudo apt-get install -y \ |
| 209 |
nvidia-cuda-toolkit \ |
| 210 |
nvidia-cuda-toolkit-gcc \ |
| 211 |
gcc-10 g++-10 |
| 212 |
echo "CC=/usr/bin/gcc-10" >> $GITHUB_ENV |
| 213 |
echo "CXX=/usr/bin/g++-10" >> $GITHUB_ENV |
| 214 |
echo "CUDAHOSTCXX=/usr/bin/g++-10" >> $GITHUB_ENV |
| 215 |
fi |
| 216 |
fi |
| 217 |
|
| 218 |
if [ "${{ matrix.config.asanEnabled }}" == "true" ]; then |
| 219 |
sudo apt-get install -y clang-18 libomp-18-dev |
| 220 |
echo "CC=/usr/bin/clang-18" >> $GITHUB_ENV |
| 221 |
echo "CXX=/usr/bin/clang++-18" >> $GITHUB_ENV |
| 222 |
fi |
| 223 |
|
| 224 |
if [ "${{ matrix.config.cmakeBuildType }}" == "ClangTidy" ]; then |
| 225 |
sudo apt-get install -y clang-18 clang-tidy-18 libomp-18-dev |
| 226 |
echo "CC=/usr/bin/clang-18" >> $GITHUB_ENV |
| 227 |
echo "CXX=/usr/bin/clang++-18" >> $GITHUB_ENV |
| 228 |
fi |
| 229 |
|
| 230 |
if [ "${{ matrix.config.coverageEnabled }}" == "true" ]; then |
| 231 |
sudo apt-get install -y gcovr |
| 232 |
fi |
| 233 |
|
| 234 |
- name: Configure and build |
| 235 |
run: | |
| 236 |
set -x |
| 237 |
cmake --version |
| 238 |
mkdir -p build |
| 239 |
cd build |
| 240 |
cmake .. \ |
| 241 |
-GNinja \ |
| 242 |
-DCMAKE_BUILD_TYPE=${{ matrix.config.cmakeBuildType }} \ |
| 243 |
-DCMAKE_INSTALL_PREFIX=./install \ |
| 244 |
-DCMAKE_CUDA_ARCHITECTURES=75 \ |
| 245 |
-DTESTS_ENABLED=ON \ |
| 246 |
-DWERROR_ENABLED=ON \ |
| 247 |
-DCUDA_ENABLED=${{ matrix.config.cudaEnabled }} \ |
| 248 |
-DCASPAR_ENABLED=${{ matrix.config.casparEnabled }} \ |
| 249 |
-DGUI_ENABLED=${{ matrix.config.guiEnabled }} \ |
| 250 |
-DASAN_ENABLED=${{ matrix.config.asanEnabled }} \ |
| 251 |
-DCOVERAGE_ENABLED=${{ matrix.config.coverageEnabled }} \ |
| 252 |
-DBLA_VENDOR=Intel10_64lp |
| 253 |
ninja -k 10000 |
| 254 |
|
| 255 |
- name: Install and build sample |
| 256 |
if: ${{ matrix.config.cmakeBuildType != 'ClangTidy' && !matrix.config.asanEnabled && !matrix.config.coverageEnabled }} |
| 257 |
run: | |
| 258 |
set -x |
| 259 |
cd build |
| 260 |
ninja install |
| 261 |
cd ../doc/sample-project |
| 262 |
mkdir build |
| 263 |
cd build |
| 264 |
export colmap_DIR=${{ github.workspace }}/build/install/share/colmap |
| 265 |
cmake .. \ |
| 266 |
-GNinja \ |
| 267 |
-DCMAKE_CUDA_ARCHITECTURES=75 |
| 268 |
ninja |
| 269 |
./hello_world --message "world" |
| 270 |
|
| 271 |
- name: Run tests |
| 272 |
if: ${{ matrix.config.cmakeBuildType != 'ClangTidy' }} |
| 273 |
run: | |
| 274 |
if [ "${{ matrix.config.cudaEnabled }}" == "true" ]; then |
| 275 |
ctestExclusions="(feature/sift_test)|(mvs/gpu_mat_test)" |
| 276 |
fi |
| 277 |
if [ "${{ matrix.config.casparEnabled }}" == "true" ]; then |
| 278 |
ctestExclusions="${ctestExclusions}|(estimators/bundle_adjustment_caspar_test)" |
| 279 |
fi |
| 280 |
|
| 281 |
export DISPLAY=":99.0" |
| 282 |
export QT_QPA_PLATFORM="offscreen" |
| 283 |
Xvfb :99 & |
| 284 |
sleep 3 |
| 285 |
cd build |
| 286 |
ctest -E "$ctestExclusions" --output-on-failure |
| 287 |
|
| 288 |
- name: Run E2E tests |
| 289 |
if: matrix.config.e2eTests |
| 290 |
run: | |
| 291 |
export DISPLAY=":99.0" |
| 292 |
export QT_QPA_PLATFORM="offscreen" |
| 293 |
Xvfb :99 & |
| 294 |
sleep 3 |
| 295 |
sudo apt install 7zip |
| 296 |
mkdir eth3d_benchmark |
| 297 |
# Error thresholds in degrees and meters, |
| 298 |
# as the ETH3D groundtruth has metric scale. |
| 299 |
GLOG_v=1 python ./python/ci/test_regression_eth3d.py \ |
| 300 |
--workspace_path ./eth3d_benchmark \ |
| 301 |
--colmap_path ./build/src/colmap/exe/colmap \ |
| 302 |
--dataset_names boulders door \ |
| 303 |
--max_rotation_error 1.0 \ |
| 304 |
--max_proj_center_error 0.05 \ |
| 305 |
--use_cpu |
| 306 |
|
| 307 |
- name: Generate coverage report |
| 308 |
if: matrix.config.coverageEnabled |
| 309 |
run: | |
| 310 |
set -x |
| 311 |
cd build |
| 312 |
../scripts/shell/generate_coverage_report.sh |
| 313 |
|
| 314 |
- name: Upload coverage HTML report |
| 315 |
uses: actions/upload-artifact@v7 |
| 316 |
if: matrix.config.coverageEnabled |
| 317 |
with: |
| 318 |
name: code-coverage |
| 319 |
path: build/coverage-html |
| 320 |
|
| 321 |
- name: Generate Github code coverage report |
| 322 |
if: matrix.config.coverageEnabled |
| 323 |
uses: irongut/[email protected] |
| 324 |
with: |
| 325 |
filename: build/coverage-cobertura.xml |
| 326 |
badge: true |
| 327 |
fail_below_min: false |
| 328 |
format: markdown |
| 329 |
hide_branch_rate: false |
| 330 |
hide_complexity: true |
| 331 |
indicators: true |
| 332 |
output: both |
| 333 |
thresholds: '75 90' |
| 334 |
|
| 335 |
# TODO: Add code coverage comment to PR. Currently, this action reports |
| 336 |
# coverage for the entire repository, not just the changed files in the PR. |
| 337 |
# We could manually filter the coverage report to only include the changed |
| 338 |
# files in the PR, but this is non-trivial and may not be worth the effort. |
| 339 |
# - name: Add Github PR code coverage comment |
| 340 |
# uses: marocchino/sticky-pull-request-comment@v2 |
| 341 |
# if: ${{ matrix.config.coverageEnabled && github.event_name == 'pull_request' }} |
| 342 |
# with: |
| 343 |
# recreate: true |
| 344 |
# path: code-coverage-results.md |
| 345 |
|
| 346 |
- name: Cleanup compiler cache |
| 347 |
run: | |
| 348 |
set -x |
| 349 |
ccache --cleanup |
| 350 |
ccache --show-stats --verbose |
| 351 |
|
| 352 |
echo "Size of ctcache before: $(du -sh $CTCACHE_DIR)" |
| 353 |
echo "Number of ctcache files before: $(find $CTCACHE_DIR | wc -l)" |
| 354 |
# Delete cache older than 10 days. |
| 355 |
find "$CTCACHE_DIR"/*/ -mtime +10 -print0 | xargs -0 rm -rf |
| 356 |
echo "Size of ctcache after: $(du -sh $CTCACHE_DIR)" |
| 357 |
echo "Number of ctcache files after: $(find $CTCACHE_DIR | wc -l)" |
| 358 |
|
| 359 |
- name: Save compiler cache |
| 360 |
uses: ./.github/actions/compiler-cache |
| 361 |
with: |
| 362 |
mode: save |
| 363 |
key: ${{ steps.cache-compiler.outputs.key }} |
| 364 |
path: ${{ env.COMPILER_CACHE_DIR }} |
| 365 |
cache-hit: ${{ steps.cache-compiler.outputs.cache-hit }} |