-
Notifications
You must be signed in to change notification settings - Fork 93
237 lines (215 loc) · 9.63 KB
/
unit-tests.yml
File metadata and controls
237 lines (215 loc) · 9.63 KB
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
# Copyright (C) 2005 - 2026 Settlers Freaks <sf-team at siedler25.org>
#
# SPDX-License-Identifier: GPL-2.0-or-later
name: Unit tests
permissions:
contents: write
on:
push:
branches:
- master
- main
- develop
- bugfix/**
- feature/**
- fix/**
- pr/**
pull_request:
concurrency:
group: ${{format('tests-{0}:{1}', github.repository, github.ref)}}
cancel-in-progress: true
env:
# Default versions from Jenkins Toolchain
CMAKE_VERSION: 3.26.0
BOOST_VERSION: 1.81.0
ADDITIONAL_CMAKE_FLAGS: -DRTTR_ENABLE_BENCHMARKS=ON
jobs:
Windows:
strategy:
matrix:
include:
- { os: windows-2022, generator: Visual Studio 17 2022, type: Debug, platform: Win32}
- { os: windows-2022, generator: Visual Studio 17 2022, type: Debug, platform: x64}
- { os: windows-2022, generator: Visual Studio 17 2022, type: Release, platform: Win32}
- { os: windows-2022, generator: Visual Studio 17 2022, type: Release, platform: x64}
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
submodules: true
- name: Install boost
uses: MarkusJx/install-boost@8ba8b2fac59ef3d91a838bb4aa53ceabd33d1aa3 # v2.5.1
id: install-boost
with:
boost_version: ${{env.BOOST_VERSION}}
platform_version: ${{matrix.os == 'windows-2019' && '2019' || '2022'}}
toolset: msvc
- name: 'Configure'
env:
BOOST_ROOT: ${{steps.install-boost.outputs.BOOST_ROOT}}
shell: cmd
run: |
set "INSTALL_DIR=%GITHUB_WORKSPACE%\installed"
mkdir build_dir
cd build_dir
rem Enable LTCG for release builds (speeds up linking as /GL compiled modules are used)
if ${{matrix.type}} == Release (set "cmakeFlags=-DCMAKE_EXE_LINKER_FLAGS=/LTCG -DCMAKE_SHARED_LINKER_FLAGS=/LTCG")
echo "Configuring ${{matrix.generator}} for ${{matrix.type}} on ${{matrix.platform}}"
cmake -G "${{matrix.generator}}" -A ${{matrix.platform}} ^
-DRTTR_ENABLE_WERROR=ON -DCMAKE_INSTALL_PREFIX=$INSTALL_DIR ^
-DRTTR_EXTERNAL_BUILD_TESTING=ON -DRTTR_ENABLE_BENCHMARKS=ON -DRTTR_INCLUDE_DEVTOOLS=ON ^
%cmakeFlags% ..
- name: 'Build'
run: cmake --build build_dir --config ${{matrix.type}} --parallel 4
- name: 'Test'
run: ctest --test-dir build_dir --output-on-failure -C ${{matrix.type}} --parallel 4
Linux:
strategy:
matrix:
include:
# MacOSX:
# Use system clang (15)
# Use system cmake (version gets ignored below)
# Use boost installed via brew
- { compiler: clang, os: macos-14, type: Debug }
# Linux:
# Oldest Compilers
# GCC 9 also known to show a few warnings that newer versions dont show
# Use system cmake
# Use boost 1.73 (min version)
- { compiler: gcc-9, os: ubuntu-22.04, type: Debug, cmake: 3.16.3, boost: 1.73.0 }
- { compiler: clang-12, os: ubuntu-22.04, type: Debug, cmake: 3.16.3, boost: 1.73.0, externalSanitizer: true }
#
# Default compiler for Ubuntu 20.04
# Use default cmake
# Use default boost
- { compiler: gcc-10, os: ubuntu-22.04, type: Debug, coverage: true }
#
# Default compilers for Ubuntu 22.04
# Use C++ 17 standard (default for gcc-11)
# Use system cmake
# Use system boost
# Also include a (semi-)optimized build to a) shake out issues there an b) run the replay tests
- { compiler: clang-14, os: ubuntu-22.04, type: Debug, cmake: 3.22.1, boost: 1.74.0, cxx: 17 }
# Similar but latest CMake 3.x
- { compiler: gcc-11, os: ubuntu-22.04, type: Debug, cmake: 3.22.1, boost: 1.74.0 }
# Use CMake 4.x
- { compiler: gcc-11, os: ubuntu-22.04, type: RelWithDebInfo, cmake: 4.1.1, boost: 1.74.0 }
#
# Latest Compilers
# Use default boost
# Use (compiler) default C++ 17 standard
# Use default cmake
- { compiler: gcc-14, os: ubuntu-24.04, type: Debug }
- { compiler: clang-18, os: ubuntu-24.04, type: Debug, externalSanitizer: true }
- { compiler: clang-21, os: ubuntu-latest, type: Debug, init_llvm: true}
runs-on: ${{matrix.os}}
steps:
- name: Setup env and configure flags
run: |
echo "DEPS_DIR=${{runner.temp}}/.cache" >> $GITHUB_ENV
echo "BUILD_TYPE=${{matrix.type}}" >> $GITHUB_ENV
[[ -z "${{matrix.cmake}}" ]] || echo "CMAKE_VERSION=${{matrix.cmake}}" >> $GITHUB_ENV
[[ -z "${{matrix.boost}}" ]] || echo "BOOST_VERSION=${{matrix.boost}}" >> $GITHUB_ENV
[[ -z "${{matrix.cxx}}" ]] || ADDITIONAL_CMAKE_FLAGS+=" -DCMAKE_CXX_STANDARD=${{matrix.cxx}}"
[[ "${{matrix.coverage}}" != "true" ]] || ADDITIONAL_CMAKE_FLAGS+=" -DRTTR_ENABLE_COVERAGE=ON"
[[ "${{matrix.externalSanitizer}}" != "true" ]] || ADDITIONAL_CMAKE_FLAGS+=" -DRTTR_EXTERNAL_BUILD_TESTING=ON -DRTTR_ENABLE_SANITIZERS=ON"
echo "ADDITIONAL_CMAKE_FLAGS=${ADDITIONAL_CMAKE_FLAGS}" >> $GITHUB_ENV
CC=${{matrix.compiler}}
if [[ "$CC" =~ clang ]]; then
CXX=${CC/clang/clang++}
else
CXX=${CC/gcc/g++}
fi
ver=7 # default
if [[ "$CC" =~ gcc- ]]; then
ver="${CC##*gcc-}"
fi
GCOV=gcov-${ver}
echo "CC=$CC" >> $GITHUB_ENV
echo "CXX=$CXX" >> $GITHUB_ENV
echo "GCOV=$GCOV" >> $GITHUB_ENV
# Coverage collection requires access to history to find merge-base
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
if: "!matrix.coverage"
with:
submodules: true
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
if: matrix.coverage
with:
submodules: true
fetch-depth: 0 # Full history
- name: Cache dependencies
uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4
with:
path: ${{env.DEPS_DIR}}
key: ${{matrix.os}}-${{env.BOOST_VERSION}}
- name: Install system packages
run: |
if [[ "${{runner.os}}" =~ macOS ]]; then
echo "HOMEBREW_PREFIX=$HOMEBREW_PREFIX"
echo "HOMEBREW_CELLAR=$HOMEBREW_CELLAR"
brew install cmake boost sdl2 sdl2_mixer gettext miniupnpc
echo "Available Boost installs: $(ls "$HOMEBREW_CELLAR/boost/")"
# Use the latest (last folder)
BOOST_ROOT=$(find "$HOMEBREW_CELLAR/boost/"* -maxdepth 0 -type d | tail -n1)
echo "Choosen Boost: $BOOST_ROOT"
[[ -n "$BOOST_ROOT" ]] || exit 1
ls "$BOOST_ROOT/include"
echo "CMake config files:"
find "$BOOST_ROOT"/lib/cmake -type f
echo "BOOST_ROOT=${BOOST_ROOT}" >> $GITHUB_ENV
else
compiler=${{matrix.compiler}}
compiler=${compiler/gcc-/g++-}
if [[ "${{matrix.init_llvm}}" == "true" ]]; then
clang_version=${compiler#clang-*}
wget -qO- "https://apt.llvm.org/llvm.sh" | sudo bash -s -- "${clang_version}"
fi
sudo apt-get -o Acquire::Retries=5 update
sudo apt-get -o Acquire::Retries=5 -y -q --no-install-suggests --no-install-recommends install gettext libsdl2-dev libsdl2-mixer-dev libcurl4-openssl-dev libbz2-dev libminiupnpc-dev liblua5.2-dev $compiler
fi
- name: Setup CCache
uses: hendrikmuhs/ccache-action@33522472633dbd32578e909b315f5ee43ba878ce # v1.2.22
with:
key: ${{matrix.os}}-${{matrix.compiler}}-${{matrix.type}}-${{matrix.boost}}
max-size: 200M
- name: Compile CMake (Linux)
if: "!startsWith(runner.os, 'macOS')"
run: |
CMAKE_DIR="${DEPS_DIR}/cmake"
external/libutil/tools/ci/installCMake.sh "${CMAKE_VERSION}" "${CMAKE_DIR}"
echo "${CMAKE_DIR}/bin" >> $GITHUB_PATH
- name: Compile Boost (Linux)
if: "!startsWith(runner.os, 'macOS')"
run: |
BOOST_ROOT="${DEPS_DIR}/boost${BOOST_VERSION}"
echo "BOOST_ROOT=${BOOST_ROOT}" >> $GITHUB_ENV
echo "ADDITIONAL_CMAKE_FLAGS=${ADDITIONAL_CMAKE_FLAGS} -DBoost_NO_SYSTEM_PATHS=ON -DBoost_NO_BOOST_CMAKE=ON" >> $GITHUB_ENV
external/libutil/tools/ci/installBoost.sh "${BOOST_VERSION}" "${BOOST_ROOT}" "filesystem,system,program_options,thread,test,locale,iostreams,regex" shared
cat /tmp/boost.log || true
ls -la ${BOOST_ROOT}/lib/ || true
- name: Build
run: tools/ci/build.sh
- name: Test
run: tools/ci/test.sh
- run: tools/ci/collectCoverageData.sh
if: matrix.coverage && success()
- run: tools/ci/checkTestCoverage.sh
if: matrix.coverage && success()
- name: Upload coverage (Codecov)
if: matrix.coverage && success()
uses: codecov/codecov-action@57e3a136b779b570ffcdbf80b3bdc90e7fab3de2 # v6.0.0
with:
fail_ci_if_error: true
disable_search: true
files: coverage.info
name: Github Actions
token: ${{secrets.CODECOV_TOKEN}}
verbose: true
- name: Upload coverage (Coveralls)
if: matrix.coverage && success()
uses: coverallsapp/github-action@5cbfd81b66ca5d10c19b062c04de0199c215fb6e # v2.3.7
with:
github-token: ${{secrets.GITHUB_TOKEN}}
path-to-lcov: srccov.info