-
Notifications
You must be signed in to change notification settings - Fork 5
146 lines (130 loc) · 4.98 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
# Copyright (C) 2005 - 2021 Settlers Freaks <sf-team at siedler25.org>
#
# SPDX-License-Identifier: GPL-2.0-or-later
name: Unit tests
on:
push:
pull_request:
concurrency:
group: ${{format('tests-{0}:{1}', github.repository, github.ref)}}
cancel-in-progress: true
env:
BOOST_VERSION: 1.69.0
defaults:
run:
shell: bash
jobs:
StyleAndFormatting:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: git submodule update --init
- name: Validation
run: tools/ci/staticValidation.sh "$GITHUB_WORKSPACE"
- name: Formatting
uses: DoozyX/[email protected]
with:
source: "examples include src tests"
clangFormatVersion: 10
- name: Lint markdown files
uses: avto-dev/[email protected]
with:
args: .
- name: Check licensing
run:
pip install --user reuse
reuse lint
UnitTests:
strategy:
matrix:
include:
- { compiler: gcc-6, os: ubuntu-18.04, buildType: Release }
- { compiler: gcc-6, os: ubuntu-18.04, buildType: Debug, coverage: true }
- { compiler: clang, os: macos-10.15, buildType: Debug, boostVersion: 1.74.0 } # Multiple bugs with recent OSX until 1.74
# Latest GCC
- { compiler: gcc-10, os: ubuntu-18.04, buildType: Debug }
# Latest Clang
- { compiler: clang-10, os: ubuntu-18.04, buildType: Debug }
# Windows
- { compiler: msvc, os: windows-2019, buildType: Debug }
runs-on: ${{matrix.os}}
steps:
- run: |
echo "DEPS_DIR=${{runner.temp}}/.cache" >> $GITHUB_ENV
echo "LIBUTIL_DIR=$GITHUB_WORKSPACE/external/libutil" >> $GITHUB_ENV
echo "LIBENDIAN_DIR=$GITHUB_WORKSPACE/external/libendian" >> $GITHUB_ENV
- run: echo "BOOST_VERSION=${{matrix.boostVersion}}" >> $GITHUB_ENV
if: matrix.boostVersion
- uses: actions/checkout@v2
- uses: actions/checkout@v2
name: Checkout libutil
with:
repository: Return-To-The-Roots/libutil
ref: master
path: external/libutil
- uses: actions/checkout@v2
name: Checkout libendian
with:
repository: Return-To-The-Roots/libendian
ref: master
path: external/libendian
- name: Cache dependencies
if: "!startsWith(runner.os, 'Windows')"
uses: actions/cache@v2
with:
path: ${{env.DEPS_DIR}}
key: ${{matrix.os}}-${{matrix.compiler}}-${{env.BOOST_VERSION}}
- name: Install Compiler
if: "startsWith(runner.os, 'Linux')"
run: |
pkgs=${{matrix.compiler}}
pkgs=${pkgs/gcc-/g++-}
sudo apt install $pkgs
- name: Setup compiler
if: "!startsWith(runner.os, 'Windows')"
run: tools/ci/setupCompiler.sh
env:
COMPILER: ${{matrix.compiler}}
- name: Install system packages (Linux)
if: "startsWith(runner.os, 'Linux')"
run: sudo apt install ccache libminiupnpc-dev lcov
- name: Install system packages (OSX)
if: startsWith(runner.os, 'macOS')
run: brew install ccache cmake miniupnpc
- name: Install system packages (Windows)
if: startsWith(runner.os, 'Windows')
run: choco install wget
- name: Setup cmake
if: "!startsWith(runner.os, 'Windows')"
uses: jwlawson/[email protected]
with:
cmake-version: '3.9.x'
- name: Setup CCache
if: "!startsWith(runner.os, 'Windows')"
uses: hendrikmuhs/ccache-action@v1
with:
key: ${{matrix.os}}-${{matrix.compiler}}-${{matrix.buildType}}-${{matrix.boostVersion}}
max-size: 200M
- name: Install Boost
shell: bash
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
SHARED=""
if [[ "${{runner.os}}" == macOS ]]; then SHARED="shared"; fi # Seems to be required
$LIBUTIL_DIR/tools/ci/installBoost.sh "${BOOST_VERSION}" "${BOOST_ROOT}" "filesystem,system,program_options,thread,test,locale,iostreams,regex" $SHARED
- name: Enable coverage collection
if: matrix.coverage
run: echo "ADDITIONAL_CMAKE_FLAGS=${ADDITIONAL_CMAKE_FLAGS} -DRTTR_ENABLE_COVERAGE=ON" >> $GITHUB_ENV
- name: Build
run: tools/ci/build.sh "${{matrix.buildType}}" "${ADDITIONAL_CMAKE_FLAGS}"
- name: Upload coverage
if: matrix.coverage && success()
run: $LIBUTIL_DIR/tools/ci/uploadCoverageData.sh '*/examples/*' "${DEPS_DIR}/"'*' '*/build/*'
- name: Upload coverage (Coveralls)
if: matrix.coverage && success()
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: coverage.info