-
Notifications
You must be signed in to change notification settings - Fork 77
209 lines (180 loc) · 7.64 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
# Copyright (C) 2005 - 2023 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:
Linux:
strategy:
matrix:
include:
# MacOSX:
# Use system clang (14)
# Use (compiler) default C++ 14 standard
# Use system cmake (version gets ignored below)
# Use boost installed via brew
- { compiler: clang, os: macos-12, 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
# GCC 12 needs boost 1.82 to compile correctly
# Use (compiler) default C++ 17 standard
# Use default cmake
- { compiler: gcc-12, os: ubuntu-22.04, type: Debug, boost: 1.82.0 }
# Use default boost
- { compiler: clang-16, os: ubuntu-20.04, type: Debug, externalSanitizer: true }
runs-on: ${{matrix.os}}
steps:
- run: echo "DEPS_DIR=${{runner.temp}}/.cache" >> $GITHUB_ENV
- name: Set BUILD_TYPE
run: echo "BUILD_TYPE=${{matrix.type}}" >> $GITHUB_ENV
- name: Set CMake version
if: matrix.cmake
run: echo "CMAKE_VERSION=${{matrix.cmake}}" >> $GITHUB_ENV
- name: Set Boost version
if: matrix.boost
run: echo "BOOST_VERSION=${{matrix.boost}}" >> $GITHUB_ENV
- name: Set C++ standard
if: matrix.cxx
run: echo "ADDITIONAL_CMAKE_FLAGS=${ADDITIONAL_CMAKE_FLAGS} -DCMAKE_CXX_STANDARD=${{matrix.cxx}}" >> $GITHUB_ENV
- name: Enable coverage collection
if: matrix.coverage
run: echo "ADDITIONAL_CMAKE_FLAGS=${ADDITIONAL_CMAKE_FLAGS} -DRTTR_ENABLE_COVERAGE=ON" >> $GITHUB_ENV
- name: Enable external sanitizer
if: matrix.externalSanitizer
run: echo "ADDITIONAL_CMAKE_FLAGS=${ADDITIONAL_CMAKE_FLAGS} -DRTTR_EXTERNAL_BUILD_TESTING=ON -DRTTR_ENABLE_SANITIZERS=ON" >> $GITHUB_ENV
# Coverage collection requires access to history to find merge-base
- uses: actions/checkout@v3
if: "!matrix.coverage"
with:
submodules: true
- uses: actions/checkout@v3
if: matrix.coverage
with:
submodules: true
fetch-depth: 0 # Faster checkout
- name: Cache dependencies
uses: actions/cache@v3
with:
path: ${{env.DEPS_DIR}}
key: ${{matrix.os}}-${{env.BOOST_VERSION}}
# clang-16 needs to be manually installed
- name: Install Compiler (Linux, clang-16)
if: matrix.compiler == 'clang-16' && matrix.os == 'ubuntu-20.04'
run: |
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
sudo add-apt-repository 'deb http://apt.llvm.org/focal/ llvm-toolchain-focal-16 main'
sudo apt update
- name: Install Compiler (Linux)
if: "!startsWith(runner.os, 'macos')"
run: |
pkgs=${{matrix.compiler}}
pkgs=${pkgs/gcc-/g++-}
sudo apt install $pkgs
# Setup CC, CXX and GCOV variables
- name: Setup compiler
run: |
CC=${{matrix.compiler}}
if [[ "$CC" =~ clang ]]; then
CXX=${CC/clang/clang++}
elif [[ "$CC" =~ gcc ]]; then
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
- name: Install system packages (Linux)
if: "!startsWith(runner.os, 'macos')"
run: |
sudo apt update
sudo apt install gettext libsdl2-dev libsdl2-mixer-dev libcurl4-openssl-dev libbz2-dev libminiupnpc-dev liblua5.2-dev
- name: Install system packages (OSX)
if: startsWith(runner.os, 'macos')
run: |
brew install cmake boost sdl2 sdl2_mixer gettext miniupnpc libiconv
echo /usr/local/opt/gettext/bin >> $GITHUB_PATH
echo "Available Boost installs: $(ls /usr/local/Cellar/boost/)"
# Use the latest (last folder)
BOOST_ROOT=$(find /usr/local/Cellar/boost/* -maxdepth 0 -type d | tail -n1)
[[ -n "$BOOST_ROOT" ]]
echo "Choosen Boost: $BOOST_ROOT"
echo "BOOST_ROOT=${BOOST_ROOT}" >> $GITHUB_ENV
- 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: Setup environment
run: echo "TRAVIS_BUILD_DIR=$GITHUB_WORKSPACE" >> $GITHUB_ENV
- 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