More and better logging. #1192
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Cesium for Unity | |
on: [push] | |
jobs: | |
QuickChecks: | |
name: "Quick Checks" | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out repository code | |
uses: actions/checkout@v4 | |
- name: Install clang-format | |
run: pip install clang-format | |
- name: Check source formatting | |
run: | | |
find native~/Runtime native~/Editor native~/Shared \( -iname '*.cpp' -o -iname '*.h' \) -print0 | xargs -0 clang-format --dry-run -Werror | |
Documentation: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Install Doxygen | |
run: | | |
sudo apt install -y doxygen | |
- name: Check out repository code | |
uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
- name: Generate Documentation | |
run: | | |
doxygen ./Documentation~/Doxyfile | |
- name: Publish Documentation Artifact | |
if: ${{ success() }} | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ReferenceDocumentation | |
path: Documentation~/Reference | |
Windows: | |
needs: [QuickChecks] | |
runs-on: windows-latest | |
# Only allow a single Windows build at a time, for Unity licensing reasons | |
concurrency: windows | |
steps: | |
- name: Check out repository code | |
uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
- name: Install nasm | |
uses: ilammy/[email protected] | |
- name: Install wget | |
run: | | |
choco install -y wget | |
- name: Install Unity Hub | |
run: | | |
wget https://public-cdn.cloud.unity3d.com/hub/prod/UnityHubSetup.exe | |
Start-Process "./UnityHubSetup.exe" -Args "/S" -Wait | |
del ./UnityHubSetup.exe | |
- name: Install Unity | |
run: | | |
Start-Process -FilePath "C:/Program Files/Unity Hub/Unity Hub.exe" -Args "-- --headless install --version 2021.3.13f1 --changeset 9e7d58001ecf" -Wait | |
Start-Process -FilePath "C:/Program Files/Unity Hub/Unity Hub.exe" -Args "-- --headless install-modules --version 2021.3.13f1 --changeset 9e7d58001ecf --module android android-sdk-ndk-tools android-open-jdk-8u172-b11 universal-windows-platform uwp-il2cpp" -Wait | |
- name: Create SSH tunnel to Unity License Server | |
env: | |
UNITY_LICENSE_SERVER_SSH_KEY: ${{ secrets.UNITY_LICENSE_SERVER_SSH_KEY }} | |
run: | | |
$ENV:UNITY_LICENSE_SERVER_SSH_KEY | Set-Content ~/unity-client-ssh-key | |
# Without StrictHostKeyChecking, OpenSSH will sit forever waiting for local input to confirm the server key is ok. | |
# We don't really care if the server is authentic, because we're not sending anything sensitive to it. | |
# The license server VM's sshd_config also needed to be modified with the following options, in order to prevent | |
# the tunnel from being closed between here and when we're ready to use it. | |
# TCPKeepAlive yes | |
# ClientAliveInterval 30 | |
# ClientAliveCountMax 9999 | |
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]" | |
sleep 5 | |
- name: Test Connection to Unity License Server | |
run: | | |
wget.exe http://127.0.0.1:12331/v1/admin/status | |
cat status | |
rm status | |
- name: Configure Unity to Use the License Server | |
run: | | |
mkdir -p $ENV:PROGRAMDATA/Unity/config | |
$filename="$ENV:PROGRAMDATA/Unity/config/services-config.json" | |
$text='{"licensingServiceBaseUrl":"http://localhost:12331","enableEntitlementLicensing":true,"clientConnectTimeoutSec":120,"clientHandshakeTimeoutSec":60}' | |
[IO.File]::WriteAllLines($filename,$text) | |
- name: Update the version in Cesium.cpp | |
run: | | |
$VERSION = (Get-Content -path package.json | ConvertFrom-Json).version | |
$COMMIT = $(git rev-parse --short HEAD) | |
((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 | |
((Get-Content -path native~/Shared/src/Cesium.cpp -Raw) -replace 'Cesium::commit = "Unknown"',"Cesium::commit = ""$COMMIT""") | Set-Content -Path native~/Shared/src/Cesium.cpp | |
# Sanity check that the replacements happened | |
if (-Not ((Get-Content -path native~/Shared/src/Cesium.cpp -Raw) -match "$COMMIT")) { throw "Commit does not exist in file after replacement" } | |
if (-Not ((Get-Content -path native~/Shared/src/Cesium.cpp -Raw) -match "$VERSION")) { throw "Version does not exist in file after replacement" } | |
- name: Move cesium-unity Repo Under Empty Project | |
run: | | |
mkdir -p d:\cesium\CesiumForUnityBuildProject\Packages\com.cesium.unity | |
mv $ENV:GITHUB_WORKSPACE/* d:\cesium\CesiumForUnityBuildProject\Packages\com.cesium.unity | |
- name: Build Reinterop | |
run: | | |
cd d:\cesium\CesiumForUnityBuildProject\Packages\com.cesium.unity | |
dotnet publish Reinterop~ -o . | |
- name: Build Package | |
run: | | |
cd d:\cesium\CesiumForUnityBuildProject\Packages\com.cesium.unity | |
mkdir -p d:\cesium\temp | |
# Store temp files on the D drive, which is much faster than the EBS-backed C drive. | |
$ENV:TEMP="d:\cesium\temp" | |
# We only need a release build of vcpkg dependencies | |
$ENV:CESIUM_VCPKG_RELEASE_ONLY="TRUE" | |
# Clear ANDROID_NDK_ROOT so that we use Unity's version | |
Remove-Item Env:ANDROID_NDK_ROOT | |
# Run the build | |
dotnet run --project Build~ | |
cat D:\cesium\CesiumForUnityBuildProject\Packages\com.cesium.unity\native~\build-WSA-x86_64\build.log | |
cat D:\cesium\CesiumForUnityBuildProject\Packages\com.cesium.unity\native~\build-WSA-arm64\build.log | |
cat D:\cesium\CesiumForUnityBuildProject\Packages\com.cesium.unity\native~\build-Android-arm64\build.log | |
dir d:\cesium\CesiumForUnityBuildProject | |
dir C:\.ezvcpkg\2024.07.12\packages\spdlog_arm64-android-unity | |
dir C:\.ezvcpkg\2024.07.12\packages\spdlog_arm64-android-unity\include | |
dir C:\.ezvcpkg\2024.07.12\packages\spdlog_arm64-android-unity\include\spdlog | |
- name: Publish package artifact | |
if: ${{ success() }} | |
uses: actions/upload-artifact@v4 | |
with: | |
name: Windows Package | |
path: d:\cesium\CesiumForUnityBuildProject\*.tgz | |
- name: Run Tests | |
run: | | |
start -FilePath "C:\Program Files\Unity\Hub\Editor\2021.3.13f1\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 | |
cat d:\cesium\temp\test-log.txt | |
- name: Test Report | |
uses: kring/[email protected] | |
if: success() || failure() # run this step even if previous step failed | |
with: | |
name: Tests - Windows | |
path: d:/cesium/temp/TestResults.xml | |
reporter: dotnet-nunit | |
MacOS: | |
needs: [QuickChecks] | |
runs-on: macos-latest | |
# Only allow a single macOS build at a time, for Unity licensing reasons | |
concurrency: mac | |
steps: | |
# - name: Set XCode version | |
# uses: maxim-lobanov/setup-xcode@v1 | |
# with: | |
# xcode-version: "14.1" | |
- name: Check out repository code | |
uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
- name: Install nasm | |
uses: ilammy/[email protected] | |
- name: Install jq | |
run: brew install jq | |
- name: Install Unity Hub | |
run: | | |
wget --quiet https://public-cdn.cloud.unity3d.com/hub/prod/UnityHubSetup.dmg | |
mkdir UnityHubSetup | |
hdiutil attach UnityHubSetup.dmg -mountpoint ./UnityHubSetup | |
sudo cp -R "./UnityHubSetup/Unity Hub.app" /Applications | |
hdiutil detach ./UnityHubSetup | |
rm ./UnityHubSetup.dmg | |
- name: Install Unity 2021.3.13f1 | |
# This command sometimes returns exit code 130, despite actually succeeding. | |
continue-on-error: true | |
run: | | |
/Applications/Unity\ Hub.app/Contents/MacOS/Unity\ Hub -- --headless install --version 2021.3.13f1 --changeset 9e7d58001ecf --architecture x86_64 | |
- name: Install Unity iOS Support | |
run: | | |
/Applications/Unity\ Hub.app/Contents/MacOS/Unity\ Hub -- --headless install-modules --version 2021.3.13f1 --changeset 9e7d58001ecf --module ios --architecture x86_64 | |
- name: Configure Unity to Use the License Server | |
run: | | |
sudo mkdir -p "/Library/Application Support/Unity/config" | |
sudo chmod g+w "/Library/Application Support/Unity" | |
sudo chmod g+w "/Library/Application Support/Unity/config" | |
sudo echo '{"licensingServiceBaseUrl": "http://localhost:12331","enableEntitlementLicensing": true,"clientConnectTimeoutSec": 60,"clientHandshakeTimeoutSec": 120}' > "/Library/Application Support/Unity/config/services-config.json" | |
- name: Create SSH tunnel to Unity License Server | |
env: | |
UNITY_LICENSE_SERVER_SSH_KEY: ${{ secrets.UNITY_LICENSE_SERVER_SSH_KEY }} | |
run: | | |
echo "$UNITY_LICENSE_SERVER_SSH_KEY" > ~/unity-client-ssh-key | |
chmod 600 ~/unity-client-ssh-key | |
# Without StrictHostKeyChecking, OpenSSH will sit forever waiting for local input to confirm the server key is ok. | |
# We don't really care if the server is authentic, because we're not sending anything sensitive to it. | |
# The license server VM's sshd_config also needed to be modified with the following options, in order to prevent | |
# the tunnel from being closed between here and when we're ready to use it. | |
# TCPKeepAlive yes | |
# ClientAliveInterval 30 | |
# ClientAliveCountMax 9999 | |
ssh -fNT -o StrictHostKeyChecking=no -i ~/unity-client-ssh-key -L 127.0.0.1:12331:127.0.0.1:8080 [email protected] | |
sleep 5 | |
- name: Test Connection to Unity License Server | |
run: | | |
wget http://127.0.0.1:12331/v1/admin/status | |
cat status | |
rm status | |
- name: Update the version in Cesium.cpp | |
run: | | |
export VERSION=$(jq -r ".version" package.json) | |
export COMMIT=$(git rev-parse --short HEAD) | |
sed -i '' 's/Cesium::version = "Development Build"/Cesium::version = "'$VERSION'"/g' native~/Shared/src/Cesium.cpp | |
sed -i '' 's/Cesium::commit = "Unknown"/Cesium::commit = "'$COMMIT'"/g' native~/Shared/src/Cesium.cpp | |
# Sanity check that the replacements happened | |
grep $VERSION native~/Shared/src/Cesium.cpp | |
grep $COMMIT native~/Shared/src/Cesium.cpp | |
- name: Move cesium-unity Repo Under Empty Project | |
run: | | |
mkdir -p ~/cesium/CesiumForUnityBuildProject/Packages/com.cesium.unity | |
mv $GITHUB_WORKSPACE/* ~/cesium/CesiumForUnityBuildProject/Packages/com.cesium.unity | |
- name: Build Reinterop | |
run: | | |
cd ~/cesium/CesiumForUnityBuildProject/Packages/com.cesium.unity | |
dotnet publish Reinterop~ -o . | |
- name: Build Package | |
run: | | |
# We only need a release build of vcpkg dependencies | |
export CESIUM_VCPKG_RELEASE_ONLY="TRUE" | |
cd ~/cesium/CesiumForUnityBuildProject/Packages/com.cesium.unity | |
dotnet run --project Build~ | |
ls -l ~/cesium/CesiumForUnityBuildProject | |
- name: Print log | |
if: ${{ failure() }} | |
run: | | |
cat /Users/runner/cesium/CesiumForUnityBuildProject/Packages/com.cesium.unity/native~/build-Standalone-x86_64/build.log | |
cat /Users/runner/cesium/CesiumForUnityBuildProject/Packages/com.cesium.unity/native~/build-Standalone-arm64/build.log | |
cat /Users/runner/cesium/CesiumForUnityBuildProject/Packages/com.cesium.unity/native~/build-iOS/build.log | |
- name: Publish package artifact | |
if: ${{ success() }} | |
uses: actions/upload-artifact@v4 | |
with: | |
name: macOS Package | |
path: ~/cesium/CesiumForUnityBuildProject/*.tgz | |
- name: Run Tests | |
run: | | |
/Applications/Unity/Hub/Editor/2021.3.13f1/Unity.app/Contents/MacOS/Unity -runTests -batchmode -projectPath ~/cesium/CesiumForUnityBuildProject -testResults ~/cesium/CesiumForUnityBuildProject/TestResults.xml -testPlatform PlayMode -logFile ~/cesium/CesiumForUnityBuildProject/test-log.txt | |
cat ~/cesium/CesiumForUnityBuildProject/test-log.txt | |
ls /Users/runner/cesium/CesiumForUnityBuildProject/TestResults.xml | |
- name: Test Report | |
uses: kring/[email protected] | |
if: success() || failure() # run this step even if previous step failed | |
with: | |
name: Tests - macOS | |
path: /Users/runner/cesium/CesiumForUnityBuildProject/TestResults.xml | |
reporter: dotnet-nunit | |
Combine: | |
runs-on: ubuntu-latest | |
needs: [Windows, MacOS] | |
steps: | |
- name: Check out repository code | |
uses: actions/checkout@v4 | |
- name: Install jq | |
run: sudo apt install jq | |
- name: Download macOS build | |
uses: actions/download-artifact@v4 | |
with: | |
name: macOS Package | |
path: combine/macos | |
- name: Extract macOS build | |
run: | | |
cd combine/macos | |
tar xzf *.tgz | |
rm *.tgz | |
- name: Download Windows build | |
uses: actions/download-artifact@v4 | |
with: | |
name: Windows Package | |
path: combine/windows | |
- name: Extract Windows build | |
run: | | |
cd combine/windows | |
tar xzf *.tgz | |
rm *.tgz | |
- name: Create combined package | |
run: | | |
mkdir -p combine/merged | |
cd combine/merged | |
# Copy the everything. For files that exist in multiple packages, the Windows one will win. | |
cp -r ../macos/* . | |
cp -r ../windows/* . | |
# Remove the generated C# files | |
for file in $(find package/Runtime/generated -name '*.cs'); | |
do | |
rm $file | |
done; | |
for file in $(find package/Editor/generated -name '*.cs'); | |
do | |
rm $file | |
done; | |
# Merge the generated files by concatentation | |
cd ../macos | |
for file in $(find package/Runtime/generated -name '*.cs'); | |
do | |
mkdir -p $(dirname "../merged/$file") | |
cp "$file" "../merged/$file" | |
done; | |
for file in $(find package/Editor/generated -name '*.cs'); | |
do | |
mkdir -p $(dirname "../merged/$file") | |
cp "$file" "../merged/$file" | |
done; | |
cd ../windows | |
for file in $(find package/Runtime/generated -name '*.cs'); | |
do | |
echo Merging $file | |
mkdir -p $(dirname "../merged/$file") | |
cat "$file" >> "../merged/$file" | |
done; | |
for file in $(find package/Editor/generated -name '*.cs'); | |
do | |
echo Merging $file | |
mkdir -p $(dirname "../merged/$file") | |
cat "$file" >> "../merged/$file" | |
done; | |
# Create the package | |
cd ../merged | |
export NAME=$(jq -r ".name" $GITHUB_WORKSPACE/package.json) | |
export VERSION=$(jq -r ".version" $GITHUB_WORKSPACE/package.json) | |
tar czf $NAME-$VERSION.tgz package | |
- name: Publish combined package | |
if: ${{ success() }} | |
uses: actions/upload-artifact@v4 | |
with: | |
name: Combined Package | |
path: combine/merged/*.tgz |