Skip to content

Commit eefe2d1

Browse files
ci(audience-sdk): add PlayMode test workflow [SDK-148]
Four-cell matrix builds the audience sample app and runs PlayMode tests inside the built player across both backends: - StandaloneWindows64 / IL2CPP / windows-latest / Unity 2021.3.45f2 - StandaloneWindows64 / Mono2x / windows-latest / Unity 2021.3.45f2 - StandaloneOSX / IL2CPP / macos-latest / Unity 2021.3.45f2 - StandaloneOSX / Mono2x / macos-latest / Unity 2021.3.45f2 Backend selection per cell goes through AUDIENCE_SCRIPTING_BACKEND env var consumed by the ScriptingBackendOverride Editor script. Notes: - Both targets use Windows / macOS hosts because game-ci can cross- build Windows IL2CPP players on Linux but the runner can't launch them to drive PlayMode tests; the host OS must match the player target. - Unity 2021.3.45f2 (not 2021.3.26f1 as originally planned) avoids a zlib-vs-macOS-15-SDK toolchain incompatibility that breaks the IL2CPP build under newer Xcode CLT (Unity zutil.h:147 macros fdopen to NULL, collides with stdio.h fdopen function declaration). - Tests live-fire to sandbox via AUDIENCE_TEST_PUBLISHABLE_KEY repo secret. Skipped on fork PRs to avoid secret leakage. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 7d72558 commit eefe2d1

6 files changed

Lines changed: 355 additions & 3 deletions

File tree

