-
Notifications
You must be signed in to change notification settings - Fork 115
189 lines (183 loc) · 7.18 KB
/
ubuntu.yml
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
name: 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,
cudaEnabled: false,
checkCodeFormat: true,
},
{
os: ubuntu-22.04,
cmakeBuildType: Release,
asanEnabled: false,
cudaEnabled: true,
checkCodeFormat: false,
},
{
os: ubuntu-22.04,
cmakeBuildType: Release,
asanEnabled: true,
cudaEnabled: false,
checkCodeFormat: false,
},
{
os: ubuntu-22.04,
cmakeBuildType: ClangTidy,
asanEnabled: false,
cudaEnabled: 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
if: matrix.config.checkCodeFormat
run: |
set +x -euo pipefail
sudo apt-get update && sudo apt-get install -y clang-format-14 black
./scripts/format/clang_format.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 \
libsuitesparse-dev \
libceres-dev \
libflann-dev \
libfreeimage-dev \
libmetis-dev \
libgoogle-glog-dev \
libgtest-dev \
libgmock-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: Upgrade CMake
run: |
CMAKE_VERSION=3.28.6
CMAKE_DIR=cmake-${CMAKE_VERSION}-linux-x86_64
wget https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/${CMAKE_DIR}.tar.gz
tar -xzf ${CMAKE_DIR}.tar.gz
sudo cp -r ${CMAKE_DIR}/* /usr/local/
rm -rf ${CMAKE_DIR}*
- 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 \
-DASAN_ENABLED=${{ matrix.config.asanEnabled }}
ninja -k 10000
- name: Run tests
if: ${{ matrix.config.cmakeBuildType != 'ClangTidy' }}
run: |
export DISPLAY=":99.0"
export QT_QPA_PLATFORM="offscreen"
Xvfb :99 &
sleep 3
cd build
ctest --output-on-failure -E .+colmap_.*
- 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)"''