Skip to content

Commit 0dcf9f1

Browse files
feat(audience): track GitHub-assigned job ID alongside run + cell IDs
Adds AUDIENCE_TEST_JOB_ID. Resolved per cell via the GitHub REST API in a new "Resolve job ID" workflow step (actions/github-script, non-blocking). Stamped into Player.log via LogCiBuildInfo and onto the audience_ci_test_marker event so a CDP record can deep-link to its cell with: https://github.com/{repo}/actions/runs/{run_id}/job/{job_id} playmode-linux.sh forwards the env into the docker container so the Linux player sees it the same way Windows and macOS do.
1 parent e68a7f2 commit 0dcf9f1

4 files changed

Lines changed: 34 additions & 3 deletions

File tree

.github/scripts/audience/playmode-linux.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ docker run --rm \
2020
--workdir /github/workspace \
2121
--env UNITY_EMAIL --env UNITY_PASSWORD --env UNITY_SERIAL \
2222
--env AUDIENCE_TEST_PUBLISHABLE_KEY --env AUDIENCE_SCRIPTING_BACKEND \
23-
--env AUDIENCE_TEST_RUN_ID --env AUDIENCE_TEST_CELL_ID \
23+
--env AUDIENCE_TEST_RUN_ID --env AUDIENCE_TEST_CELL_ID --env AUDIENCE_TEST_JOB_ID \
2424
--volume "$PWD":/github/workspace:z \
2525
--cpus=8 --memory=30487m \
2626
"unityci/editor:ubuntu-${UNITY_VERSION}-linux-il2cpp-3" \

.github/workflows/test-audience-sample-app.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,34 @@ jobs:
8686
Library-${{ matrix.backend }}-${{ matrix.platform.target }}-${{ matrix.unity.version }}-
8787
Library-${{ matrix.backend }}-${{ matrix.platform.target }}-
8888
89+
- name: Resolve job ID
90+
# Resolves the GitHub-assigned numeric job ID for the current cell so
91+
# the player can stamp it into Player.log and CDP rows. Lets a CDP
92+
# event link straight to the cell's GHA log via the canonical URL
93+
# https://github.com/{repo}/actions/runs/{run_id}/job/{job_id}.
94+
# Non-blocking: if the API call fails, AUDIENCE_TEST_JOB_ID stays unset.
95+
continue-on-error: true
96+
uses: actions/github-script@v7
97+
env:
98+
JOB_NAME: ${{ matrix.platform.target }} / ${{ matrix.backend }} / Unity ${{ matrix.unity.version }}
99+
with:
100+
script: |
101+
const jobs = await github.paginate(
102+
github.rest.actions.listJobsForWorkflowRunAttempt,
103+
{
104+
owner: context.repo.owner,
105+
repo: context.repo.repo,
106+
run_id: context.runId,
107+
attempt_number: context.runAttempt,
108+
}
109+
);
110+
const job = jobs.find(j => j.name === process.env.JOB_NAME);
111+
if (!job) {
112+
core.warning(`No job matching name="${process.env.JOB_NAME}"`);
113+
return;
114+
}
115+
core.exportVariable('AUDIENCE_TEST_JOB_ID', String(job.id));
116+
89117
- name: Detect or Install Unity (Windows + macOS only)
90118
if: matrix.platform.install_unity_script != ''
91119
env:

examples/audience/Assets/SampleApp/Scripts/AudienceSample.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,16 @@ public sealed partial class AudienceSample : MonoBehaviour
3838

3939
// ---- Lifecycle ----
4040

41-
// Logs CI build info (buildGuid, runId, cellId) to Player.log on player startup. CI-only.
41+
// Logs CI build info (buildGuid, runId, cellId, jobId) to Player.log on player startup. CI-only.
4242
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
4343
private static void LogCiBuildInfo()
4444
{
4545
var runId = Environment.GetEnvironmentVariable("AUDIENCE_TEST_RUN_ID") ?? string.Empty;
4646
var cellId = Environment.GetEnvironmentVariable("AUDIENCE_TEST_CELL_ID") ?? string.Empty;
47+
var jobId = Environment.GetEnvironmentVariable("AUDIENCE_TEST_JOB_ID") ?? string.Empty;
4748
if (string.IsNullOrEmpty(runId) && string.IsNullOrEmpty(cellId)) return;
4849
UnityEngine.Debug.Log(
49-
$"[CI] buildGuid={Application.buildGUID} runId={runId} cellId={cellId}");
50+
$"[CI] buildGuid={Application.buildGUID} runId={runId} cellId={cellId} jobId={jobId}");
5051
}
5152

5253
private void Awake()

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ public IEnumerator AudienceCiTestMarker_EmitsRunMetadata()
138138
{
139139
var runId = Environment.GetEnvironmentVariable("AUDIENCE_TEST_RUN_ID");
140140
var cellId = Environment.GetEnvironmentVariable("AUDIENCE_TEST_CELL_ID");
141+
var jobId = Environment.GetEnvironmentVariable("AUDIENCE_TEST_JOB_ID");
141142
if (string.IsNullOrEmpty(runId) && string.IsNullOrEmpty(cellId))
142143
{
143144
Assert.Ignore("Not running in CI.");
@@ -151,6 +152,7 @@ public IEnumerator AudienceCiTestMarker_EmitsRunMetadata()
151152
["source"] = "ci",
152153
["ciRunId"] = runId ?? string.Empty,
153154
["ciCellId"] = cellId ?? string.Empty,
155+
["ciJobId"] = jobId ?? string.Empty,
154156
});
155157

156158
yield return null;

0 commit comments

Comments
 (0)