-
-
Notifications
You must be signed in to change notification settings - Fork 225
316 lines (297 loc) · 10.1 KB
/
build-and-test.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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
# Build and run tests for ReactPhysics3D
name: build
# Controls when the action will run. Triggers the workflow on push
on:
push:
branches:
- master
- develop
pull_request:
workflow_call:
secrets:
codecov_token:
required: true
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
name: ${{ matrix.config.name }}
runs-on: ${{ matrix.config.os }}
strategy:
fail-fast: false
matrix:
config:
- {
name: "Linux / GCC (Debug, Single Precision)",
os: ubuntu-latest,
build_type: "Debug",
cc: "gcc",
cxx: "g++",
cxx_flags: "-Wall -Wextra -pedantic",
generators: "Ninja",
double_precision: false,
coverage: false,
}
- {
name: "Linux / GCC (Release, Single Precision)",
os: ubuntu-latest,
build_type: "Release",
cc: "gcc",
cxx: "g++",
cxx_flags: "-Wall -Wextra -pedantic",
generators: "Ninja",
double_precision: false,
coverage: false,
}
- {
name: "Linux / GCC (Debug, Double Precision)",
os: ubuntu-latest,
build_type: "Debug",
cc: "gcc",
cxx: "g++",
cxx_flags: "-Wall -Wextra -pedantic",
generators: "Ninja",
double_precision: true,
coverage: false,
}
- {
name: "Linux / GCC (Release, Double Precision)",
os: ubuntu-latest,
build_type: "Release",
cc: "gcc",
cxx: "g++",
cxx_flags: "-Wall -Wextra -pedantic",
generators: "Ninja",
double_precision: true,
coverage: false,
}
- {
name: "Linux / Clang (Debug, Single Precision)",
os: ubuntu-latest,
build_type: "Debug",
cc: "clang",
cxx: "clang++",
cxx_flags: "-Wall -Wextra -pedantic",
generators: "Ninja",
double_precision: false,
coverage: false,
}
- {
name: "Linux / Clang (Release, Single Precision)",
os: ubuntu-latest,
build_type: "Release",
cc: "clang",
cxx: "clang++",
cxx_flags: "-Wall -Wextra -pedantic",
generators: "Ninja",
double_precision: false,
coverage: false,
}
- {
name: "Linux / Clang (Debug, Double Precision)",
os: ubuntu-latest,
build_type: "Debug",
cc: "clang",
cxx: "clang++",
cxx_flags: "-Wall -Wextra -pedantic",
generators: "Ninja",
double_precision: true,
coverage: false,
}
- {
name: "Linux / Clang (Release, Double Precision)",
os: ubuntu-latest,
build_type: "Release",
cc: "clang",
cxx: "clang++",
cxx_flags: "-Wall -Wextra -pedantic",
generators: "Ninja",
double_precision: true,
coverage: false,
}
- {
name: "Windows / MSVC (Debug, Single Precision)",
os: windows-latest,
build_type: "Debug",
cc: "cl",
cxx: "cl",
cxx_flags: "",
generators: "Visual Studio 17 2022",
double_precision: false,
coverage: false,
}
- {
name: "Windows / MSVC (Release, Single Precision)",
os: windows-latest,
build_type: "Release",
cc: "cl",
cxx: "cl",
cxx_flags: "",
generators: "Visual Studio 17 2022",
double_precision: false,
coverage: false,
}
# Commented because this is currently not working because of issue with running app on MinGW on github runner
#- {
# name: "Windows / MinGW (Debug, Single Precision)",
# os: windows-latest,
# build_type: "Debug",
# cc: "gcc",
# cxx: "g++",
# cxx_flags: "-Wall -Wextra -pedantic",
# generators: "Ninja",
# double_precision: false,
# coverage: false,
#}
#- {
# name: "Windows / MinGW (Release, Single Precision)",
# os: windows-latest,
# build_type: "Release",
# cc: "gcc",
# cxx: "g++",
# cxx_flags: "-Wall -Wextra -pedantic",
# generators: "Ninja",
# double_precision: false,
# coverage: false,
#}
- {
name: "MacOS / Clang (Debug, Single Precision)",
os: macos-latest,
build_type: "Debug",
cc: "clang",
cxx: "clang++",
cxx_flags: "-Wall -Wextra -pedantic",
generators: "Ninja",
double_precision: false,
coverage: false,
}
- {
name: "MacOS / Clang (Release, Single Precision)",
os: macos-latest,
build_type: "Release",
cc: "clang",
cxx: "clang++",
cxx_flags: "-Wall -Wextra -pedantic",
generators: "Ninja",
double_precision: false,
coverage: false,
}
- {
name: "Code Coverage",
os: ubuntu-latest,
build_type: "Debug",
cc: "gcc",
cxx: "g++",
cxx_flags: "-Wall -Wextra -pedantic",
generators: "Ninja",
double_precision: false,
coverage: true,
}
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- name: Print env
run: |
echo github.event.action: ${{ github.event.action }}
echo github.event_name: ${{ github.event_name }}
- name: Install dependencies on Windows
if: startsWith(matrix.config.os, 'windows')
run: |
choco install ninja cmake
ninja --version
cmake --version
- name: Install dependencies on Linux
if: startsWith(matrix.config.os, 'ubuntu')
run: |
sudo apt-get update
sudo apt-get install ninja-build cmake lcov valgrind
ninja --version
cmake --version
gcc --version
clang --version
- name: Install dependencies on MacOS
if: startsWith(matrix.config.os, 'macos')
run: |
brew install cmake ninja
ninja --version
cmake --version
- name: CMake Configure
shell: bash
env:
CC: ${{ matrix.config.cc }}
CXX: ${{ matrix.config.cxx }}
run: |
mkdir build
cmake \
-S . \
-B build \
-DCMAKE_BUILD_TYPE=${{ matrix.config.build_type }} \
-DRP3D_DOUBLE_PRECISION_ENABLED=${{ matrix.config.double_precision }} \
-DRP3D_CODE_COVERAGE_ENABLED=${{ matrix.config.coverage }} \
-DCODE_COVERAGE_VERBOSE=True \
-DRP3D_COMPILE_TESTS=True \
-DCMAKE_CXX_FLAGS="${{ matrix.config.cxx_flags }}" \
-G "${{ matrix.config.generators }}" \
- name: Build
shell: bash
run: cmake --build build/ --config ${{ matrix.config.build_type }}
- name: Install Library on Linux/MacOS
if: ${{ !startsWith(matrix.config.os, 'windows') }}
shell: bash
run: sudo cmake --install build/ --config ${{ matrix.config.build_type }}
- name: Install Library on Windows
if: startsWith(matrix.config.os, 'windows')
shell: bash
run: cmake --install build/ --config ${{ matrix.config.build_type }}
- name: Run Unit Tests (Linux / MacOS / Windows MinGW)
if: ${{ !startsWith(matrix.config.os, 'windows') }}
shell: bash
run: ./build/test/tests
- name: Run Unit Tests (Windows MSVC)
if: ${{ startsWith(matrix.config.name, 'Windows / MSVC') }}
shell: bash
run: "./build/test/${{ matrix.config.build_type }}/tests.exe"
- name: Build Hello World
if: ${{ !matrix.config.coverage }}
shell: bash
env:
CC: ${{ matrix.config.cc }}
CXX: ${{ matrix.config.cxx }}
run: |
mkdir build_hello_world
cmake \
-S helloworld \
-B build_hello_world \
-DCMAKE_BUILD_TYPE=${{ matrix.config.build_type }} \
-DCMAKE_EXE_LINKER_FLAGS=-no-pie \
-DCMAKE_CXX_FLAGS="${{ matrix.config.cxx_flags }}" \
-G "${{ matrix.config.generators }}"
cmake --build build_hello_world/ --config ${{ matrix.config.build_type }}
- name: Run Hello World (Linux / MacOS / Windows MinGW)
if: ${{ !startsWith(matrix.config.name, 'Windows / MSVC') && !matrix.config.coverage }}
shell: bash
run: "./build_hello_world/helloworld"
- name: Run Hello World (Windows MSVC)
if: ${{ startsWith(matrix.config.name, 'Windows / MSVC') }}
shell: bash
run: "./build_hello_world/${{ matrix.config.build_type }}/helloworld.exe"
- name: Memory Leaks Test
if: ${{ startsWith(matrix.config.name, 'Linux / GCC (Debug, Single Precision)') }}
shell: bash
run: valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes --verbose --error-exitcode=1 ./build/test/tests
- name: Compute Code Coverage
if: ${{ matrix.config.coverage }}
env:
CC: ${{ matrix.config.cc }}
CXX: ${{ matrix.config.cxx }}
shell: bash
run: |
cmake --build build/ --target coverage
- name: Upload coverage to Codecov
if: ${{ matrix.config.coverage }}
uses: codecov/codecov-action@v4
with:
fail_ci_if_error: true
token: ${{ secrets.codecov_token }}
verbose: false