-
Notifications
You must be signed in to change notification settings - Fork 85
372 lines (368 loc) · 17.9 KB
/
build.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
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: 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: Cache vcpkg artifacts
uses: actions/cache@v4
with:
path: "d:/.ezvcpkg"
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') }}
restore-keys: |
vcpkg-windows-${{ hashFiles('native~/vcpkg/ports/**/vcpkg.json', 'native~/vcpkg/triplets/**/*', 'native~/extern/*toolchain.cmake') }}-
- name: Install Ninja
run: |
choco install -y ninja
- 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 2022.3.41f1 --changeset 0f988161febf" -Wait
Start-Process -FilePath "C:/Program Files/Unity Hub/Unity Hub.exe" -Args "-- --headless install-modules --version 2022.3.41f1 --changeset 0f988161febf --module android android-sdk-ndk-tools android-open-jdk-11.0.14.1+1 universal-windows-platform" -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
# Disable Unity audio
mkdir -p d:\cesium\CesiumForUnityBuildProject\Packages\com.cesium.unity\ProjectSettings
$text="%YAML 1.1`n%TAG !u! tag:unity3d.com,2011:`n--- !u!11 &1`nAudioManager:`n m_DisableAudio: 1`n"
[IO.File]::WriteAllLines("d:/cesium/CesiumForUnityBuildProject/Packages/com.cesium.unity/ProjectSettings/AudioManager.asset",$text)
- 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
# Explicitly set the ezvcpkg path. Otherwise it will be `/.ezvcpkg` and the drive letter is ambiguous.
$ENV:EZVCPKG_BASEDIR="D:/.ezvcpkg"
# Run the build
dotnet run --project Build~
- name: Publish Logs
if: success() || failure() # run this step even if previous step failed
uses: actions/upload-artifact@v4
with:
name: Native Build Logs - Windows
path: d:/cesium/CesiumForUnityBuildProject/Packages/com.cesium.unity/native~/build-*/build.log
- name: Publish package artifact
if: ${{ success() }}
uses: actions/upload-artifact@v4
with:
name: Windows Package
path: d:\cesium\CesiumForUnityBuildProject\*.tgz
- name: Run Tests
env:
CESIUM_ION_TOKEN_FOR_TESTS: ${{ secrets.CESIUM_ION_TOKEN_FOR_TESTS }}
run: |
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
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: Make some more disk space
run: |
df -h
ls /Applications
brew uninstall google-chrome
sudo rm -rf /Users/runner/Library/Android
sudo rm -rf /Applications/Xcode_14.3.1.app
sudo rm -rf /Applications/Xcode_14.3.app
sudo rm -rf /Applications/Xcode_15.0.1.app
sudo rm -rf /Applications/Xcode_15.0.app
sudo rm -rf /Applications/Xcode_15.1.0.app
sudo rm -rf /Applications/Xcode_15.1.app
sudo rm -rf /Applications/Xcode_15.2.0.app
sudo rm -rf /Applications/Xcode_15.2.app
sudo rm -rf /Applications/Xcode_15.3.0.app
sudo rm -rf /Applications/Xcode_15.3.app
sudo rm -rf /Applications/Xcode_16.0.0.app
sudo rm -rf /Applications/Xcode_16.0.app
sudo rm -rf /Applications/Xcode_16.1.0.app
sudo rm -rf /Applications/Xcode_16.1.app
sudo rm -rf /Applications/Xcode_16.1_beta.app
sudo rm -rf /Applications/Xcode_16_beta_6.app
ls /Applications
df -h
- name: Check out repository code
uses: actions/checkout@v4
with:
submodules: recursive
- name: Cache vcpkg artifacts
uses: actions/cache@v4
with:
path: "~/.ezvcpkg"
key: vcpkg-mac-${{ hashFiles('native~/vcpkg/ports/**/vcpkg.json', 'native~/vcpkg/triplets/**/*', 'native~/extern/*toolchain.cmake') }}-${{ hashFiles('native~/extern/cesium-native/CMakeLists.txt', 'native~/CMakeLists.txt') }}
restore-keys: |
vcpkg-mac-${{ hashFiles('native~/vcpkg/ports/**/vcpkg.json', 'native~/vcpkg/triplets/**/*', 'native~/extern/*toolchain.cmake') }}-
- name: Install nasm
uses: ilammy/[email protected]
- 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 2022.3.41f1
# 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 2022.3.41f1 --changeset 0f988161febf --architecture arm64
- name: Install Unity iOS Support
run: |
/Applications/Unity\ Hub.app/Contents/MacOS/Unity\ Hub -- --headless install-modules --version 2022.3.41f1 --changeset 0f988161febf --module ios --architecture arm64
- 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
# Disable Unity audio
mkdir -p ~/cesium/CesiumForUnityBuildProject/Packages/com.cesium.unity/ProjectSettings
echo '%YAML 1.1\n%TAG !u! tag:unity3d.com,2011:\n--- !u!11 &1\nAudioManager:\n m_DisableAudio: 1\n' > ~/cesium/CesiumForUnityBuildProject/Packages/com.cesium.unity/ProjectSettings/AudioManager.asset
- 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: Publish Logs
if: success() || failure() # run this step even if previous step failed
uses: actions/upload-artifact@v4
with:
name: Native Build Logs - macOS
path: ~/cesium/CesiumForUnityBuildProject/Packages/com.cesium.unity/native~/build-*/build.log
- name: Publish package artifact
if: ${{ success() }}
uses: actions/upload-artifact@v4
with:
name: macOS Package
path: ~/cesium/CesiumForUnityBuildProject/*.tgz
- name: Run Tests
env:
CESIUM_ION_TOKEN_FOR_TESTS: ${{ secrets.CESIUM_ION_TOKEN_FOR_TESTS }}
run: |
/Applications/Unity/Hub/Editor/2022.3.41f1/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