Skip to content

Commit 7d89eea

Browse files
committed
ci(audience): run Unity-dependent SDK tests via dedicated workflow (SDK-326)
The Unity-dependent test asmdefs in the Audience package were never discovered by CI: test-audience-sdk.yml runs dotnet test (csproj excludes Tests/Runtime/Unity/** + Tests/Editor/**), and test-audience-sample-app.yml runs Unity Test Runner against examples/audience but the project's manifest.json had no testables entry, so Immutable.Audience.Runtime.Tests was never compiled by Unity. As a result DeviceCollectorTests shipped with two compile errors (missing InternalsVisibleTo + a broken 'is not string s' pattern) that no PR caught. Closes the gap with: * New test-audience-sdk-unity.yml — single GameCI Linux cell, Unity 2022.3 with iOS module so UnityEditor.iOS.Xcode + UNITY_IOS resolve. Single cell on purpose; these tests don't vary by Unity LTS / backend / OS. * testables entry in examples/audience/Packages/manifest.json so Unity Test Runner discovers the package's test asmdefs. * InternalsVisibleTo on Immutable.Audience.Unity for the test asmdef so DeviceCollectorTests can see internal types. * Fix the 'is not string s' pattern: the negated form doesn't bind s, so CS0165 fired on s.Length once compilation actually ran.
1 parent e6abbbd commit 7d89eea

5 files changed

Lines changed: 96 additions & 2 deletions

File tree

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: Audience package — Unity Tests
2+
3+
# Sibling to test-audience-sdk.yml. That workflow runs pure-C# unit tests via
4+
# `dotnet test` on Ubuntu (~1 min) but its csproj excludes anything that
5+
# references UnityEngine/UnityEditor/UnityEditor.iOS.Xcode. This workflow picks
6+
# up exactly the tests that get excluded — DeviceCollector / IDFVBridge /
7+
# InstallReferrerBridge / iOSInfoPlistPostProcessor — by booting Unity Test
8+
# Runner against the sample app project.
9+
#
10+
# Single matrix cell on purpose: these tests exercise platform-agnostic SDK
11+
# logic that happens to use Unity types. They don't vary across Unity LTS,
12+
# scripting backend, or OS, so spending a multi-cell matrix on them would
13+
# burn CI minutes for zero added signal. The cross-version IL2CPP build
14+
# matrix lives in test-audience-sample-app.yml.
15+
#
16+
# iOS targetPlatform is non-negotiable: the iOSInfoPlistPostProcessor tests
17+
# reference UnityEditor.iOS.Xcode (Apple's PlistDocument API) which only ships
18+
# in the iOS GameCI image. Without it the test asmdef silently fails to
19+
# compile — which is the exact CI gap this workflow is here to close.
20+
21+
on:
22+
push:
23+
branches: [main]
24+
paths:
25+
- 'src/Packages/Audience/**'
26+
- 'examples/audience/Packages/manifest.json'
27+
- '.github/workflows/test-audience-sdk-unity.yml'
28+
pull_request:
29+
paths:
30+
- 'src/Packages/Audience/**'
31+
- 'examples/audience/Packages/manifest.json'
32+
- '.github/workflows/test-audience-sdk-unity.yml'
33+
34+
jobs:
35+
editmode:
36+
if: github.event.pull_request.head.repo.fork == false || github.event_name == 'workflow_dispatch'
37+
name: EditMode (Unity 2022.3 / iOS module)
38+
runs-on: ubuntu-latest-8-cores
39+
40+
steps:
41+
- uses: actions/checkout@v4
42+
with:
43+
lfs: true
44+
45+
- uses: actions/cache@v4
46+
with:
47+
path: examples/audience/Library
48+
key: Library-audience-unity-tests-${{ hashFiles('examples/audience/Packages/**', 'examples/audience/ProjectSettings/**', 'src/Packages/Audience/**') }}
49+
restore-keys: |
50+
Library-audience-unity-tests-
51+
52+
- uses: game-ci/unity-test-runner@v4
53+
env:
54+
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
55+
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
56+
UNITY_SERIAL: ${{ secrets.UNITY_SERIAL }}
57+
with:
58+
# Pinned to the same Unity version the mobile-build matrix uses so
59+
# the GameCI image is shared across workflows (less cache churn).
60+
unityVersion: 2022.3.62f2
61+
# iOS image needed for UnityEditor.iOS.Xcode + UNITY_IOS define.
62+
targetPlatform: iOS
63+
projectPath: examples/audience
64+
testMode: editmode
65+
# Limit test discovery to the Audience package's own asmdefs. The
66+
# sample app's PlayMode integration tests run in
67+
# test-audience-sample-app.yml; running them here would duplicate.
68+
customParameters: -assemblyNames Immutable.Audience.Runtime.Tests;Immutable.Audience.Editor.Tests
69+
checkName: Audience EditMode Tests
70+
artifactsPath: artifacts
71+
72+
- uses: actions/upload-artifact@v4
73+
if: always()
74+
with:
75+
name: audience-unity-test-results
76+
path: artifacts

examples/audience/Packages/manifest.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,8 @@
3737
"com.unity.modules.vr": "1.0.0",
3838
"com.unity.modules.wind": "1.0.0",
3939
"com.unity.modules.xr": "1.0.0"
40-
}
40+
},
41+
"testables": [
42+
"com.immutable.audience"
43+
]
4144
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
using System.Runtime.CompilerServices;
2+
3+
[assembly: InternalsVisibleTo("Immutable.Audience.Runtime.Tests")]

src/Packages/Audience/Runtime/Unity/AssemblyInfo.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Packages/Audience/Tests/Runtime/Unity/DeviceCollectorTests.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ public void CollectGameLaunchProperties_StringFields_DoNotExceed256Chars()
6868
"platform", "version", "buildGuid", "unityVersion",
6969
"osFamily", "deviceModel", "gpu", "gpuVendor", "cpu" })
7070
{
71-
if (!props.TryGetValue(key, out var val) || val is not string s) continue;
71+
if (!props.TryGetValue(key, out var val)) continue;
72+
if (val is not string s) continue;
7273
Assert.LessOrEqual(s.Length, 256, $"props[{key}] exceeds 256 chars");
7374
}
7475
}

0 commit comments

Comments
 (0)