Skip to content

Commit 156b0b8

Browse files
ci(audience): route all matrix jobs through set-matrix, harden Windows checkout (SDK-330)
- Replaces the cross-product matrix (unity x target x backend with axis-matching include items) on `playmode` with a `set-matrix` helper job that emits a fully-specified JSON matrix. - The cross-product approach silently expanded to zero playmode cells on every run since SDK-327, so Windows and macOS PlayMode tests have not actually run on PRs (verified on the SDK-327 merge commit and on PR #748). Root cause: a unity-keyed include item that has no cell to augment after the conditional `exclude` removes Unity 2022 on PR runs spawns an orphan combination missing `target`, `backend`, and `runner`; `runs-on: ${{ matrix.runner }}` then evaluates to empty and GitHub aborts the matrix. - `set-matrix` runs on ubuntu-latest, defines the full 12-cell playmode matrix, 6-cell playmode-linux matrix and 6-cell mobile matrix inline as JSON, and uses jq to strip Unity 2022.3.62f2 cells when the trigger is pull_request. Schedule and workflow_dispatch get the full sets. - All three matrix-driven jobs now declare `needs: set-matrix` and consume `matrix.include: fromJSON(needs.set-matrix.outputs.<key>)`. Each cell carries every key the steps need, so no axis-match augmentation step can silently drop keys, and the workflow graph shows all three jobs hanging off set-matrix in one place. - `mobile-build` PR runs drop Unity 2022.3.62f2 to match the playmode and playmode-linux trim. Schedule and workflow_dispatch keep all 3 Unity versions. Steps unchanged. - `playmode-linux` matrix moved from cross-product + conditional exclude to the same set-matrix-fed include pattern. Same 6 cells on schedule, same 4 cells on PR; behaviour unchanged. - Hardens the Windows pre-checkout cleanup. The previous Kill-stale step only covered Unity-family processes and slept 2 seconds, then handed off to actions/checkout@v4 which would die with EBUSY on stuck files in examples/audience. New step adds bee_backend and mono to the kill list, sleeps 3 seconds, and force-removes the workspace contents in a retry loop so checkout's own cleanup is left with nothing to do. Linear: https://linear.app/imtbl/issue/SDK-330 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 1c83cbc commit 156b0b8

1 file changed

Lines changed: 90 additions & 37 deletions

File tree

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

Lines changed: 90 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,67 @@ concurrency:
2626
cancel-in-progress: true
2727

2828
jobs:
29-
# Reduced matrix on pull_request, full matrix on schedule and
30-
# workflow_dispatch. The self-hosted Windows runner pool is small, so
31-
# trimming PR cells keeps PR feedback fast. `matrix.exclude` below is
32-
# the source of truth for which cells are dropped on pull_request.
29+
# The playmode, playmode-linux and mobile-build matrices are built here
30+
# and consumed by the dependent jobs via fromJSON. PR runs trim Unity
31+
# 2022.3.62f2 cells; schedule and workflow_dispatch run the full set.
32+
set-matrix:
33+
runs-on: ubuntu-latest
34+
outputs:
35+
playmode: ${{ steps.set.outputs.playmode }}
36+
playmode_linux: ${{ steps.set.outputs.playmode_linux }}
37+
mobile: ${{ steps.set.outputs.mobile }}
38+
steps:
39+
- id: set
40+
shell: bash
41+
run: |
42+
playmode_full='[
43+
{"target":"StandaloneWindows64","backend":"IL2CPP","unity":"2021.3.45f2","changeset":"88f88f591b2e","runner":["self-hosted","Windows","X64"]},
44+
{"target":"StandaloneWindows64","backend":"Mono2x","unity":"2021.3.45f2","changeset":"88f88f591b2e","runner":["self-hosted","Windows","X64"]},
45+
{"target":"StandaloneOSX","backend":"IL2CPP","unity":"2021.3.45f2","changeset":"88f88f591b2e","runner":["self-hosted","macOS","ARM64"]},
46+
{"target":"StandaloneOSX","backend":"Mono2x","unity":"2021.3.45f2","changeset":"88f88f591b2e","runner":["self-hosted","macOS","ARM64"]},
47+
{"target":"StandaloneWindows64","backend":"IL2CPP","unity":"6000.4.0f1","changeset":"8cf496087c8f","runner":["self-hosted","Windows","X64"]},
48+
{"target":"StandaloneWindows64","backend":"Mono2x","unity":"6000.4.0f1","changeset":"8cf496087c8f","runner":["self-hosted","Windows","X64"]},
49+
{"target":"StandaloneOSX","backend":"IL2CPP","unity":"6000.4.0f1","changeset":"8cf496087c8f","runner":["self-hosted","macOS","ARM64"]},
50+
{"target":"StandaloneOSX","backend":"Mono2x","unity":"6000.4.0f1","changeset":"8cf496087c8f","runner":["self-hosted","macOS","ARM64"]},
51+
{"target":"StandaloneWindows64","backend":"IL2CPP","unity":"2022.3.62f2","changeset":"7670c08855a9","runner":["self-hosted","Windows","X64"]},
52+
{"target":"StandaloneWindows64","backend":"Mono2x","unity":"2022.3.62f2","changeset":"7670c08855a9","runner":["self-hosted","Windows","X64"]},
53+
{"target":"StandaloneOSX","backend":"IL2CPP","unity":"2022.3.62f2","changeset":"7670c08855a9","runner":["self-hosted","macOS","ARM64"]},
54+
{"target":"StandaloneOSX","backend":"Mono2x","unity":"2022.3.62f2","changeset":"7670c08855a9","runner":["self-hosted","macOS","ARM64"]}
55+
]'
56+
playmode_linux_full='[
57+
{"target":"StandaloneLinux64","backend":"IL2CPP","unity":"2021.3.45f2"},
58+
{"target":"StandaloneLinux64","backend":"Mono2x","unity":"2021.3.45f2"},
59+
{"target":"StandaloneLinux64","backend":"IL2CPP","unity":"6000.4.0f1"},
60+
{"target":"StandaloneLinux64","backend":"Mono2x","unity":"6000.4.0f1"},
61+
{"target":"StandaloneLinux64","backend":"IL2CPP","unity":"2022.3.62f2"},
62+
{"target":"StandaloneLinux64","backend":"Mono2x","unity":"2022.3.62f2"}
63+
]'
64+
mobile_full='[
65+
{"target":"Android","unity":"2021.3.45f2","method":"AndroidBuilder.Build"},
66+
{"target":"Android","unity":"2022.3.62f2","method":"AndroidBuilder.Build"},
67+
{"target":"Android","unity":"6000.4.0f1","method":"AndroidBuilder.Build"},
68+
{"target":"iOS","unity":"2021.3.45f2","method":"IosBuilder.Build"},
69+
{"target":"iOS","unity":"2022.3.62f2","method":"IosBuilder.Build"},
70+
{"target":"iOS","unity":"6000.4.0f1","method":"IosBuilder.Build"}
71+
]'
72+
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
73+
filter='[.[] | select(.unity != "2022.3.62f2")]'
74+
playmode=$(jq -c "$filter" <<<"$playmode_full")
75+
playmode_linux=$(jq -c "$filter" <<<"$playmode_linux_full")
76+
mobile=$(jq -c "$filter" <<<"$mobile_full")
77+
else
78+
playmode=$(jq -c '.' <<<"$playmode_full")
79+
playmode_linux=$(jq -c '.' <<<"$playmode_linux_full")
80+
mobile=$(jq -c '.' <<<"$mobile_full")
81+
fi
82+
{
83+
echo "playmode=$playmode"
84+
echo "playmode_linux=$playmode_linux"
85+
echo "mobile=$mobile"
86+
} >> "$GITHUB_OUTPUT"
87+
3388
playmode:
89+
needs: set-matrix
3490
if: |
3591
(github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == false)
3692
|| github.event_name == 'schedule'
@@ -39,21 +95,7 @@ jobs:
3995
strategy:
4096
fail-fast: false
4197
matrix:
42-
unity: ['2021.3.45f2', '6000.4.0f1', '2022.3.62f2']
43-
target: [StandaloneWindows64, StandaloneOSX]
44-
backend: [IL2CPP, Mono2x]
45-
include:
46-
- unity: '2021.3.45f2'
47-
changeset: 88f88f591b2e
48-
- unity: '6000.4.0f1'
49-
changeset: 8cf496087c8f
50-
- unity: '2022.3.62f2'
51-
changeset: 7670c08855a9
52-
- target: StandaloneWindows64
53-
runner: [self-hosted, Windows, X64]
54-
- target: StandaloneOSX
55-
runner: [self-hosted, macOS, ARM64]
56-
exclude: ${{ fromJSON(github.event_name == 'pull_request' && '[{"unity":"2022.3.62f2"}]' || '[]') }}
98+
include: ${{ fromJSON(needs.set-matrix.outputs.playmode) }}
5799
runs-on: ${{ matrix.runner }}
58100
# Healthy cells finish in ~10 min. 30 min covers cold caches +
59101
# IL2CPP + Unity 6 startup; anything past that is a hang. Capping
@@ -62,25 +104,43 @@ jobs:
62104
timeout-minutes: 30
63105

