File: build-ubuntu.yml

package info (click to toggle)
colmap 3.10-2.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 11,168 kB
  • sloc: cpp: 91,779; ansic: 17,774; python: 3,459; sh: 216; makefile: 154
file content (268 lines) | stat: -rw-r--r-- 9,463 bytes parent folder | download | duplicates (2)
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
name: COLMAP (Ubuntu)

on:
  push:
    branches:
      - main
  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' || '' }}
    runs-on: ${{ matrix.config.os }}
    strategy:
      matrix:
        config: [
          {
            os: ubuntu-22.04,
            cmakeBuildType: Release,
            asanEnabled: false,
            guiEnabled: true,
            cudaEnabled: false,
            e2eTests: true,
            checkCodeFormat: true,
          },
          {
            os: ubuntu-22.04,
            cmakeBuildType: Release,
            asanEnabled: false,
            guiEnabled: false,
            cudaEnabled: true,
            e2eTests: false,
            checkCodeFormat: false,
          },
          {
            os: ubuntu-22.04,
            cmakeBuildType: Release,
            asanEnabled: true,
            guiEnabled: false,
            cudaEnabled: false,
            e2eTests: false,
            checkCodeFormat: false,
          },
          {
            os: ubuntu-22.04,
            cmakeBuildType: ClangTidy,
            asanEnabled: false,
            guiEnabled: false,
            cudaEnabled: false,
            e2eTests: false,
            checkCodeFormat: false,
          },
          {
            os: ubuntu-20.04,
            cmakeBuildType: Release,
            asanEnabled: false,
            guiEnabled: true,
            cudaEnabled: false,
            e2eTests: false,
            checkCodeFormat: false,
          },
          {
            os: ubuntu-20.04,
            cmakeBuildType: Release,
            asanEnabled: false,
            guiEnabled: false,
            cudaEnabled: true,
            e2eTests: false,
            checkCodeFormat: 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

    steps:
      - uses: actions/checkout@v4
      - uses: actions/cache@v4
        id: cache-builds
        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: 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.8.2/ccache-4.8.2-linux-x86_64.tar.xz
          echo "0b33f39766fe9db67f40418aed6a5b3d7b2f4f7fab025a8213264b77a2d0e1b1  ccache-4.8.2-linux-x86_64.tar.xz" | sha256sum --check
          tar xfv ccache-4.8.2-linux-x86_64.tar.xz
          mkdir -p "$COMPILER_CACHE_DIR/bin"
          mv ./ccache-4.8.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: Check code format
        run: |
          if [ "${{ matrix.config.checkCodeFormat }}" != "true" ]; then
            exit 0
          fi
          set +x -euo pipefail
          sudo apt-get update && sudo apt-get install -y clang-format-14 black
          ./scripts/format/clang_format.sh
          ./scripts/format/black.sh
          git diff --name-only
          git diff --exit-code || (echo "Code formatting failed" && exit 1)

      - name: Setup Ubuntu
        run: |
          sudo apt-get update && sudo apt-get install -y \
            build-essential \
            cmake \
            ninja-build \
            libboost-program-options-dev \
            libboost-filesystem-dev \
            libboost-graph-dev \
            libboost-system-dev \
            libeigen3-dev \
            libceres-dev \
            libflann-dev \
            libfreeimage-dev \
            libmetis-dev \
            libgoogle-glog-dev \
            libgtest-dev \
            libsqlite3-dev \
            libglew-dev \
            qtbase5-dev \
            libqt5opengl5-dev \
            libcgal-dev \
            libcgal-qt5-dev \
            libgl1-mesa-dri \
            libunwind-dev \
            xvfb

          if [ "${{ matrix.config.cudaEnabled }}" == "true" ]; then
            if [ "${{ matrix.config.os }}" == "ubuntu-20.04" ]; then
              sudo apt-get install -y \
                nvidia-cuda-toolkit \
                nvidia-cuda-toolkit-gcc
              echo "CC=/usr/bin/cuda-gcc" >> $GITHUB_ENV
              echo "CXX=/usr/bin/cuda-g++" >> $GITHUB_ENV
            elif [ "${{ 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-15 libomp-15-dev
            echo "CC=/usr/bin/clang-15" >> $GITHUB_ENV
            echo "CXX=/usr/bin/clang++-15" >> $GITHUB_ENV
          fi

          if [ "${{ matrix.config.cmakeBuildType }}" == "ClangTidy" ]; then
            sudo apt-get install -y clang-15 clang-tidy-15 libomp-15-dev
            echo "CC=/usr/bin/clang-15" >> $GITHUB_ENV
            echo "CXX=/usr/bin/clang++-15" >> $GITHUB_ENV
          fi

      - name: Configure and build
        run: |
          set -x
          cmake --version
          mkdir build
          cd build
          cmake .. \
            -GNinja \
            -DCMAKE_BUILD_TYPE=${{ matrix.config.cmakeBuildType }} \
            -DCMAKE_INSTALL_PREFIX=./install \
            -DCMAKE_CUDA_ARCHITECTURES=50 \
            -DTESTS_ENABLED=ON \
            -DCUDA_ENABLED=${{ matrix.config.cudaEnabled }} \
            -DGUI_ENABLED=${{ matrix.config.guiEnabled }} \
            -DASAN_ENABLED=${{ matrix.config.asanEnabled }}
          ninja -k 10000

      - name: Install and build sample
        run: |
          if [ "${{ matrix.config.asanEnabled }}" == "true" ] ||
             [ "${{ matrix.config.cmakeBuildType }}" == "ClangTidy" ]; then
            exit 0
          fi

          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
        run: |
          if [ "${{ matrix.config.cmakeBuildType }}" == "ClangTidy" ]; then
            exit 0
          fi

          if [ "${{ matrix.config.cudaEnabled }}" == "true" ]; then
            ctestExclusions="(feature/colmap_feature_sift_test)|(mvs/colmap_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
        run: |
          if [ "${{ matrix.config.e2eTests }}" != "true" ]; then
            exit 0
          fi

          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 ./scripts/python/benchmark_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

      - 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)"