File: build-ubuntu.yml

package info (click to toggle)
colmap 4.0.2-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 15,408 kB
  • sloc: cpp: 142,920; ansic: 17,774; python: 3,613; sh: 428; makefile: 160
file content (330 lines) | stat: -rw-r--r-- 12,334 bytes parent folder | download | duplicates (4)
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
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
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-24.04,
            qtVersion: 6,
            cmakeBuildType: Release,
            asanEnabled: false,
            guiEnabled: true,
            cudaEnabled: false,
            e2eTests: false,
            checkCodeFormat: true,
            coverageEnabled: true,
          },
          {
            os: ubuntu-22.04,
            qtVersion: 6,
            cmakeBuildType: Release,
            asanEnabled: false,
            guiEnabled: true,
            cudaEnabled: false,
            e2eTests: true,
            checkCodeFormat: true,
            coverageEnabled: false,
          },
          {
            os: ubuntu-22.04,
            qtVersion: 5,
            cmakeBuildType: Release,
            asanEnabled: false,
            guiEnabled: false,
            cudaEnabled: true,
            e2eTests: false,
            checkCodeFormat: false,
            coverageEnabled: false,
          },
          {
            os: ubuntu-24.04,
            qtVersion: 6,
            cmakeBuildType: Release,
            asanEnabled: true,
            guiEnabled: false,
            cudaEnabled: false,
            e2eTests: false,
            checkCodeFormat: false,
            coverageEnabled: false,
          },
          {
            os: ubuntu-24.04,
            qtVersion: 6,
            cmakeBuildType: ClangTidy,
            asanEnabled: false,
            guiEnabled: false,
            cudaEnabled: false,
            e2eTests: false,
            checkCodeFormat: false,
            coverageEnabled: false,
          },
        ]

    env:
      COMPILER_CACHE_VERSION: 1
      COMPILER_CACHE_DIR: ${{ github.workspace }}/compiler-cache
      CCACHE_DIR: ${{ github.workspace }}/compiler-cache/ccache
      CCACHE_BASEDIR: ${{ github.workspace }}
      CTCACHE_DIR: ${{ github.workspace }}/compiler-cache/ctcache
      FETCHCONTENT_CACHE_VERSION: 1
      FETCHCONTENT_CACHE_DIR: ${{ github.workspace }}/build/_deps
      GLOG_v: 2
      GLOG_logtostderr: 1

    steps:
      - uses: actions/checkout@v4

      - name: Check code format
        if: matrix.config.checkCodeFormat
        run: |
          set +x -euo pipefail
          python -m pip install ruff==0.15.0 clang-format==21.1.8
          ./scripts/format/c++.sh
          ./scripts/format/python.sh
          git diff --name-only
          git diff --exit-code || (echo "Code formatting failed" && exit 1)

      - name: Restore Compiler cache
        uses: actions/cache@v4
        id: cache-compiler
        with:
          key: v${{ env.COMPILER_CACHE_VERSION }}-${{ matrix.config.os }}-${{ matrix.config.cmakeBuildType }}-${{ matrix.config.asanEnabled }}--${{ matrix.config.cudaEnabled }}-${{ github.run_id }}-${{ github.run_number }}
          restore-keys: v${{ env.COMPILER_CACHE_VERSION }}-${{ matrix.config.os }}-${{ matrix.config.cmakeBuildType }}-${{ matrix.config.asanEnabled }}--${{ matrix.config.cudaEnabled }}
          path: ${{ env.COMPILER_CACHE_DIR }}

      - name: Restore FetchContent cache
        uses: actions/cache@v4
        id: cache-fetchcontent
        with:
          key: fetchcontent-v${{ env.FETCHCONTENT_CACHE_VERSION }}-${{ matrix.config.os }}-cuda_${{ matrix.config.cudaEnabled }}-${{ hashFiles('cmake/FindDependencies.cmake', 'src/thirdparty/CMakeLists.txt') }}
          restore-keys: fetchcontent-v${{ env.FETCHCONTENT_CACHE_VERSION }}-${{ matrix.config.os }}-cuda_${{ matrix.config.cudaEnabled }}-
          path: ${{ env.FETCHCONTENT_CACHE_DIR }}

      - 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
            exit 0
          fi

          set -x
          wget https://github.com/ccache/ccache/releases/download/v4.12.2/ccache-4.12.2-linux-x86_64.tar.xz
          echo "630c34ec94d451b200f5b14a6a25580d6a45bc80c394b7e0b93e33556eee5d32  ccache-4.12.2-linux-x86_64.tar.xz" | sha256sum --check
          tar xfv ccache-4.12.2-linux-x86_64.tar.xz
          mkdir -p "$COMPILER_CACHE_DIR/bin"
          mv ./ccache-4.12.2-linux-x86_64/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"

      - name: Setup Ubuntu
        run: |
          if [ "${{ matrix.config.qtVersion }}" == "5" ]; then
            qt_packages="qtbase5-dev libqt5opengl5-dev libcgal-qt5-dev"
          elif [ "${{ matrix.config.qtVersion }}" == "6" ]; then
            qt_packages="qt6-base-dev libqt6opengl6-dev libqt6openglwidgets6"
          fi

          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=50 \
            -DTESTS_ENABLED=ON \
            -DWERROR_ENABLED=ON \
            -DCUDA_ENABLED=${{ matrix.config.cudaEnabled }} \
            -DGUI_ENABLED=${{ matrix.config.guiEnabled }} \
            -DASAN_ENABLED=${{ matrix.config.asanEnabled }} \
            -DCOVERAGE_ENABLED=${{ matrix.config.coverageEnabled }} \
            -DBLA_VENDOR=Intel10_64lp \
            -DFETCHCONTENT_FULLY_DISCONNECTED=${{ steps.cache-fetchcontent.outputs.cache-hit == 'true' && 'ON' || 'OFF' }}
          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=50
          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

          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@v4
        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 --show-stats --verbose
          ccache --evict-older-than 1d
          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)"