Lines changed: 204 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,204 @@
1+
name: Audience SDK — PlayMode (IL2CPP + Mono)
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- 'src/Packages/Audience/**'
7+
- 'examples/audience/**'
8+
- '.github/workflows/test-audience-sample-app.yml'
9+
workflow_dispatch:
10+
11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.ref }}
13+
cancel-in-progress: true
14+
15+
jobs:
16+
playmode:
17+
if: github.event.pull_request.head.repo.fork == false || github.event_name == 'workflow_dispatch'
18+
name: ${{ matrix.target }} / ${{ matrix.backend }} / Unity ${{ matrix.unity }}
19+
strategy:
20+
fail-fast: false
21+
matrix:
22+
include:
23+
- target: StandaloneWindows64
24+
backend: IL2CPP
25+
unity: 2021.3.45f2
26+
changeset: 88f88f591b2e
27+
runner: [self-hosted, Windows, X64]
28+
- target: StandaloneWindows64
29+
backend: Mono2x
30+
unity: 2021.3.45f2
31+
changeset: 88f88f591b2e
32+
runner: [self-hosted, Windows, X64]
33+
- target: StandaloneOSX
34+
backend: IL2CPP
35+
unity: 2021.3.45f2
36+
changeset: 88f88f591b2e
37+
runner: [self-hosted, macOS, ARM64]
38+
- target: StandaloneOSX
39+
backend: Mono2x
40+
unity: 2021.3.45f2
41+
changeset: 88f88f591b2e
42+
runner: [self-hosted, macOS, ARM64]
43+
runs-on: ${{ matrix.runner }}
44+
timeout-minutes: 60
45+
46+
steps:
47+
- uses: actions/checkout@v4
48+
with:
49+
lfs: true
50+
51+
- name: Cache Unity Library
52+
uses: actions/cache@v4
53+
with:
54+
path: examples/audience/Library
55+
key: Library-${{ matrix.backend }}-${{ matrix.target }}-${{ matrix.unity }}-${{ hashFiles('examples/audience/Assets/**', 'examples/audience/Packages/**', 'examples/audience/ProjectSettings/**', 'src/Packages/Audience/**') }}
56+
restore-keys: |
57+
Library-${{ matrix.backend }}-${{ matrix.target }}-${{ matrix.unity }}-
58+
Library-${{ matrix.backend }}-${{ matrix.target }}-
59+
60+
- name: Resolve Unity ${{ matrix.unity }} (macOS)
61+
if: runner.os == 'macOS'
62+
shell: bash
63+
env:
64+
UNITY_VER: ${{ matrix.unity }}
65+
UNITY_CS: ${{ matrix.changeset }}
66+
run: |
67+
set -uo pipefail
68+
HUB="/Applications/Unity Hub.app/Contents/MacOS/Unity Hub"
69+
70+
echo "::group::install editor"
71+
"$HUB" -- --headless install \
72+
--version "$UNITY_VER" --changeset "$UNITY_CS" --architecture arm64 \
73+
|| echo "(install non-zero — OK if 'Editor already installed in this location')"
74+
echo "::endgroup::"
75+
76+
echo "::group::install mac-il2cpp module"
77+
"$HUB" -- --headless install-modules \
78+
--version "$UNITY_VER" --changeset "$UNITY_CS" --architecture arm64 \
79+
--module mac-il2cpp \
80+
|| echo "(install-modules non-zero — OK if 'No modules found to install')"
81+
echo "::endgroup::"
82+
83+
EDITOR_APP=""
84+
for cand in \
85+
"/Applications/Unity/Hub/Editor/$UNITY_VER-arm64/Unity.app" \
86+
"/Applications/Unity/Hub/Editor/$UNITY_VER/Unity.app"; do
87+
if [ -x "$cand/Contents/MacOS/Unity" ]; then EDITOR_APP="$cand"; break; fi
88+
done
89+
90+
IL2CPP_DIR=""
91+
if [ -n "$EDITOR_APP" ]; then
92+
for d in \
93+
"$EDITOR_APP/Contents/PlaybackEngines/MacStandaloneSupport/Variations/macos_arm64_player_nondevelopment_il2cpp" \
94+
"$EDITOR_APP/Contents/PlaybackEngines/MacStandaloneSupport/Variations/macos_x64_player_nondevelopment_il2cpp"; do
95+
if [ -d "$d" ]; then IL2CPP_DIR="$d"; break; fi
96+
done
97+
fi
98+
99+
if [ -z "$EDITOR_APP" ] || [ -z "$IL2CPP_DIR" ]; then
100+
echo "::error::Unity $UNITY_VER + Mac-IL2CPP not present after install attempt"
101+
ls -la /Applications/Unity/Hub/Editor/ 2>&1 || true
102+
"$HUB" -- --headless editors --installed 2>&1 || true
103+
exit 1
104+
fi
105+
106+
echo "Found Unity: $EDITOR_APP/Contents/MacOS/Unity"
107+
echo "Found IL2CPP: $IL2CPP_DIR"
108+
echo "UNITY_PATH=$EDITOR_APP/Contents/MacOS/Unity" >> "$GITHUB_ENV"
109+
110+
- name: Resolve Unity ${{ matrix.unity }} (Windows)
111+
if: runner.os == 'Windows'
112+
shell: pwsh
113+
env:
114+
UNITY_VER: ${{ matrix.unity }}
115+
UNITY_CS: ${{ matrix.changeset }}
116+
run: |
117+
$hub = "C:\Program Files\Unity Hub\Unity Hub.exe"
118+
119+
Write-Host "::group::install editor"
120+
$installArgs = @('--','--headless','install','--version',$env:UNITY_VER,'--changeset',$env:UNITY_CS,'--architecture','x86_64')
121+
& $hub @installArgs 2>&1 | Write-Host
122+
if ($LASTEXITCODE -ne 0) { Write-Host "(install non-zero — OK if 'Editor already installed in this location')" }
123+
$global:LASTEXITCODE = 0
124+
Write-Host "::endgroup::"
125+
126+
Write-Host "::group::install windows-il2cpp module"
127+
$modArgs = @('--','--headless','install-modules','--version',$env:UNITY_VER,'--changeset',$env:UNITY_CS,'--architecture','x86_64','--module','windows-il2cpp')
128+
& $hub @modArgs 2>&1 | Write-Host
129+
if ($LASTEXITCODE -ne 0) { Write-Host "(install-modules non-zero — OK if 'No modules found to install')" }
130+
$global:LASTEXITCODE = 0
131+
Write-Host "::endgroup::"
132+
133+
$editor = "C:\Program Files\Unity\Hub\Editor\$env:UNITY_VER\Editor\Unity.exe"
134+
$il2cpp = "C:\Program Files\Unity\Hub\Editor\$env:UNITY_VER\Editor\Data\PlaybackEngines\windowsstandalonesupport\Variations\win64_player_nondevelopment_il2cpp"
135+
if (-not (Test-Path $editor) -or -not (Test-Path $il2cpp)) {
136+
Write-Host "::error::Unity $env:UNITY_VER + Windows-IL2CPP not present after install attempt"
137+
Get-ChildItem "C:\Program Files\Unity\Hub\Editor\" -ErrorAction SilentlyContinue | Format-Table
138+
& $hub -- --headless editors --installed
139+
exit 1
140+
}
141+
142+
Write-Host "Found Unity: $editor"
143+
Write-Host "Found IL2CPP: $il2cpp"
144+
"UNITY_PATH=$editor" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
145+
146+
- name: Run PlayMode tests (macOS)
147+
if: runner.os == 'macOS'
148+
shell: bash
149+
env:
150+
AUDIENCE_TEST_PUBLISHABLE_KEY: ${{ secrets.AUDIENCE_TEST_PUBLISHABLE_KEY }}
151+
AUDIENCE_SCRIPTING_BACKEND: ${{ matrix.backend }}
152+
run: |
153+
set -euo pipefail
154+
mkdir -p artifacts
155+
"$UNITY_PATH" \
156+
-batchmode -nographics \
157+
-projectPath examples/audience \
158+
-runTests \
159+
-testPlatform ${{ matrix.target }} \
160+
-testResults "$(pwd)/artifacts/test-results.xml" \
161+
-logFile -
162+
163+
- name: Run PlayMode tests (Windows)
164+
if: runner.os == 'Windows'
165+
shell: pwsh
166+
env:
167+
AUDIENCE_TEST_PUBLISHABLE_KEY: ${{ secrets.AUDIENCE_TEST_PUBLISHABLE_KEY }}
168+
AUDIENCE_SCRIPTING_BACKEND: ${{ matrix.backend }}
169+
run: |
170+
New-Item -ItemType Directory -Force -Path artifacts | Out-Null
171+
$logFile = "$pwd\artifacts\unity.log"
172+
$unityArgs = @(
173+
'-batchmode','-nographics',
174+
'-projectPath','examples/audience',
175+
'-runTests',
176+
'-testPlatform','${{ matrix.target }}',
177+
'-testResults',"$pwd\artifacts\test-results.xml",
178+
'-logFile',$logFile
179+
)
180+
Write-Host "Launching Unity: $env:UNITY_PATH $($unityArgs -join ' ')"
181+
$p = Start-Process -FilePath $env:UNITY_PATH -ArgumentList $unityArgs -Wait -PassThru -NoNewWindow
182+
$exit = $p.ExitCode
183+
Write-Host "::group::Unity log"
184+
Get-Content $logFile -ErrorAction SilentlyContinue | Write-Host
185+
Write-Host "::endgroup::"
186+
Write-Host "Unity exited with code $exit"
187+
if ($exit -ne 0 -and $exit -ne 2) { exit $exit }
188+
189+
- name: Publish test report
190+
uses: dorny/test-reporter@v3
191+
if: always()
192+
with:
193+
name: PlayMode (${{ matrix.backend }} / ${{ matrix.target }})
194+
path: artifacts/test-results.xml
195+
reporter: dotnet-nunit
196+
fail-on-error: false
197+
198+
- uses: actions/upload-artifact@v4
199+
if: always()
200+
with:
201+
name: playmode-${{ matrix.backend }}-${{ matrix.target }}-${{ matrix.unity }}
202+
path: |
203+
artifacts/test-results.xml
204+
examples/audience/Logs/**

examples/audience/Assets/SampleApp/Tests/Runtime/SampleAppLiveFireTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ public IEnumerator InitTrackFlush_AgainstSandbox_FlushReportsOk()
132132
}
133133

134134
[UnityTest]
135-
public IEnumerator TypedEvent_Progression_FlushReportsOk()
135+
public IEnumerator Event_Progression_FlushReportsOk()
136136
{
137137
// Progression's only required field is `status` (enum, defaults to "start").
138138
yield return DriveTypedEventAndFlush(SampleAppUi.Buttons.TypedEvent("progression"));

examples/audience/Packages/manifest.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"com.unity.test-framework": "1.1.33",
1010
"com.unity.textmeshpro": "3.0.6",
1111
"com.unity.timeline": "1.6.5",
12+
"com.unity.toolchain.macos-arm64-linux-x86_64": "2.0.5",
1213
"com.unity.ugui": "1.0.0",
1314
"com.unity.visualscripting": "1.9.4",
1415
"com.unity.modules.ai": "1.0.0",

examples/audience/Packages/packages-lock.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,22 @@
8080
"dependencies": {},
8181
"url": "https://packages.unity.com"
8282
},
83+
"com.unity.sysroot": {
84+
"version": "2.0.10",
85+
"depth": 1,
86+
"source": "registry",
87+
"dependencies": {},
88+
"url": "https://packages.unity.com"
89+
},
90+
"com.unity.sysroot.linux-x86_64": {
91+
"version": "2.0.9",
92+
"depth": 1,
93+
"source": "registry",
94+
"dependencies": {
95+
"com.unity.sysroot": "2.0.10"
96+
},
97+
"url": "https://packages.unity.com"
98+
},
8399
"com.unity.test-framework": {
84100
"version": "1.1.33",
85101
"depth": 0,
@@ -122,6 +138,16 @@
122138
},
123139
"url": "https://packages.unity.com"
124140
},
141+
"com.unity.toolchain.macos-arm64-linux-x86_64": {
142+
"version": "2.0.5",
143+
"depth": 0,
144+
"source": "registry",
145+
"dependencies": {
146+
"com.unity.sysroot": "2.0.10",
147+
"com.unity.sysroot.linux-x86_64": "2.0.9"
148+
},
149+
"url": "https://packages.unity.com"
150+
},
125151
"com.unity.ugui": {
126152
"version": "1.0.0",
127153
"depth": 0,

examples/audience/ProjectSettings/ProjectSettings.asset

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -632,12 +632,12 @@ PlayerSettings:
632632
PS4: 1
633633
PS5: 1
634634
Stadia: 1
635+
Standalone: 3
635636
WebGL: 1
636637
Windows Store Apps: 1
637638
XboxOne: 1
638639
iPhone: 1
639640
tvOS: 1
640-
Standalone: 3
641641
incrementalIl2cppBuild: {}
642642
suppressCommonWarnings: 1
643643
allowUnsafeCode: 0
@@ -727,7 +727,7 @@ PlayerSettings:
727727
framebufferDepthMemorylessMode: 0
728728
qualitySettingsNames: []
729729
projectName: audience
730-
organizationId:
730+
organizationId:
731731
cloudEnabled: 0
732732
legacyClampBlendShapeWeights: 0
733733
playerDataPath:

0 commit comments

Comments
 (0)