Skip to content

Commit a2e46dd

Browse files
authored
chore: Utilize app-runner for WebGL (#2572)
1 parent 576188e commit a2e46dd

10 files changed

Lines changed: 441 additions & 251 deletions

File tree

.github/workflows/ci.yml

Lines changed: 10 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,10 @@ jobs:
189189
run: ./test/Scripts.Integration.Test/add-sentry.ps1 -UnityPath "$env:UNITY_PATH" -PackagePath "test-package-release"
190190

191191
- name: Configure Sentry
192-
run: ./test/Scripts.Integration.Test/configure-sentry.ps1 -UnityPath "$env:UNITY_PATH" -Platform "$env:BUILD_PLATFORM" -CheckSymbols
192+
run: ./test/Scripts.Integration.Test/configure-sentry.ps1 -UnityPath "$env:UNITY_PATH" -Platform "$env:BUILD_PLATFORM" -CheckSymbols -TestMode "integration"
193193
env:
194194
BUILD_PLATFORM: ${{ matrix.build_platform }}
195+
SENTRY_DSN: ${{ secrets.SENTRY_TEST_DSN }}
195196

196197
- name: Build Project
197198
run: ./test/Scripts.Integration.Test/build-project.ps1 -UnityPath "$env:UNITY_PATH" -Platform "$env:BUILD_PLATFORM" -CheckSymbols:$([System.Convert]::ToBoolean($env:CHECK_SYMBOLS)) -UnityVersion "$env:UNITY_VERSION"
@@ -219,15 +220,14 @@ jobs:
219220
run: |
220221
# Note: remove local.properties file that contains Android SDK & NDK paths in the Unity installation.
221222
rm -rf samples/IntegrationTest/Build/*_BackUpThisFolder_ButDontShipItWithYourGame
222-
tar -cvzf test-app-runtime.tar.gz samples/IntegrationTest/Build
223+
tar -cvzf test-app-webgl.tar.gz samples/IntegrationTest/Build
223224
224-
# Upload runtime initialization build
225225
- name: Upload test app
226226
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
227227
with:
228-
name: testapp-${{ matrix.platform }}-${{ matrix.unity-version }}-runtime
228+
name: testapp-webgl-compiled-${{ matrix.unity-version }}
229229
if-no-files-found: error
230-
path: test-app-runtime.tar.gz
230+
path: test-app-webgl.tar.gz
231231
retention-days: 14
232232

233233
- name: Upload IntegrationTest project on failure
@@ -325,33 +325,17 @@ jobs:
325325
# - https://github.com/actions/runner-images/blob/main/images/macos/macos-14-Readme.md
326326

327327
smoke-test-run-webgl:
328-
name: Run ${{ matrix.platform }} ${{ matrix.unity-version }} Smoke Test
328+
name: Run WebGL ${{ matrix.unity-version }} Integration Test
329329
if: ${{ !startsWith(github.ref, 'refs/heads/release/') }}
330330
needs: [smoke-test-build-webgl, create-unity-matrix]
331-
runs-on: ubuntu-latest
331+
secrets: inherit
332332
strategy:
333333
fail-fast: false
334334
matrix:
335335
unity-version: ${{ fromJSON(needs.create-unity-matrix.outputs.unity-matrix).unity-version }}
336-
platform: ["WebGL"]
337-
steps:
338-
- name: Checkout
339-
uses: actions/checkout@v3
340-
341-
- name: Download test app artifact
342-
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
343-
id: download
344-
with:
345-
name: testapp-${{ matrix.platform }}-${{ matrix.unity-version }}-runtime
346-
347-
- name: Extract test app
348-
run: tar -xvzf test-app-runtime.tar.gz
349-
350-
- name: Run (WebGL)
351-
timeout-minutes: 10
352-
run: |
353-
pip3 install --upgrade --user selenium urllib3 requests
354-
python3 scripts/smoke-test-webgl.py "samples/IntegrationTest/Build"
336+
uses: ./.github/workflows/smoke-test-run-webgl.yml
337+
with:
338+
unity-version: ${{ matrix.unity-version }}
355339

356340
smoke-test-build-linux:
357341
name: Build Linux ${{ matrix.unity-version }} Integration Test
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: "IntegrationTest: Run WebGL"
2+
on:
3+
workflow_call:
4+
inputs:
5+
unity-version:
6+
required: true
7+
type: string
8+
9+
defaults:
10+
run:
11+
shell: pwsh
12+
13+
jobs:
14+
run:
15+
name: WebGL ${{ inputs.unity-version }}
16+
runs-on: ubuntu-latest
17+
env:
18+
SENTRY_TEST_DSN: ${{ secrets.SENTRY_TEST_DSN }}
19+
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
20+
21+
steps:
22+
- name: Checkout
23+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
24+
25+
- name: Initialize app-runner submodule
26+
run: git submodule update --init modules/app-runner
27+
shell: bash
28+
29+
- name: Download test app artifact
30+
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
31+
with:
32+
name: testapp-webgl-compiled-${{ inputs.unity-version }}
33+
34+
- name: Extract test app
35+
run: tar -xvzf test-app-webgl.tar.gz
36+
37+
- name: Install Selenium
38+
run: pip3 install --upgrade selenium
39+
shell: bash
40+
41+
- name: Run Integration Tests
42+
timeout-minutes: 20
43+
run: |
44+
$env:SENTRY_WEBGL_BUILD_PATH = "samples/IntegrationTest/Build"
45+
Invoke-Pester -Path test/IntegrationTest/Integration.Tests.WebGL.ps1 -CI
46+
47+
- name: Upload test results on failure
48+
if: ${{ failure() }}
49+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
50+
with:
51+
name: testapp-webgl-logs-${{ inputs.unity-version }}
52+
path: |
53+
test/IntegrationTest/results/
54+
retention-days: 14

Directory.Build.targets

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ Related: https://forum.unity.com/threads/6572-debugger-agent-unable-to-listen-on
386386

387387
<!-- Run smoke test on the WebGL player: dotnet msbuild /t:UnitySmokeTestPlayerWebGL src/Sentry.Unity -->
388388
<Target Name="UnitySmokeTestPlayerWebGL" Condition="'$(MSBuildProjectName)' == 'Sentry.Unity'">
389-
<Exec Command="python3 -X utf8 &quot;$(RepoRoot)scripts/smoke-test-webgl.py&quot;" IgnoreStandardErrorWarningFormat="true"/>
389+
<Exec Command="pwsh -Command &quot;Invoke-Pester -Path '$(RepoRoot)test/IntegrationTest/Integration.Tests.WebGL.ps1' -CI&quot;" IgnoreStandardErrorWarningFormat="true"/>
390390
</Target>
391391

392392
<!-- Run PlayMode tests with dotnet msbuild /t:UnityPlayModeTest test/Sentry.Unity.Tests -->

scripts/smoke-test-webgl.py

Lines changed: 0 additions & 216 deletions
This file was deleted.

src/Sentry.Unity/UnityWebRequestTransport.cs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ internal class WebBackgroundWorker : IBackgroundWorker
1515
{
1616
private readonly SentryMonoBehaviour _behaviour;
1717
private readonly UnityWebRequestTransport _transport;
18+
private int _pendingItems;
1819

1920
public WebBackgroundWorker(SentryUnityOptions options, SentryMonoBehaviour behaviour)
2021
{
@@ -24,13 +25,26 @@ public WebBackgroundWorker(SentryUnityOptions options, SentryMonoBehaviour behav
2425

2526
public bool EnqueueEnvelope(Envelope envelope)
2627
{
27-
_behaviour.QueueCoroutine(_transport.SendEnvelopeAsync(envelope));
28+
_pendingItems++;
29+
_behaviour.QueueCoroutine(SendAndTrack(envelope));
2830
return true;
2931
}
3032

33+
private IEnumerator SendAndTrack(Envelope envelope)
34+
{
35+
try
36+
{
37+
yield return _transport.SendEnvelopeAsync(envelope);
38+
}
39+
finally
40+
{
41+
_pendingItems--;
42+
}
43+
}
44+
3145
public Task FlushAsync(TimeSpan timeout) => Task.CompletedTask;
3246

33-
public int QueuedItems { get; }
47+
public int QueuedItems => _pendingItems;
3448
}
3549

3650
internal class UnityWebRequestTransport : HttpTransportBase

test/IntegrationTest/CommonTestCases.ps1

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,11 @@ $CommonTestCases = @(
100100
@{ Name = "Contains OS context"; TestBlock = {
101101
param($TestSetup, $TestType, $SentryEvent, $RunResult)
102102
$SentryEvent.contexts.os | Should -Not -BeNullOrEmpty
103+
104+
if ($TestSetup.Platform -eq "WebGL") {
105+
Set-ItResult -Skipped -Because "OS name is not available in the browser sandbox"
106+
return
107+
}
103108
$SentryEvent.contexts.os.name | Should -Not -BeNullOrEmpty
104109
}
105110
}

0 commit comments

Comments
 (0)