Skip to content

Commit db050d4

Browse files
committed
chore: restructure CI to build players in parallel
1 parent 01769a5 commit db050d4

File tree

2 files changed

+60
-54
lines changed

2 files changed

+60
-54
lines changed

.github/workflows/ci.yml

Lines changed: 58 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,21 @@ jobs:
112112
docker exec unity bash -c 'dotnet tool install --global Alias --version 0.2.0 && \
113113
~/.dotnet/tools/assemblyalias --target-directory "package-dev/Runtime" --internalize --prefix "Sentry." --assemblies-to-alias "Microsoft*;System*"'
114114
115+
- name: Prepare Sentry package for release
116+
shell: pwsh
117+
run: ./scripts/pack.ps1
118+
119+
- name: Upload release artifacts
120+
uses: actions/upload-artifact@v2
121+
if: ${{ matrix.unity-version == env.LOWEST_SUPPORTED_UNITY_VERSION }}
122+
with:
123+
name: ${{ github.sha }}
124+
if-no-files-found: error
125+
# Adding the native libraries so the symbol collector craft target can find/upload them
126+
path: |
127+
package-release.zip
128+
modules/sentry-java/sentry-android-ndk/build/intermediates/merged_native_libs/release/out/lib/*
129+
115130
- name: Run Unity tests (playmode)
116131
# TODO: Run Play mode tests on 2021.2 or newer once S.T.J loading issue resolved.
117132
# System.MissingMethodException : Method not found: System.Text.Json.JsonDocument System.Text.Json.JsonDocument.Parse(System.ReadOnlyMemory`1<byte>,System.Text.Json.JsonDocumentOptions)
@@ -145,68 +160,59 @@ jobs:
145160
docker exec unity dotnet msbuild /t:UnityConfigureSentryOptions /p:TestDsn=http://publickey@localhost:8000/12345 /p:Configuration=Release /p:OutDir=other src/Sentry.Unity
146161
docker exec unity dotnet msbuild /t:UnityBuildPlayerIOS /p:Configuration=Release /p:OutDir=other src/Sentry.Unity
147162
148-
- name: Prepare Sentry package for release
149-
shell: pwsh
150-
run: ./scripts/pack.ps1
151-
152-
- name: Upload build artifacts if build failed
153-
if: ${{ failure() }}
154-
uses: actions/upload-artifact@v2
155-
with:
156-
name: Build output
157-
path: artifacts/build
158-
159163
- name: Upload Xcode project for smoke test.
160164
uses: actions/upload-artifact@v2
161165
with:
162166
name: testapp-ios-project-${{ matrix.unity-version }}
163167
path: samples/artifacts/builds/iOS/Xcode
164168
if-no-files-found: error
165169

166-
- name: Upload release artifacts
167-
uses: actions/upload-artifact@v2
168-
if: ${{ matrix.unity-version == env.LOWEST_SUPPORTED_UNITY_VERSION }}
169-
with:
170-
name: ${{ github.sha }}
171-
if-no-files-found: error
172-
# Adding the native libraries so the symbol collector craft target can find/upload them
173-
path: |
174-
package-release.zip
175-
modules/sentry-java/sentry-android-ndk/build/intermediates/merged_native_libs/release/out/lib/*
170+
smoke-test-build:
171+
name: Build ${{ matrix.platform }} Smoke Test - ${{ matrix.unity-version }}
172+
runs-on: ubuntu-latest
173+
strategy:
174+
fail-fast: false
175+
matrix:
176+
unity-version: ['2019', '2020', '2021']
177+
platform: ['Android', 'WebGL']
178+
defaults:
179+
run:
180+
shell: pwsh
181+
steps:
182+
- name: Checkout
183+
uses: actions/[email protected]
176184

177-
# TODO: can we make unity only prepare the project, without compiling it, to unlock the unity license faster? iOS is already built like that.
178-
# This option should do it: https://docs.unity3d.com/ScriptReference/BuildOptions.AcceptExternalModificationsToPlayer.html
179-
- name: Build Android Player with IL2CPP
180-
run: |
181-
# Clean the previous (iOS) build or Unity 2021 fails to build because it caches the SmokeTester.cs precompiled with iOS directives.
182-
sudo git clean -ffxd samples
183-
docker exec unity dotnet msbuild /t:UnityConfigureSentryOptions /p:TestDsn=http://[email protected]:8000/12345 /p:Configuration=Release /p:OutDir=other src/Sentry.Unity
184-
docker exec unity dotnet msbuild /t:UnityBuildPlayerAndroidIL2CPP /p:Configuration=Release /p:OutDir=other src/Sentry.Unity
185+
- name: Load env
186+
id: env
187+
run: echo "::set-output name=unityVersion::$(./scripts/ci-env.ps1 "unity${{ matrix.unity-version }}")"
185188

186-
- name: Upload Android test app for smoke test.
187-
uses: actions/upload-artifact@v2
188-
with:
189-
name: testapp-android-${{ matrix.unity-version }}
190-
path: samples/artifacts/builds/Android/IL2CPP_Player.apk
191-
if-no-files-found: error
189+
- run: echo "::add-mask::${{ secrets.LICENSE_SERVER_URL }}"
192190

193-
- name: Upload Android Build
194-
uses: actions/upload-artifact@v2
191+
- name: Start the Unity docker container
192+
run: docker run -td --name unity -v ${{ github.workspace }}:/sentry-unity --workdir /sentry-unity ghcr.io/getsentry/unity-docker:editor-ubuntu-${{ steps.env.outputs.unityVersion }}
193+
194+
- name: Create Unity license config
195+
run: |
196+
docker exec unity mkdir -p /usr/share/unity3d/config/
197+
echo '${{ secrets.UNITY_LICENSE_SERVER_CONFIG }}' | docker exec -i unity sh -c "cat > /usr/share/unity3d/config/services-config.json"
198+
199+
- name: Download UPM package
200+
uses: vaind/download-artifact@989a39a417730897d098ab11c34e49ac4e13ed70
195201
with:
196-
name: Android Build
197-
path: samples/artifacts/builds/Android
198-
if-no-files-found: error
202+
name: ${{ github.sha }}
203+
wait-timeout: 3600
199204

200-
- name: Build WebGL Player
205+
- name: Build ${{ matrix.platform }} Player
201206
run: |
202-
docker exec unity dotnet msbuild /t:UnityConfigureSentryOptions /p:TestDsn=http://[email protected]:8000/12345 /p:Configuration=Release /p:OutDir=other src/Sentry.Unity
203-
docker exec unity dotnet msbuild /t:UnityBuildPlayerWebGL /p:Configuration=Release /p:OutDir=other src/Sentry.Unity
207+
$testDsnServer = If ("${{ matrix.platform }}" -eq "Android") {"10.0.2.2"} Else {"127.0.0.1"}
208+
docker exec unity dotnet msbuild /t:UnityConfigureSentryOptions /p:TestDsn=http://publickey@$testDsnServer:8000/12345 /p:Configuration=Release /p:OutDir=other src/Sentry.Unity
209+
docker exec unity dotnet msbuild /t:UnityBuildPlayer${{ matrix.platform }} /p:Configuration=Release /p:OutDir=other src/Sentry.Unity
204210
205-
- name: Upload WebGL Build
211+
- name: Upload test app for smoke test
206212
uses: actions/upload-artifact@v2
207213
with:
208-
name: testapp-webgl-${{ matrix.unity-version }}
209-
path: samples/artifacts/builds/WebGL
214+
name: testapp-${{ matrix.platform }}-${{ matrix.unity-version }}
215+
path: samples/artifacts/builds/${{ matrix.platform }}
210216
if-no-files-found: error
211217

212218
package-validation:
@@ -304,7 +310,7 @@ jobs:
304310
run: ./test/Scripts.Integration.Test/integration-run-smoke-test.ps1 -Crash
305311

306312
android-smoke-test:
307-
needs: [build]
313+
needs: [smoke-test-build]
308314
name: Run Android ${{ matrix.api-level }} Unity ${{ matrix.unity-version }} Smoke Test
309315
runs-on: macos-latest
310316
strategy:
@@ -326,7 +332,7 @@ jobs:
326332
- name: Download test app artifact
327333
uses: actions/download-artifact@v2
328334
with:
329-
name: testapp-android-${{ matrix.unity-version }}
335+
name: testapp-Android-${{ matrix.unity-version }}
330336
path: samples/artifacts/builds/Android
331337

332338
- name: Android emulator setup + Smoke test
@@ -387,6 +393,7 @@ jobs:
387393
path: samples/artifacts/builds/Android/screen.png
388394

389395
ios-smoke-test-build:
396+
needs: [build]
390397
name: Build iOS Unity ${{ matrix.unity-version }} Smoke Test
391398
runs-on: macos-latest
392399
strategy:
@@ -398,11 +405,10 @@ jobs:
398405
uses: actions/[email protected]
399406

400407
- name: Download XCode app artifact
401-
uses: vaind/download-artifact@989a39a417730897d098ab11c34e49ac4e13ed70
408+
uses: actions/download-artifact@v2
402409
with:
403410
name: testapp-ios-project-${{ matrix.unity-version }}
404411
path: samples/artifacts/builds/iOS/Xcode
405-
wait-timeout: 3600
406412

407413
- name: Build iOS package
408414
shell: pwsh
@@ -467,7 +473,7 @@ jobs:
467473
./Scripts/smoke-test-ios.ps1 Test "$runtime"
468474
469475
webgl-smoke-test:
470-
needs: [build]
476+
needs: [smoke-test-build]
471477
name: Run WebGL Unity ${{ matrix.unity-version }} Smoke Test
472478
runs-on: ubuntu-latest
473479
strategy:
@@ -481,7 +487,7 @@ jobs:
481487
- name: Download test app artifact
482488
uses: actions/download-artifact@v2
483489
with:
484-
name: testapp-webgl-${{ matrix.unity-version }}
490+
name: testapp-WebGL-${{ matrix.unity-version }}
485491
path: samples/artifacts/builds/WebGL
486492

487493
- run: pip3 install --upgrade --user selenium urllib3 requests

Directory.Build.targets

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,8 @@ Related: https://forum.unity.com/threads/6572-debugger-agent-unable-to-listen-on
232232
<Exec Command="pwsh &quot;$(RepoRoot)/test/Scripts.Integration.Test/integration-run-smoke-test.ps1&quot; -Smoke -Crash &quot;$(StandaloneExecutablePath)&quot; -AppDataDir &quot;$(StandaloneDataPath)&quot;" />
233233
</Target>
234234

235-
<!-- Build an Android player with IL2CPP: dotnet msbuild /t:UnityBuildPlayerAndroidIL2CPP src/Sentry.Unity -->
236-
<Target Name="UnityBuildPlayerAndroidIL2CPP" DependsOnTargets="FindUnity" Condition="'$(MSBuildProjectName)' == 'Sentry.Unity'">
235+
<!-- Build an Android player: dotnet msbuild /t:UnityBuildPlayerAndroid src/Sentry.Unity -->
236+
<Target Name="UnityBuildPlayerAndroid" DependsOnTargets="FindUnity" Condition="'$(MSBuildProjectName)' == 'Sentry.Unity'">
237237
<Error Condition="$(UnityRoot) == ''" Text="Couldn't find Unity."></Error>
238238

239239
<Message Importance="High" Text="Building Android Player with IL2CPP."></Message>

0 commit comments

Comments
 (0)