generated from abdes/asap
-
Notifications
You must be signed in to change notification settings - Fork 0
198 lines (179 loc) · 7.25 KB
/
ubuntu-builds.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
190
191
192
193
194
195
196
197
198
name: ubuntu-builds
on: workflow_call
env:
CMAKE_VERSION: 3.21.1
NINJA_VERSION: 1.11.1
CCACHE_VERSION: 4.8
CC: ''
CXX: ''
GCC_VERSION: ''
CLANG_VERSION: ''
jobs:
dev-build:
runs-on: ubuntu-22.04
strategy:
matrix:
compiler: [gcc-10, gcc-11, gcc-12, clang-14, clang-15, clang-16]
build_type: [Debug, Release]
include:
- build_type: Debug
examples: ON
tests: OFF # the template asap has no unit tests
- build_type: Release
examples: ON
tests: OFF # the template asap has no unit tests
steps:
- name: Split compiler name and version
id: split
env:
COMPILER: ${{ matrix.compiler }}
COMPILER_NAME: ''
COMPILER_VERSION: ''
run: |
COMPILER_NAME=${COMPILER%%-*}
COMPILER_VERSION=${COMPILER##*-}
echo "compiler_name=$COMPILER_NAME" >> $GITHUB_OUTPUT
if [ $COMPILER_NAME == 'gcc' ]
then
echo "gcc_version=$COMPILER_VERSION" >> $GITHUB_OUTPUT
elif [ $COMPILER_NAME == 'clang' ]
then
echo "clang_version=$COMPILER_VERSION" >> $GITHUB_OUTPUT
echo "gcc_version=11" >> $GITHUB_OUTPUT
fi
- name: Install basic OS packages
run: |
sudo apt-get -qq update
sudo apt-get -qq -y install \
software-properties-common \
apt-transport-https \
lsb-release \
ca-certificates \
curl \
gnupg \
build-essential
- name: Install GCC (always runs)
run: |
# sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
sudo apt-get -qq update && \
sudo apt-get -qq -y install gcc-${{steps.split.outputs.gcc_version}} g++-${{steps.split.outputs.gcc_version}}
- name: Install clang (only if building with clang)
if: ${{ steps.split.outputs.compiler_name == 'clang' }}
run: |
curl https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
sudo add-apt-repository -y 'deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-${{steps.split.outputs.clang_version}} main'
sudo apt-get -qq update
sudo apt-get -qq -y install \
libllvm${{steps.split.outputs.clang_version}} \
llvm-${{steps.split.outputs.clang_version}} \
llvm-${{steps.split.outputs.clang_version}}-dev \
llvm-${{steps.split.outputs.clang_version}}-runtime \
llvm-${{steps.split.outputs.clang_version}}-linker-tools \
lld-${{steps.split.outputs.clang_version}} \
clang-${{steps.split.outputs.clang_version}} \
clang-tools-${{steps.split.outputs.clang_version}} \
clang-format-${{steps.split.outputs.clang_version}} \
libclang1-${{steps.split.outputs.clang_version}} \
libc++-${{steps.split.outputs.clang_version}}-dev \
libc++abi-${{steps.split.outputs.clang_version}}-dev \
clang-format-${{steps.split.outputs.clang_version}} \
python3-clang-${{steps.split.outputs.clang_version}} \
clang-tools-${{steps.split.outputs.clang_version}} \
clang-tidy-${{steps.split.outputs.clang_version}}
- uses: actions/checkout@v3
with:
submodules: recursive
- name: Use GNU compilers (only if building with gcc/g++)
if: ${{ steps.split.outputs.compiler_name == 'gcc' }}
run: |
echo "CC=gcc" >> $GITHUB_ENV
echo "CXX=g++" >> $GITHUB_ENV
sudo update-alternatives --install \
/usr/bin/gcc gcc /usr/bin/gcc-${{steps.split.outputs.gcc_version}} 110 \
--slave /usr/bin/g++ g++ /usr/bin/g++-${{steps.split.outputs.gcc_version}} \
--slave /usr/bin/gcov gcov /usr/bin/gcov-${{steps.split.outputs.gcc_version}}
- name: Use clang (only if building with clang/clang++)
if: ${{ steps.split.outputs.compiler_name == 'clang' }}
run: |
echo "CC=clang" >> $GITHUB_ENV
echo "CXX=clang++" >> $GITHUB_ENV
for command in clang clang++ clang-apply-replacements clang-check \
clang-query clang-tidy clang-format scan-build scan-view llvm-cov \
llvm-profdata
do
sudo update-alternatives --install /usr/bin/$command $command \
/usr/bin/$command-${{steps.split.outputs.clang_version}} 110
done
clang --version
- name: Setup ninja
# Do not use ninja-build from the distro repos as it is always old
uses: abdes/gha-setup-ninja@master
with:
version: ${{ env.NINJA_VERSION }}
- name: Setup cmake
# Do not use cmake from the distro repos as it is not the version we
# want
uses: jwlawson/actions-setup-cmake@v1
with:
cmake-version: ${{ env.CMAKE_VERSION }}
- name: Install ccache from latest
run: |
CCACHE_DIST="ccache-${{ env.CCACHE_VERSION }}-linux-x86_64"
CCACHE_URL="https://github.com/ccache/ccache/releases/download/v$CCACHE_VERSION/$CCACHE_DIST.tar.xz"
echo "Installing ccache from: $CCACHE_URL"
curl -s -L -o ./ccache.tar.xz $CCACHE_URL
tar xf ./ccache.tar.xz
rm -f ./ccache.tar.xz
echo "$GITHUB_WORKSPACE/$CCACHE_DIST" >> $GITHUB_PATH
- name: Log environment properties
run: |
echo "Build Type : ${{matrix.build_type}}"
echo "Compiler Name : ${{steps.split.outputs.compiler_name}}"
if [ ${{steps.split.outputs.compiler_name}} == 'clang' ]
then
echo "Clang Version : ${{steps.split.outputs.clang_version}}"
fi
echo "GCC Version : ${{steps.split.outputs.gcc_version}}"
ninja --version
cmake --version
gcc --version
clang --version
ccache --version
- name: Setup ccache
uses: Chocobo1/setup-ccache-action@v1
with:
install_ccache: false
update_packager_index: false
prepend_symlinks_to_path: false
windows_compile_environment: msvc # this field is required
- name: Configure build
working-directory: ${{runner.workspace}}
run: |
cmake -B build -S $GITHUB_WORKSPACE \
-D CMAKE_BUILD_TYPE=${{matrix.build_type}} \
-G Ninja \
-D CMAKE_MAKE_PROGRAM=ninja \
-D USE_CCACHE=ON \
-D ASAP_BUILD_TESTS=${{matrix.tests}} \
-D ASAP_BUILD_EXAMPLES=${{matrix.examples}} \
-D ASAP_BUILD_DOCS=OFF \
-D CMAKE_INSTALL_PREFIX=install \
-D CMAKE_VERBOSE_MAKEFILE=ON
- name: Build main targets
working-directory: ${{runner.workspace}}
run: |
cmake --build build --target all
- name: Build test targets
working-directory: ${{runner.workspace}}
if: ${{ matrix.tests == true }}
run: |
cmake --build build --target build-all-tests
- name: Run tests with ctest
working-directory: ${{runner.workspace}}
# Hardcode 2 cores we know are there
run: |
ctest \
--test-dir build \
-C ${{matrix.build_type}} \
-j 2 \
--output-on-failure