-
Notifications
You must be signed in to change notification settings - Fork 80
218 lines (198 loc) · 8.88 KB
/
unit-tests.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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
# Copyright (C) 2005 - 2025 Settlers Freaks <sf-team at siedler25.org>
#
# SPDX-License-Identifier: GPL-2.0-or-later
name: Unit tests
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-2019, generator: Visual Studio 16 2019, type: Debug, platform: Win32}
- { os: windows-2019, generator: Visual Studio 16 2019, type: Debug, platform: x64}
- { os: windows-2019, generator: Visual Studio 16 2019, type: Release, platform: Win32}
- { os: windows-2019, generator: Visual Studio 16 2019, type: Release, platform: x64}
- { 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@v4
with:
submodules: true
- name: Install boost
uses: MarkusJx/install-boost@v2.4.5
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 (compiler) default C++ 14 standard
# 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 (compiler) default C++ 14 standard
# Use system cmake
# Use system boost (min version)
- { compiler: gcc-9, os: ubuntu-20.04, type: Debug, cmake: 3.16.3, boost: 1.71.0 }
- { compiler: clang-10, os: ubuntu-20.04, type: Debug, cmake: 3.16.3, boost: 1.71.0, externalSanitizer: true }
#
# Default compiler for Ubuntu 20.04
# Use (compiler) default C++ 14 standard
# Use default cmake
# Use default boost
- { compiler: gcc-10, os: ubuntu-20.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 }
- { compiler: gcc-11, os: ubuntu-22.04, type: Debug, cmake: 3.22.1, boost: 1.74.0 }
- { compiler: gcc-11, os: ubuntu-22.04, type: RelWithDebInfo, cmake: 3.22.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 }
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@v4
if: "!matrix.coverage"
with:
submodules: true
- uses: actions/checkout@v4
if: matrix.coverage
with:
submodules: true
fetch-depth: 0 # Faster checkout
- name: Cache dependencies
uses: actions/cache@v4
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
echo "BOOST_ROOT=${BOOST_ROOT}" >> $GITHUB_ENV
else
compiler=${{matrix.compiler}}
compiler=${compiler/gcc-/g++-}
sudo apt update
sudo apt 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@v1
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
- run: tools/ci/collectCoverageData.sh && external/libutil/tools/ci/uploadCoverageData.sh
if: matrix.coverage && success()
- run: tools/ci/checkTestCoverage.sh
if: matrix.coverage && success()
- name: Upload coverage (Coveralls)
if: matrix.coverage && success()
uses: coverallsapp/github-action@master
with:
github-token: ${{secrets.GITHUB_TOKEN}}
path-to-lcov: srccov.info