-
Notifications
You must be signed in to change notification settings - Fork 25
418 lines (360 loc) · 16 KB
/
build-addon-on-push.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
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
412
413
414
415
416
417
418
# Workflow to automatically create the godot openxr loaders addon
name: Build on push
on: [push, pull_request]
env:
# Only used for the cache key. Increment version to force clean build.
GODOT_BASE_BRANCH: master
SCONS_CACHE: ${{ github.workspace }}/.scons-cache/
jobs:
build:
name: Building for ${{ matrix.name }} (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
include:
- name: 🐧 Linux (x86_64, GCC)
os: ubuntu-20.04
platform: linux
flags: arch=x86_64
artifact_name: build-files-linux-x86_64
artifact_path: aar/demo/addons/godotopenxrvendors/.bin/linux/*/*/*.so
cache-name: linux-x86_64
# Not sure how to cross compile these
# - name: Linux (arm64)
# os: ubuntu-20.04
# platform: linux
# flags: arch=arm64
# artifact_name: build-files-linux-arm64
# artifact_path: aar/demo/addons/godotopenxrvendors/.bin/linux/*/*/*.so
# cache-name: linux-arm64
# - name: Linux (rv64)
# os: ubuntu-20.04
# platform: linux
# flags: arch=rv64
# artifact_name: build-files-linux-rv64
# artifact_path: aar/demo/addons/godotopenxrvendors/.bin/linux/*/*/*.so
# cache-name: linux-rv64
- name: 🏁 Windows (x86_64, MSVC)
os: windows-latest
platform: windows
artifact_name: build-files-windows
artifact_path: aar/demo/addons/godotopenxrvendors/.bin/windows/*/*/*.dll
cache-name: windows-x86_64-msvc
- name: 🍎 MacOS (universal)
os: macos-latest
platform: macos
flags: arch=universal
artifact_name: build-files-macos
artifact_path: aar/demo/addons/godotopenxrvendors/.bin/macos/*/*.framework
cache-name: macos-universal
- name: 🤖 Android (arm64)
os: ubuntu-20.04
platform: android
flags: arch=arm64
artifact_name: build-files-android
artifact_path: |
aar/demo/addons/godotopenxrvendors/.bin/android/*/*.aar
aar/demo/addons/godotopenxrvendors/.bin/android/*/*/*.so
cache-name: android-arm64
# Note, to satisfy the asset library we need to make sure our zip files have a root folder
# this is why we checkout into aar and build into asset
steps:
- name: Checkout
uses: actions/checkout@v4
with:
path: aar
submodules: recursive
- name: Restore Godot build cache
uses: ./aar/thirdparty/godot-cpp/.github/actions/godot-cache-restore
with:
cache-name: ${{ matrix.cache-name }}
continue-on-error: true
- name: Set up Python (for SCons)
uses: actions/setup-python@v5
with:
python-version: "3.x"
- name: Android dependencies
uses: nttld/setup-ndk@v1
with:
ndk-version: r23c
link-to-sdk: true
- name: Install scons
run: |
python -m pip install scons==4.0.0
- name: Create extension library
run: |
cd aar
scons platform=${{ matrix.platform }} target=template_debug ${{ matrix.flags }} custom_api_file=thirdparty/godot_cpp_gdextension_api/extension_api.json build_profile=thirdparty/godot_cpp_build_profile/build_profile.json
scons platform=${{ matrix.platform }} target=template_release ${{ matrix.flags }} custom_api_file=thirdparty/godot_cpp_gdextension_api/extension_api.json build_profile=thirdparty/godot_cpp_build_profile/build_profile.json
cd ..
- name: Save Godot build cache
uses: ./aar/thirdparty/godot-cpp/.github/actions/godot-cache-save
with:
cache-name: ${{ matrix.cache-name }}
continue-on-error: true
# On Android we build our loaders and build our extension with gradlew
- name: Setup java
uses: actions/setup-java@v4
with:
java-version: 17
distribution: "adopt"
if: matrix.platform == 'android'
- name: Validate Gradle wrapper
uses: gradle/actions/wrapper-validation@v3
if: matrix.platform == 'android'
- name: Create Godot-CPP library
run: |
cd aar/thirdparty/godot-cpp
scons platform=${{ matrix.platform }} target=template_debug arch=arm64 custom_api_file=../godot_cpp_gdextension_api/extension_api.json build_profile=../godot_cpp_build_profile/build_profile.json
scons platform=${{ matrix.platform }} target=template_release arch=arm64 custom_api_file=../godot_cpp_gdextension_api/extension_api.json build_profile=../godot_cpp_build_profile/build_profile.json
scons platform=${{ matrix.platform }} target=template_debug arch=x86_64 custom_api_file=../godot_cpp_gdextension_api/extension_api.json build_profile=../godot_cpp_build_profile/build_profile.json
scons platform=${{ matrix.platform }} target=template_release arch=x86_64 custom_api_file=../godot_cpp_gdextension_api/extension_api.json build_profile=../godot_cpp_build_profile/build_profile.json
cd ../../..
if: matrix.platform == 'android'
- name: Create Godot OpenXR Vendors AARs
uses: burrunan/gradle-cache-action@v1
with:
build-root-directory: aar
arguments: build
if: matrix.platform == 'android'
- name: Upload build files (artifacts)
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact_name }}
path: |
${{ matrix.artifact_path }}
# GODOT 4.2 ADDON GENERATION SECTION
asset:
name: Assembling the asset
runs-on: ubuntu-20.04
needs: build
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- name: Checkout
uses: actions/checkout@v4
with:
path: aar
- name: Download all workflow run artifacts
uses: actions/download-artifact@v4
- name: Create Godot OpenXR Vendors Addon
run: |
mkdir asset
cp -r aar/demo/addons asset
cp aar/CHANGES.md asset/addons/godotopenxrvendors/GodotOpenXRVendors_CHANGES.md
- name: Adding vendor licences
run: |
mkdir -p asset/addons/godotopenxrvendors/meta/
cp aar/thirdparty/ovr_openxr_mobile_sdk/LICENSE.txt asset/addons/godotopenxrvendors/meta/
mkdir -p asset/addons/godotopenxrvendors/pico/
cp aar/thirdparty/khronos_openxr_sdk/LICENSE asset/addons/godotopenxrvendors/pico/LICENSE
mkdir -p asset/addons/godotopenxrvendors/khronos/
cp aar/thirdparty/khronos_openxr_sdk/LICENSE asset/addons/godotopenxrvendors/khronos/LICENSE
mkdir -p asset/addons/godotopenxrvendors/magicleap/
cp aar/thirdparty/khronos_openxr_sdk/LICENSE asset/addons/godotopenxrvendors/magicleap/LICENSE
- name: Copying artifacts
run: |
mkdir -p asset/addons/godotopenxrvendors/.bin/android/
cp -r build-files-android/* asset/addons/godotopenxrvendors/.bin/android/
mkdir -p asset/addons/godotopenxrvendors/.bin/linux/
cp -r build-files-linux-x86_64/* asset/addons/godotopenxrvendors/.bin/linux/
mkdir -p asset/addons/godotopenxrvendors/.bin/windows/
cp -r build-files-windows/* asset/addons/godotopenxrvendors/.bin/windows/
mkdir -p asset/addons/godotopenxrvendors/.bin/macos/
cp -r build-files-macos/* asset/addons/godotopenxrvendors/.bin/macos/
- name: Create Godot OpenXR Vendor addon artifact
uses: actions/upload-artifact@v4
with:
name: GodotOpenXRVendorsAddon
include-hidden-files: true
path: |
asset
- name: Zip addon
run: |
zip -qq -r godotopenxrvendorsaddon.zip asset
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
- name: Create and upload asset
uses: ncipollo/release-action@v1
with:
allowUpdates: true
artifacts: "godotopenxrvendorsaddon.zip"
omitNameDuringUpdate: true
omitBodyDuringUpdate: true
omitDraftDuringUpdate: true
omitPrereleaseDuringUpdate: true
token: ${{ secrets.GITHUB_TOKEN }}
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
run_xr_simulator:
name: "Run XR Simulator"
#runs-on: windows-latest
runs-on: [Windows, self-hosted, gpu]
needs: build
env:
GODOT_VERSION: "4.3-stable"
XRSIM_VERSION: "65.0.0"
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
lfs: 'true'
- name: Install Chocolatey
run: |
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
- name: Install 7zip
run: |
choco install 7zip -y
- name: Download Godot
run: |
Invoke-WebRequest -Uri "https://github.com/godotengine/godot-builds/releases/download/${{ env.GODOT_VERSION }}/Godot_v${{ env.GODOT_VERSION }}_win64.exe.zip" -OutFile "godot.zip"
- name: Extract Godot
run: |
Expand-Archive -Path "godot.zip" -DestinationPath .
#- name: Download SwiftShader vulkan-1.dll
# run: |
# Invoke-WebRequest -Uri "https://www.dropbox.com/scl/fi/r6radx6b125555xkxue20/vulkan-1.dll?rlkey=ffv3cgvqbytivm1zy119hss7n&st=frcettrf&dl=1" -OutFile "vulkan-1.dll"
- name: Download Meta XR Simulator
run: |
Invoke-WebRequest -Uri "https://npm.developer.oculus.com/com.meta.xr.simulator/-/com.meta.xr.simulator-${{ env.XRSIM_VERSION }}.tgz" -OutFile MetaXRSimulator.tgz
- name: Extract Meta XR Simulator
run: |
# Unzip.
New-Item -Path "C:\Meta" -ItemType Directory -Force
tar -xzvf "MetaXRSimulator.tgz" -C "C:\Meta\"
rm "MetaXRSimulator.tgz"
- name: Configure the Meta XR Simulator as the active OpenXR runtime
run: |
New-Item -Path "HKLM:\SOFTWARE\Khronos\OpenXR\1" -Name "ActiveRuntime" -Force
Set-ItemProperty -Path "HKLM:\SOFTWARE\Khronos\OpenXR\1" -Name "ActiveRuntime" -Value "C:\Meta\package\MetaXRSimulator\meta_openxr_simulator.json"
- name: Download Windows build artifacts
uses: actions/download-artifact@v4
with:
name: build-files-windows
path: build-files-windows
- name: Copy Windows build of the addon into the demo and samples project
run: |
mkdir -p demo/addons/godotopenxrvendors/.bin/windows/
cp -r build-files-windows/* demo/addons/godotopenxrvendors/.bin/windows/
$sampleProjects = Get-ChildItem -Path "samples/" -Directory
foreach ($project in $sampleProjects) {
cp -r demo/addons "$($project.FullName)/"
}
- name: Import the demo and sample projects
run: |
$godot = "Godot_v${{ env.GODOT_VERSION }}_win64.exe"
Write-Output ""
Write-Output " ** Importing demo project"
Write-Output ""
Start-Process -FilePath "$godot" -ArgumentList "--path demo --import --headless" -NoNewWindow -Wait
$sampleProjects = Get-ChildItem -Path "samples/" -Directory
foreach ($project in $sampleProjects) {
$projectFile = Join-Path -Path $project.FullName -ChildPath "project.godot"
if (Test-Path $projectFile) {
Write-Output ""
Write-Output " ** Importing project $($project.Name)"
Write-Output ""
Start-Process -FilePath "$godot" -ArgumentList "--path $($project.FullName) --import --headless" -NoNewWindow -Wait
}
}
- name: Launch a synthetic environment
run: |
# Ensure a synthetic environment isn't already running.
try {
Get-Process -Name "synth_env_server" | Stop-Process
} catch {
# Do nothing if there is no existing process.
}
Start-Process -FilePath "C:\Meta\package\MetaXRSimulator\.synth_env_server\synth_env_server.exe" -ArgumentList "Bedroom" -PassThru
- name: Run tests
run: |
$jsonPath = "$env:AppData\MetaXR\MetaXrSimulator\persistent_data.json"
$demoVrsFiles = Get-ChildItem -Path "demo/tests/" -Recurse -Filter *.vrs
$sampleVrsFiles = Get-ChildItem -Path "samples/*/tests/" -Recurse -Filter *.vrs
$vrsFiles = @()
$vrsFiles += $demoVrsFiles
$vrsFiles += $sampleVrsFiles
foreach ($file in $vrsFiles) {
$replayPath = Join-Path -Path $file.DirectoryName -ChildPath ($file.BaseName + "-replay.vrs")
$jsonContent = @{
session_capture = @{
delay_start_ms = 5000
exec_state = "replay"
quit_buffer_ms = 5000
quit_when_complete = $true
record_path = $file.FullName
replay_path = $replayPath
}
} | ConvertTo-Json
New-Item -ItemType Directory -Force -Path (Split-Path $jsonPath)
Set-Content -Path $jsonPath -Value $jsonContent
echo "$jsonContent"
$godot = "Godot_v${{ env.GODOT_VERSION }}_win64.exe"
$timeout = 300
$waitTime = 0
$projectPath = (Get-Item $file.DirectoryName).Parent
Write-Output ""
Write-Output " ** Running VRS $($file.Name) on $($projectPath.Name) project"
Write-Output ""
$process = Start-Process -FilePath "$godot" -ArgumentList "--path $($projectPath.FullName) --rendering-method mobile --verbose -- --xrsim-automated-tests" -NoNewWindow -PassThru
while ($process.HasExited -eq $false -and $waitTime -lt $timeout) {
Start-Sleep -Seconds 1
$waitTime++
}
if ($process.HasExited -eq $false) {
Write-Output "Process is still running after $timeout seconds. Stopping the process."
$process.Kill()
Exit 1
} else {
Write-Output "Process completed within $waitTime seconds."
}
if (-Not (Test-Path $replayPath)) {
Write-Error "Replay file not found: $replayPath"
Exit 1
}
}
- name: Stop synthetic environment
run: |
Get-Process -Name "synth_env_server" | Stop-Process
- name: Upload VRS artifacts
uses: actions/upload-artifact@v4
with:
name: ReplayVRS
path: |
test-scripts/
**/*/tests/*.vrs
compare_vrs_replay:
name: "Compare VRS replay"
runs-on: ubuntu-latest
needs: run_xr_simulator
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download VRS artifacts
uses: actions/download-artifact@v4
with:
name: ReplayVRS
path: tests/vrs
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r scripts/vrs_pixmatch/requirements.txt
- name: Compare VRS replay with expected recordings
run: |
cd tests/vrs/
mkdir diffs
for replay in $(find . -name \*-replay.vrs); do
echo " ==> Checking $replay..."
expected=$(echo $replay | sed -e 's/-replay.vrs$/.vrs/')
diff_path="diffs/$replay"
mkdir -p "$diff_path"
python ../../scripts/vrs_pixmatch/vrs_pixmatch.py "$expected" "$replay" --threshold 0.4 --max-pixel-diff 40000 --output-path "$diff_path" --verbose
done
- name: Upload VRS diff artifacts
uses: actions/upload-artifact@v4
if: always()
with:
name: ReplayVRSDiff
path: tests/vrs/diffs/**/*