name: COLMAP (Ubuntu) concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} cancel-in-progress: ${{ github.event_name == 'pull_request' }} on: push: branches: - main - release/* pull_request: types: [ assigned, opened, synchronize, reopened ] release: types: [ published, edited ] jobs: build: name: ${{ matrix.config.os }} ${{ matrix.config.cmakeBuildType }} ${{ matrix.config.cudaEnabled && 'CUDA' || '' }} ${{ matrix.config.asanEnabled && 'ASan' || '' }} ${{ matrix.config.coverageEnabled && 'Coverage' || '' }} runs-on: ${{ matrix.config.os }} strategy: matrix: config: [ { os: ubuntu-26.04, qtVersion: 6, cmakeBuildType: Release, asanEnabled: false, guiEnabled: true, cudaEnabled: false, casparEnabled: false, e2eTests: false, checkCodeFormat: false, coverageEnabled: false, ccacheMaxSize: 100M, }, { os: ubuntu-24.04, qtVersion: 6, cmakeBuildType: Release, asanEnabled: false, guiEnabled: true, cudaEnabled: false, casparEnabled: false, e2eTests: false, checkCodeFormat: true, coverageEnabled: true, ccacheMaxSize: 120M, }, { os: ubuntu-22.04, qtVersion: 6, cmakeBuildType: Release, asanEnabled: false, guiEnabled: true, cudaEnabled: false, casparEnabled: false, e2eTests: true, checkCodeFormat: true, coverageEnabled: false, ccacheMaxSize: 100M, }, { os: ubuntu-22.04, qtVersion: 5, cmakeBuildType: Release, asanEnabled: false, guiEnabled: false, cudaEnabled: true, casparEnabled: true, e2eTests: false, checkCodeFormat: false, coverageEnabled: false, ccacheMaxSize: 120M, }, { os: ubuntu-24.04, qtVersion: 6, cmakeBuildType: Release, asanEnabled: true, guiEnabled: false, cudaEnabled: false, casparEnabled: false, e2eTests: false, checkCodeFormat: false, coverageEnabled: false, ccacheMaxSize: 120M, }, { os: ubuntu-24.04, qtVersion: 6, cmakeBuildType: ClangTidy, asanEnabled: false, guiEnabled: false, cudaEnabled: false, casparEnabled: false, e2eTests: false, checkCodeFormat: false, coverageEnabled: false, ccacheMaxSize: 150M, }, ] env: COMPILER_CACHE_DIR: ${{ github.workspace }}/compiler-cache CCACHE_DIR: ${{ github.workspace }}/compiler-cache/ccache CCACHE_BASEDIR: ${{ github.workspace }} CCACHE_NOHASHDIR: "true" CCACHE_COMPILERCHECK: content CCACHE_MAXSIZE: ${{ matrix.config.ccacheMaxSize }} CTCACHE_DIR: ${{ github.workspace }}/compiler-cache/ctcache GLOG_v: 2 GLOG_logtostderr: 1 steps: - uses: actions/checkout@v7 - name: Check code format if: matrix.config.checkCodeFormat run: | set +x -euo pipefail python -m pip install ruff==0.15.20 clang-format==22.1.5 ./scripts/format/c++.sh --all ./scripts/format/python.sh --all git diff --name-only git diff --exit-code || (echo "Code formatting failed" && exit 1) - name: Restore compiler cache uses: ./.github/actions/compiler-cache id: cache-compiler with: mode: restore path: ${{ env.COMPILER_CACHE_DIR }} 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 }} - name: Install compiler cache run: | mkdir -p "$CCACHE_DIR" "$CTCACHE_DIR" echo "$COMPILER_CACHE_DIR/bin" >> $GITHUB_PATH if [ ! -f "$COMPILER_CACHE_DIR/bin/ccache" ]; then set -x wget https://github.com/ccache/ccache/releases/download/v4.13.6/ccache-4.13.6-linux-x86_64-glibc.tar.xz echo "508b2a1217dc6e04a23e967c7b95a0fb45d8a7e16fde9e180919698f2e2be060 ccache-4.13.6-linux-x86_64-glibc.tar.xz" | sha256sum --check tar xfv ccache-4.13.6-linux-x86_64-glibc.tar.xz mkdir -p "$COMPILER_CACHE_DIR/bin" mv ./ccache-4.13.6-linux-x86_64-glibc/ccache "$COMPILER_CACHE_DIR/bin" ctcache_commit_id="66c3614175fc650591488519333c411b2eac15a3" wget https://github.com/matus-chochlik/ctcache/archive/${ctcache_commit_id}.zip echo "108b087f156a9fe7da0c796de1ef73f5855d2a33a27983769ea39061359a40fc ${ctcache_commit_id}.zip" | sha256sum --check unzip "${ctcache_commit_id}.zip" mv ctcache-${ctcache_commit_id}/clang-tidy* "$COMPILER_CACHE_DIR/bin" fi "$COMPILER_CACHE_DIR/bin/ccache" --zero-stats - name: Setup Ubuntu run: | if [ "${{ matrix.config.qtVersion }}" == "5" ]; then qt_packages="qtbase5-dev libqt5opengl5-dev libqt5svg5-dev libcgal-qt5-dev" elif [ "${{ matrix.config.qtVersion }}" == "6" ]; then qt_packages="qt6-base-dev libqt6opengl6-dev libqt6openglwidgets6" # The Svg dev package is named qt6-svg-dev on Ubuntu 24.04+ but # libqt6svg6-dev on Ubuntu 22.04. if [ "${{ matrix.config.os }}" == "ubuntu-22.04" ]; then qt_packages="$qt_packages libqt6svg6-dev" else qt_packages="$qt_packages qt6-svg-dev" fi fi # Ubuntu's apt Boost (1.74 on 22.04, 1.83 on 24.04) predates # boost::unordered_node_map (Boost >= 1.84), so COLMAP auto-selects the # STD hash map backend here. The BOOST backend is exercised on the # macOS (brew) and Windows (vcpkg) jobs. See COLMAP_HASH_MAP_BACKEND. sudo apt-get update && sudo apt-get install -y \ build-essential \ cmake \ ninja-build \ libboost-program-options-dev \ libboost-graph-dev \ libboost-system-dev \ libeigen3-dev \ libceres-dev \ libopenimageio-dev \ openimageio-tools \ libsuitesparse-dev \ libmetis-dev \ libgoogle-glog-dev \ libgtest-dev \ libgmock-dev \ libsqlite3-dev \ libglew-dev \ $qt_packages \ libcgal-dev \ libgl1-mesa-dri \ libunwind-dev \ libcurl4-openssl-dev \ libmkl-full-dev \ xvfb # Fix issue in Ubuntu's openimageio CMake config. # We don't depend on any of openimageio's OpenCV functionality, # but it still requires the OpenCV include directory to exist. sudo mkdir -p /usr/include/opencv4 if [ "${{ matrix.config.cudaEnabled }}" == "true" ]; then if [ "${{ matrix.config.os }}" == "ubuntu-22.04" ]; then sudo apt-get install -y \ nvidia-cuda-toolkit \ nvidia-cuda-toolkit-gcc \ gcc-10 g++-10 echo "CC=/usr/bin/gcc-10" >> $GITHUB_ENV echo "CXX=/usr/bin/g++-10" >> $GITHUB_ENV echo "CUDAHOSTCXX=/usr/bin/g++-10" >> $GITHUB_ENV fi fi if [ "${{ matrix.config.asanEnabled }}" == "true" ]; then sudo apt-get install -y clang-18 libomp-18-dev echo "CC=/usr/bin/clang-18" >> $GITHUB_ENV echo "CXX=/usr/bin/clang++-18" >> $GITHUB_ENV fi if [ "${{ matrix.config.cmakeBuildType }}" == "ClangTidy" ]; then sudo apt-get install -y clang-18 clang-tidy-18 libomp-18-dev echo "CC=/usr/bin/clang-18" >> $GITHUB_ENV echo "CXX=/usr/bin/clang++-18" >> $GITHUB_ENV fi if [ "${{ matrix.config.coverageEnabled }}" == "true" ]; then sudo apt-get install -y gcovr fi - name: Configure and build run: | set -x cmake --version mkdir -p build cd build cmake .. \ -GNinja \ -DCMAKE_BUILD_TYPE=${{ matrix.config.cmakeBuildType }} \ -DCMAKE_INSTALL_PREFIX=./install \ -DCMAKE_CUDA_ARCHITECTURES=75 \ -DTESTS_ENABLED=ON \ -DWERROR_ENABLED=ON \ -DCUDA_ENABLED=${{ matrix.config.cudaEnabled }} \ -DCASPAR_ENABLED=${{ matrix.config.casparEnabled }} \ -DGUI_ENABLED=${{ matrix.config.guiEnabled }} \ -DASAN_ENABLED=${{ matrix.config.asanEnabled }} \ -DCOVERAGE_ENABLED=${{ matrix.config.coverageEnabled }} \ -DBLA_VENDOR=Intel10_64lp ninja -k 10000 - name: Install and build sample if: ${{ matrix.config.cmakeBuildType != 'ClangTidy' && !matrix.config.asanEnabled && !matrix.config.coverageEnabled }} run: | set -x cd build ninja install cd ../doc/sample-project mkdir build cd build export colmap_DIR=${{ github.workspace }}/build/install/share/colmap cmake .. \ -GNinja \ -DCMAKE_CUDA_ARCHITECTURES=75 ninja ./hello_world --message "world" - name: Run tests if: ${{ matrix.config.cmakeBuildType != 'ClangTidy' }} run: | if [ "${{ matrix.config.cudaEnabled }}" == "true" ]; then ctestExclusions="(feature/sift_test)|(mvs/gpu_mat_test)" fi if [ "${{ matrix.config.casparEnabled }}" == "true" ]; then ctestExclusions="${ctestExclusions}|(estimators/bundle_adjustment_caspar_test)" fi export DISPLAY=":99.0" export QT_QPA_PLATFORM="offscreen" Xvfb :99 & sleep 3 cd build ctest -E "$ctestExclusions" --output-on-failure - name: Run E2E tests if: matrix.config.e2eTests run: | export DISPLAY=":99.0" export QT_QPA_PLATFORM="offscreen" Xvfb :99 & sleep 3 sudo apt install 7zip mkdir eth3d_benchmark # Error thresholds in degrees and meters, # as the ETH3D groundtruth has metric scale. GLOG_v=1 python ./python/ci/test_regression_eth3d.py \ --workspace_path ./eth3d_benchmark \ --colmap_path ./build/src/colmap/exe/colmap \ --dataset_names boulders door \ --max_rotation_error 1.0 \ --max_proj_center_error 0.05 \ --use_cpu - name: Generate coverage report if: matrix.config.coverageEnabled run: | set -x cd build ../scripts/shell/generate_coverage_report.sh - name: Upload coverage HTML report uses: actions/upload-artifact@v7 if: matrix.config.coverageEnabled with: name: code-coverage path: build/coverage-html - name: Generate Github code coverage report if: matrix.config.coverageEnabled uses: irongut/CodeCoverageSummary@v1.3.0 with: filename: build/coverage-cobertura.xml badge: true fail_below_min: false format: markdown hide_branch_rate: false hide_complexity: true indicators: true output: both thresholds: '75 90' # TODO: Add code coverage comment to PR. Currently, this action reports # coverage for the entire repository, not just the changed files in the PR. # We could manually filter the coverage report to only include the changed # files in the PR, but this is non-trivial and may not be worth the effort. # - name: Add Github PR code coverage comment # uses: marocchino/sticky-pull-request-comment@v2 # if: ${{ matrix.config.coverageEnabled && github.event_name == 'pull_request' }} # with: # recreate: true # path: code-coverage-results.md - name: Cleanup compiler cache run: | set -x ccache --cleanup ccache --show-stats --verbose echo "Size of ctcache before: $(du -sh $CTCACHE_DIR)" echo "Number of ctcache files before: $(find $CTCACHE_DIR | wc -l)" # Delete cache older than 10 days. find "$CTCACHE_DIR"/*/ -mtime +10 -print0 | xargs -0 rm -rf echo "Size of ctcache after: $(du -sh $CTCACHE_DIR)" echo "Number of ctcache files after: $(find $CTCACHE_DIR | wc -l)" - name: Save compiler cache uses: ./.github/actions/compiler-cache with: mode: save key: ${{ steps.cache-compiler.outputs.key }} path: ${{ env.COMPILER_CACHE_DIR }} cache-hit: ${{ steps.cache-compiler.outputs.cache-hit }}