Skip to content

Commit e885b34

Browse files
committed
Add separate Emscripten build to CI.
1 parent d7b3e01 commit e885b34

File tree

1 file changed

+156
-1
lines changed

1 file changed

+156
-1
lines changed

.github/workflows/build.yml

Lines changed: 156 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,9 +307,138 @@ jobs:
307307
name: Tests - macOS
308308
path: /Users/runner/cesium/CesiumForUnityBuildProject/TestResults.xml
309309
reporter: dotnet-nunit
310+
Emscripten:
311+
needs: [QuickChecks]
312+
runs-on: windows-latest
313+
# Only allow a single Emscripten build at a time, for Unity licensing reasons
314+
concurrency: emscripten
315+
steps:
316+
- name: Check out repository code
317+
uses: actions/checkout@v4
318+
with:
319+
submodules: recursive
320+
- name: Cache vcpkg artifacts
321+
uses: actions/cache@v4
322+
with:
323+
path: "d:/.ezvcpkg"
324+
key: vcpkg-windows-${{ hashFiles('native~/vcpkg/ports/**/vcpkg.json', 'native~/vcpkg/triplets/**/*', 'native~/extern/*toolchain.cmake') }}-${{ hashFiles('native~/extern/cesium-native/CMakeLists.txt', 'native~/CMakeLists.txt') }}
325+
restore-keys: |
326+
vcpkg-windows-${{ hashFiles('native~/vcpkg/ports/**/vcpkg.json', 'native~/vcpkg/triplets/**/*', 'native~/extern/*toolchain.cmake') }}-
327+
- name: Install latest ninja and cmake
328+
uses: lukka/get-cmake@latest
329+
with:
330+
cmakeVersion: "3.31.6"
331+
- name: Install nasm
332+
uses: ilammy/[email protected]
333+
- name: Install wget
334+
run: |
335+
choco install -y wget
336+
- name: Install Unity Hub
337+
run: |
338+
wget https://public-cdn.cloud.unity3d.com/hub/prod/UnityHubSetup.exe
339+
Start-Process "./UnityHubSetup.exe" -Args "/S" -Wait
340+
del ./UnityHubSetup.exe
341+
- name: Install Unity
342+
run: |
343+
# We must use Unity 6+ because the Emscripten version in older releases is too old.
344+
Start-Process -FilePath "C:/Program Files/Unity Hub/Unity Hub.exe" -Args "-- --headless install --version 6000.0.62f1 --changeset f99f05b3e950" -Wait
345+
Start-Process -FilePath "C:/Program Files/Unity Hub/Unity Hub.exe" -Args "-- --headless install-modules --version 6000.0.62f1 --changeset f99f05b3e950 --module webgl" -Wait
346+
- name: Create SSH tunnel to Unity License Server
347+
env:
348+
UNITY_LICENSE_SERVER_SSH_KEY: ${{ secrets.UNITY_LICENSE_SERVER_SSH_KEY }}
349+
run: |
350+
$ENV:UNITY_LICENSE_SERVER_SSH_KEY | Set-Content ~/unity-client-ssh-key
351+
# Without StrictHostKeyChecking, OpenSSH will sit forever waiting for local input to confirm the server key is ok.
352+
# We don't really care if the server is authentic, because we're not sending anything sensitive to it.
353+
# The license server VM's sshd_config also needed to be modified with the following options, in order to prevent
354+
# the tunnel from being closed between here and when we're ready to use it.
355+
# TCPKeepAlive yes
356+
# ClientAliveInterval 30
357+
# ClientAliveCountMax 9999
358+
start -FilePath ssh -ArgumentList "-o StrictHostKeyChecking=no -i ~/unity-client-ssh-key -L 127.0.0.1:12331:127.0.0.1:8080 [email protected]"
359+
sleep 5
360+
- name: Test Connection to Unity License Server
361+
run: |
362+
wget.exe http://127.0.0.1:12331/v1/admin/status
363+
cat status
364+
rm status
365+
- name: Configure Unity to Use the License Server
366+
run: |
367+
mkdir -p $ENV:PROGRAMDATA/Unity/config
368+
$filename="$ENV:PROGRAMDATA/Unity/config/services-config.json"
369+
$text='{"licensingServiceBaseUrl":"http://localhost:12331","enableEntitlementLicensing":true,"clientConnectTimeoutSec":120,"clientHandshakeTimeoutSec":60}'
370+
[IO.File]::WriteAllLines($filename,$text)
371+
- name: Update the version in Cesium.cpp
372+
run: |
373+
$VERSION = (Get-Content -path package.json | ConvertFrom-Json).version
374+
$COMMIT = $(git rev-parse --short HEAD)
375+
((Get-Content -path native~/Shared/src/Cesium.cpp -Raw) -replace 'Cesium::version = "Development Build"',"Cesium::version = ""$VERSION""") | Set-Content -Path native~/Shared/src/Cesium.cpp
376+
((Get-Content -path native~/Shared/src/Cesium.cpp -Raw) -replace 'Cesium::commit = "Unknown"',"Cesium::commit = ""$COMMIT""") | Set-Content -Path native~/Shared/src/Cesium.cpp
377+
# Sanity check that the replacements happened
378+
if (-Not ((Get-Content -path native~/Shared/src/Cesium.cpp -Raw) -match "$COMMIT")) { throw "Commit does not exist in file after replacement" }
379+
if (-Not ((Get-Content -path native~/Shared/src/Cesium.cpp -Raw) -match "$VERSION")) { throw "Version does not exist in file after replacement" }
380+
- name: Move cesium-unity Repo Under Empty Project
381+
run: |
382+
mkdir -p d:\cesium\CesiumForUnityBuildProject\Packages\com.cesium.unity
383+
mv $ENV:GITHUB_WORKSPACE/* d:\cesium\CesiumForUnityBuildProject\Packages\com.cesium.unity
384+
# Disable Unity audio
385+
mkdir -p d:\cesium\CesiumForUnityBuildProject\Packages\com.cesium.unity\ProjectSettings
386+
$text="%YAML 1.1`n%TAG !u! tag:unity3d.com,2011:`n--- !u!11 &1`nAudioManager:`n m_DisableAudio: 1`n"
387+
[IO.File]::WriteAllLines("d:/cesium/CesiumForUnityBuildProject/Packages/com.cesium.unity/ProjectSettings/AudioManager.asset",$text)
388+
- name: Build Reinterop
389+
run: |
390+
cd d:\cesium\CesiumForUnityBuildProject\Packages\com.cesium.unity
391+
dotnet publish Reinterop~ -o .
392+
- name: Print disk space 1
393+
if: success() || failure() # run this step even if previous step failed
394+
run: |
395+
get-psdrive
396+
- name: Build Package
397+
run: |
398+
cd d:\cesium\CesiumForUnityBuildProject\Packages\com.cesium.unity
399+
mkdir -p d:\cesium\temp
400+
# Store temp files on the D drive, which is much faster than the EBS-backed C drive.
401+
$ENV:TEMP="d:\cesium\temp"
402+
# We only need a release build of vcpkg dependencies
403+
$ENV:CESIUM_VCPKG_RELEASE_ONLY="TRUE"
404+
# Clear ANDROID_NDK_ROOT so that we use Unity's version
405+
Remove-Item Env:ANDROID_NDK_ROOT
406+
# Explicitly set the ezvcpkg path. Otherwise it will be `/.ezvcpkg` and the drive letter is ambiguous.
407+
$ENV:EZVCPKG_BASEDIR="D:/.ezvcpkg"
408+
# Run the build
409+
dotnet run --project Build~ --platform Web
410+
- name: Print disk space 2
411+
if: success() || failure() # run this step even if previous step failed
412+
run: |
413+
get-psdrive
414+
- name: Publish Logs
415+
if: success() || failure() # run this step even if previous step failed
416+
uses: actions/upload-artifact@v4
417+
with:
418+
name: Native Build Logs - Windows
419+
path: d:/cesium/CesiumForUnityBuildProject/Packages/com.cesium.unity/native~/build-*/build.log
420+
- name: Publish package artifact
421+
if: ${{ success() }}
422+
uses: actions/upload-artifact@v4
423+
with:
424+
name: Emscripten Package
425+
path: d:\cesium\CesiumForUnityBuildProject\*.tgz
426+
- name: Run Tests
427+
env:
428+
CESIUM_ION_TOKEN_FOR_TESTS: ${{ secrets.CESIUM_ION_TOKEN_FOR_TESTS }}
429+
run: |
430+
start -FilePath "C:\Program Files\Unity\Hub\Editor\2022.3.41f1\Editor\Unity.exe" -ArgumentList "-runTests -batchmode -projectPath d:\cesium\CesiumForUnityBuildProject -testResults d:\cesium\temp\TestResults.xml -testPlatform PlayMode -logFile d:\cesium\temp\test-log.txt" -Wait
431+
cat d:\cesium\temp\test-log.txt
432+
- name: Test Report
433+
uses: kring/[email protected]
434+
if: success() || failure() # run this step even if previous step failed
435+
with:
436+
name: Tests - Windows
437+
path: d:/cesium/temp/TestResults.xml
438+
reporter: dotnet-nunit
310439
Combine:
311440
runs-on: ubuntu-latest
312-
needs: [Windows, MacOS]
441+
needs: [Windows, MacOS, Emscripten]
313442
steps:
314443
- name: Check out repository code
315444
uses: actions/checkout@v4
@@ -325,6 +454,16 @@ jobs:
325454
cd combine/macos
326455
tar xzf *.tgz
327456
rm *.tgz
457+
- name: Download Emscripten build
458+
uses: actions/download-artifact@v4
459+
with:
460+
name: Emscripten Package
461+
path: combine/emscripten
462+
- name: Extract Emscripten build
463+
run: |
464+
cd combine/emscripten
465+
tar xzf *.tgz
466+
rm *.tgz
328467
- name: Download Windows build
329468
uses: actions/download-artifact@v4
330469
with:
@@ -342,6 +481,7 @@ jobs:
342481
343482
# Copy the everything. For files that exist in multiple packages, the Windows one will win.
344483
cp -r ../macos/* .
484+
cp -r ../emscripten/* .
345485
cp -r ../windows/* .
346486
347487
# Remove the generated C# files
@@ -366,6 +506,21 @@ jobs:
366506
mkdir -p $(dirname "../merged/$file")
367507
cp "$file" "../merged/$file"
368508
done;
509+
510+
cd ../emscripten
511+
for file in $(find package/Runtime/generated -name '*.cs');
512+
do
513+
echo Merging $file
514+
mkdir -p $(dirname "../merged/$file")
515+
cat "$file" >> "../merged/$file"
516+
done;
517+
for file in $(find package/Editor/generated -name '*.cs');
518+
do
519+
echo Merging $file
520+
mkdir -p $(dirname "../merged/$file")
521+
cat "$file" >> "../merged/$file"
522+
done;
523+
369524
cd ../windows
370525
for file in $(find package/Runtime/generated -name '*.cs');
371526
do

0 commit comments

Comments
 (0)