-
Notifications
You must be signed in to change notification settings - Fork 2
411 lines (363 loc) · 14.9 KB
/
build.yml
File metadata and controls
411 lines (363 loc) · 14.9 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
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
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
name: Build, test and Package
on:
push:
workflow_dispatch:
inputs:
debug_enabled:
type: boolean
description: 'Enable remote SSH connection. Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)'
required: false
default: false
jobs:
build:
name: Build, test and Package
# env and permissions are setup to add dependencies from vcpkg to the repo's dependency graph
env:
VCPKG_FEATURE_FLAGS: dependencygraph
VCPKG_EXE: ${{ github.workspace }}/vcpkg/vcpkg
FEED_URL: https://nuget.pkg.github.com/NexoEngine/index.json
VCPKG_BINARY_SOURCES: "clear;nuget,https://nuget.pkg.github.com/NexoEngine/index.json,readwrite"
DOTNET_INSTALL_DIR: "./.dotnet"
permissions:
contents: write
packages: write
strategy:
fail-fast: false
matrix:
os: [windows-latest, ubuntu-latest] # TODO: Add macos-latest later
compiler: [gcc, msvc] # TODO: add clang later
include:
- os: ubuntu-latest
compiler: gcc
version: 13
generator: Ninja
- os: windows-latest
compiler: msvc
version: 14
generator: "Visual Studio 17 2022"
exclude:
- os: ubuntu-latest
compiler: msvc
- os: windows-latest
compiler: gcc
- os: macos-latest
compiler: gcc
- os: macos-latest
compiler: msvc
runs-on: ${{ matrix.os }}
steps:
- name: Checkout repository
uses: actions/checkout@v5
with:
submodules: recursive
fetch-depth: 0 # Fetch all history for all tags and branches (for SonarCloud)
# DEBUGGING ONLY, to run this trigger with even
- name: Setup tmate session
uses: mxschmitt/action-tmate@v3
if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_enabled }}
with:
limit-access-to-actor: true # Only the person who triggered the workflow can access
detached: true # Run in the background and wait for connection
- name: Add Ubuntu toolchain repository
if: ${{ matrix.os == 'ubuntu-latest' && matrix.compiler == 'gcc'}}
run: |
sudo add-apt-repository --yes --update ppa:ubuntu-toolchain-r/test -y
sudo apt-get update
- name: Pre-install GCC with cache
if: ${{ matrix.os == 'ubuntu-latest' && matrix.compiler == 'gcc' }}
uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: cpp-13 g++-13 gcc-13 gcc-13-base libgcc-13-dev libhwasan0 \
libstdc++-13-dev libasan8 libatomic1 libcc1-0 libgcc-13-dev \
libgcc-s1 libgomp1 libhwasan0 libitm1 liblsan0 libquadmath0 \
libstdc++-13-dev libstdc++6 libtsan2 libubsan1
version: 1.0
execute_install_scripts: true
- name: Set up GCC
if: ${{ matrix.compiler == 'gcc' }}
id: set-up-gcc
uses: egor-tensin/setup-gcc@v1
with:
version: ${{ matrix.version }}
platform: x64
- name: Set up Clang
if: ${{ matrix.compiler == 'clang' }}
id: set-up-clang
uses: egor-tensin/setup-clang@v1
with:
version: ${{ matrix.version }}
platform: x64
cygwin: ${{ matrix.os == 'windows-latest' && 1 || 0 }}
- name: Set up MSVC
if: ${{ matrix.compiler == 'msvc' }}
uses: ilammy/msvc-dev-cmd@v1
with:
toolset: ${{ matrix.version }}
- name: Install required system dependencies for Ubuntu
if: ${{ matrix.os == 'ubuntu-latest' }}
uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: libxrandr-dev libx11-dev
libxext-dev libxi-dev libgl1-mesa-dev libxinerama-dev
libxcursor-dev libxcb-render0-dev libxcb-shape0-dev
libxcb-randr0-dev libxcb-xfixes0-dev libxcb-sync-dev libxcb-shm0-dev
libxcb-icccm4-dev libxcb-keysyms1-dev libxcb-dri2-0-dev libxcb-dri3-dev
libxcb-glx0-dev libx11-xcb-dev libglu1-mesa-dev
libxrender-dev libxi-dev libxkbcommon-dev libxkbcommon-x11-dev
libegl1-mesa-dev mono-complete
version: 1.0
execute_install_scripts: true
- name: Install .NET SDK 9.0
uses: actions/setup-dotnet@v4
with:
dotnet-version: '9.x'
- name: Init submodules
run: |
git submodule update --init --recursive
- name: Install sonar-scanner
if: ${{ matrix.os == 'ubuntu-latest' }}
uses: sonarsource/sonarcloud-github-c-cpp@v3
- name: Install latest CMake and Ninja
uses: lukka/get-cmake@latest
with:
cmakeVersion: ~3.30.0
- name: Setup vcpkg
uses: lukka/run-vcpkg@v11
- name: Add NuGet sources
if: ${{ matrix.os == 'windows-latest' }}
shell: pwsh
env:
USERNAME: NexoEngine
run: |
.$(${{ env.VCPKG_EXE }} fetch nuget) `
sources add `
-Source "${{ env.FEED_URL }}" `
-StorePasswordInClearText `
-Name GitHubPackages `
-UserName "${{ env.USERNAME }}" `
-Password "${{ secrets.GITHUB_TOKEN }}"
.$(${{ env.VCPKG_EXE }} fetch nuget) `
setapikey "${{ secrets.GITHUB_TOKEN }}" `
-Source "${{ env.FEED_URL }}"
- name: Add NuGet sources
if: ${{ matrix.os != 'windows-latest' }}
shell: bash
env:
USERNAME: NexoEngine
run: |
mono `${{ env.VCPKG_EXE }} fetch nuget | tail -n 1` \
sources add \
-Source "${{ env.FEED_URL }}" \
-StorePasswordInClearText \
-Name GitHubPackages \
-UserName "${{ env.USERNAME }}" \
-Password "${{ secrets.GITHUB_TOKEN }}"
mono `${{ env.VCPKG_EXE }} fetch nuget | tail -n 1` \
setapikey "${{ secrets.GITHUB_TOKEN }}" \
-Source "${{ env.FEED_URL }}"
- name: CMake Workflow with preset 'build-coverage' for tests
uses: lukka/run-cmake@v10
with:
workflowPreset: 'build-coverage'
env:
CMAKE_GENERATOR: ${{ matrix.generator }}
CC: ${{ matrix.compiler == 'clang' && steps.set-up-clang.outputs.clang || matrix.compiler == 'gcc' && steps.set-up-gcc.outputs.gcc || '' }}
CXX: ${{ matrix.compiler == 'clang' && steps.set-up-clang.outputs.clangxx || matrix.compiler == 'gcc' && steps.set-up-gcc.outputs.gxx || '' }}
CMAKE_C_COMPILER: ${{ matrix.compiler == 'clang' && steps.set-up-clang.outputs.clang || matrix.compiler == 'gcc' && steps.set-up-gcc.outputs.gcc || '' }}
CMAKE_CXX_COMPILER: ${{ matrix.compiler == 'clang' && steps.set-up-clang.outputs.clangxx || matrix.compiler == 'gcc' && steps.set-up-gcc.outputs.gxx || '' }}
USERNAME: NexoEngine
- name: Install Mesa for Windows
shell: cmd
if: ${{ matrix.os == 'windows-latest' }}
run: |
curl.exe -L --output mesa.7z --url https://github.com/pal1000/mesa-dist-win/releases/download/20.3.2/mesa3d-20.3.2-release-msvc.7z
"C:\Program Files\7-Zip\7z.exe" x mesa.7z
mklink opengl32.dll "x64\opengl32.dll"
mklink libglapi.dll "x64\libglapi.dll"
working-directory: 'build'
- name: Run headless test
uses: coactions/setup-xvfb@v1
with:
run: 'ctest -C Debug --output-on-failure'
working-directory: 'build'
- name: Collect coverage into XML report for SonarCloud
if: ${{ matrix.os == 'ubuntu-latest' }}
run: |
pip install gcovr
gcovr build --verbose --sonarqube -o coverage.xml --gcov-executable gcov-${{ matrix.version }}
cat coverage.xml
- name: Run sonar-scanner
if: ${{ matrix.os == 'ubuntu-latest' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONARCLOUD_TOKEN }}
run: |
sonar-scanner \
--define sonar.cfamily.compile-commands="./build/compile_commands.json" \
--define sonar.coverageReportPaths=coverage.xml
- name: Install nexoEditor
shell: bash
run: |
mkdir -p output
cmake --install build --component Unspecified --prefix ./output --config Debug -v
- name: Upload package
uses: actions/upload-artifact@v4
with:
name: nexo-engine-${{ matrix.compiler }}${{ matrix.version }}-${{ matrix.os }}
path: |
./output/*
- name: CMake Workflow with preset 'minimal-build' for packaging
uses: lukka/run-cmake@v10
with:
workflowPreset: 'minimal-build'
env:
CMAKE_GENERATOR: ${{ matrix.generator }}
CC: ${{ matrix.compiler == 'clang' && steps.set-up-clang.outputs.clang || matrix.compiler == 'gcc' && steps.set-up-gcc.outputs.gcc || '' }}
CXX: ${{ matrix.compiler == 'clang' && steps.set-up-clang.outputs.clangxx || matrix.compiler == 'gcc' && steps.set-up-gcc.outputs.gxx || '' }}
CMAKE_C_COMPILER: ${{ matrix.compiler == 'clang' && steps.set-up-clang.outputs.clang || matrix.compiler == 'gcc' && steps.set-up-gcc.outputs.gcc || '' }}
CMAKE_CXX_COMPILER: ${{ matrix.compiler == 'clang' && steps.set-up-clang.outputs.clangxx || matrix.compiler == 'gcc' && steps.set-up-gcc.outputs.gxx || '' }}
- name: Generate NSIS installer
if: ${{ matrix.os == 'windows-latest' }}
shell: bash
run: |
choco install -y nsis
cd build
cpack -G NSIS --verbose
- name: Generate DEB installer
if: ${{ matrix.os == 'ubuntu-latest' }}
shell: bash
run: |
cd build
cpack -G DEB --verbose
- name: Upload installer packages
uses: actions/upload-artifact@v4
with:
name: nexo-engine-installer-${{ matrix.compiler }}${{ matrix.version }}-${{ matrix.os }}
path: |
build/NEXO-Engine-*-win64.exe
build/*.deb
test-nsis-installer:
name: Test NSIS installer
runs-on: windows-latest
env:
DOTNET_INSTALL_DIR: "./.dotnet"
needs: build
steps:
- name: Download NSIS installer
id: download
uses: actions/download-artifact@v4
with:
pattern: 'nexo-engine-installer-msvc14-windows-latest'
- name: Install .NET SDK 9.0
uses: actions/setup-dotnet@v4
with:
dotnet-version: '9.x'
- name: Run NSIS installer
shell: pwsh
run: |
# Find the first .exe file in the downloaded directory
$exePath = Get-ChildItem -Path "${{steps.download.outputs.download-path}}\nexo-engine-installer-msvc14-windows-latest" -Filter "*.exe" | Select-Object -First 1 -ExpandProperty FullName
if (-not $exePath) {
Write-Error "No .exe file found in the directory."
exit 1
}
# Run the installer with /S for silent mode and /D to specify the installation directory
Start-Process -FilePath "$exePath" -wait -ArgumentList "/S /D=C:\Program Files\NexoEngine"
# Check if the installation directory exists
if (-not (Test-Path "C:\Program Files\NexoEngine")) {
Write-Error "Installation directory not found."
exit 1
}
- name: Install 7zip
run: choco install 7zip.install
- name: Install Mesa
shell: cmd
run: |
curl.exe -L --output mesa.7z --url https://github.com/pal1000/mesa-dist-win/releases/download/20.3.2/mesa3d-20.3.2-release-msvc.7z
"C:\Program Files\7-Zip\7z.exe" x mesa.7z
mklink opengl32.dll "x64\opengl32.dll"
mklink libglapi.dll "x64\libglapi.dll"
working-directory: "C:\\Program Files\\NexoEngine\\bin\\"
- name: Run NEXO headless
shell: pwsh
timeout-minutes: 1
run: |
$exePath = "C:\Program Files\NexoEngine\bin\nexoEditor.exe"
# Test the close behavior of the NEXO Editor
$process = Start-Process -FilePath $exePath -NoNewWindow -PassThru
$exited = $process.WaitForExit(10000)
if ($exited) {
Write-Error "::error:: NEXO Editor exited before timeout with code $($process.ExitCode)"
exit 1
}
$process.CloseMainWindow()
$process.WaitForExit()
if ($process.ExitCode -ne 0) {
Write-Error "::error:: NEXO Editor exited at close window with code $($process.ExitCode)"
exit 1
}
Write-Output "NEXO Editor gracefully closed with window close"
exit 0
test-deb-installer:
name: Test DEB installer
runs-on: ubuntu-latest
env:
DOTNET_INSTALL_DIR: "./.dotnet"
needs: build
steps:
- name: Download DEB installer
id: download
uses: actions/download-artifact@v4
with:
pattern: 'nexo-engine-installer-gcc13-ubuntu-latest'
- name: Install .NET SDK 9.0
uses: actions/setup-dotnet@v4
with:
dotnet-version: '9.x'
- name: Install DEB package
shell: bash
run: |
sudo apt-get update
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get -f install ${{steps.download.outputs.download-path}}/nexo-engine-installer-gcc13-ubuntu-latest/*.deb
- name: Write NEXO run script
uses: "DamianReeves/write-file-action@master"
with:
path: ./run-nexo.sh
contents: |
#!/bin/bash
nexoEditor &
process_pid=$!
echo "Started NEXO Editor with PID: $process_pid"
# Wait for the process for up to 10 seconds
timeout=10
for ((i=0; i<timeout; i++)); do
if ! ps -p $process_pid > /dev/null; then
# Process exited before timeout; capture exit code
wait $process_pid
exit_code=$?
echo "::error:: NEXO Editor exited before timeout with code $exit_code"
exit 1
fi
sleep 1
done
# Send SIGTERM signal to the process
kill -SIGTERM $process_pid
echo "Sent SIGTERM to process with PID: $process_pid"
# Wait for the process to terminate after SIGTERM
wait $process_pid
exit_code=$?
if [ $exit_code -ne 0 ]; then
echo "::error:: NEXO Editor exited at SIGTERM with code $exit_code"
exit 1
fi
echo "NEXO Editor gracefully closed with SIGTERM"
exit 0
- name: Set permissions for NEXO run script
run: chmod +x ./run-nexo.sh
- name: Run NEXO headless
uses: coactions/setup-xvfb@v1
timeout-minutes: 1
with:
run: ./run-nexo.sh