64106
steps:
65-
- name: Kill stale Unity processes (Windows pre-checkout)
107+
- name: Clean Windows workspace (pre-checkout)
66108
if: runner.os == 'Windows'
67109
shell: pwsh
68110
continue-on-error: true
69111
run: |
70-
# actions/checkout@v4 deletes the prior workspace before cloning. If a
71-
# previous run's Unity Editor / IL2CPP build process is still holding
72-
# handles inside examples/audience, checkout dies with EBUSY. Kill any
73-
# leftover Unity-family process here so checkout's cleanup succeeds.
112+
# actions/checkout@v4 removes the prior workspace before cloning. If
113+
# a previous run's Unity build / IL2CPP linker / bee_backend / shader
114+
# compiler is still holding handles, checkout dies with EBUSY on
115+
# examples/audience. Kill known offenders, then force-remove the
116+
# workspace contents ourselves so checkout's cleanup succeeds.
74117
Get-Process | Where-Object {
75118
$_.Name -like 'Unity*' -or
76119
$_.Name -like 'il2cpp*' -or
77120
$_.Name -like 'UnityShaderCompiler*' -or
78-
$_.Name -like 'UnityCrashHandler*'
121+
$_.Name -like 'UnityCrashHandler*' -or
122+
$_.Name -like 'bee_backend*' -or
123+
$_.Name -like 'mono*'
79124
} | ForEach-Object {
80125
Write-Host "Killing stale process: $($_.Name) (pid $($_.Id))"
81126
Stop-Process -Id $_.Id -Force -ErrorAction SilentlyContinue
82127
}
83-
Start-Sleep -Seconds 2
128+
Start-Sleep -Seconds 3
129+
130+
$ws = "$env:GITHUB_WORKSPACE"
131+
if (-not (Test-Path $ws)) { return }
132+
for ($i = 1; $i -le 6; $i++) {
133+
try {
134+
Get-ChildItem -Path $ws -Force -ErrorAction Stop |
135+
Remove-Item -Recurse -Force -ErrorAction Stop
136+
Write-Host "Cleaned $ws on attempt ${i}"
137+
return
138+
} catch {
139+
Write-Host "Attempt ${i}: $($_.Exception.Message)"
140+
Start-Sleep -Seconds 3
141+
}
142+
}
143+
Write-Host "::warning::Workspace not fully cleaned; checkout may fail"
84144
85145
- uses: actions/checkout@v4
86146
with:
@@ -406,6 +466,7 @@ jobs:
406466
examples/audience/Logs/**
407467
408468
playmode-linux:
469+
needs: set-matrix
409470
if: |
410471
(github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == false)
411472
|| github.event_name == 'schedule'
@@ -415,10 +476,7 @@ jobs:
415476
strategy:
416477
fail-fast: false
417478
matrix:
418-
unity: ['2021.3.45f2', '6000.4.0f1', '2022.3.62f2']
419-
target: [StandaloneLinux64]
420-
backend: [IL2CPP, Mono2x]
421-
exclude: ${{ fromJSON(github.event_name == 'pull_request' && '[{"unity":"2022.3.62f2"}]' || '[]') }}
479+
include: ${{ fromJSON(needs.set-matrix.outputs.playmode_linux) }}
422480

423481
steps:
424482
- uses: actions/checkout@v4
@@ -468,6 +526,7 @@ jobs:
468526
# Scope: IL2CPP compile pipeline only. Runtime tests require a real device and
469527
# are out of scope until a device farm is available.
470528
mobile-build:
529+
needs: set-matrix
471530
if: |
472531
(github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == false)
473532
|| github.event_name == 'schedule'
@@ -477,13 +536,7 @@ jobs:
477536
strategy:
478537
fail-fast: false
479538
matrix:
480-
target: [Android, iOS]
481-
unity: ['2021.3.45f2', '2022.3.62f2', '6000.4.0f1']
482-
include:
483-
- target: Android
484-
method: AndroidBuilder.Build
485-
- target: iOS
486-
method: IosBuilder.Build
539+
include: ${{ fromJSON(needs.set-matrix.outputs.mobile) }}
487540

488541
steps:
489542
- uses: actions/checkout@v4

0 commit comments

Comments
 (0)