Skip to content

Commit 8178208

Browse files
authored
chore: update setup-unity and run macOS e2e tests (#2673)
1 parent f646aa9 commit 8178208

10 files changed

Lines changed: 208 additions & 40 deletions

File tree

.github/workflows/build.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ jobs:
4343

4444
- name: Load env
4545
id: env
46-
run: echo "unityVersion=$(./scripts/ci-env.ps1 "$env:UNITY_SCRIPT_ARG")" >> $env:GITHUB_OUTPUT
47-
env:
48-
UNITY_SCRIPT_ARG: unity${{ env.UNITY_VERSION }}
46+
run: |
47+
$v = (Get-Content scripts/unity-versions.json -Raw | ConvertFrom-Json).'${{ env.UNITY_VERSION }}'.version
48+
"unityVersion=$v" >> $env:GITHUB_OUTPUT
4949
5050
- name: Cache Unity Library
5151
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5

.github/workflows/ci.yml

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,19 @@ jobs:
379379
with:
380380
unity-version: ${{ matrix.unity-version }}
381381

382+
test-build-macos:
383+
name: Build macOS ${{ matrix.unity-version }} Integration Test
384+
if: ${{ !startsWith(github.ref, 'refs/heads/release/') }}
385+
needs: [test-create, create-unity-matrix]
386+
secrets: inherit
387+
strategy:
388+
fail-fast: false
389+
matrix:
390+
unity-version: ${{ fromJSON(needs.create-unity-matrix.outputs.unity-matrix).unity-version }}
391+
uses: ./.github/workflows/test-build-macos.yml
392+
with:
393+
unity-version: ${{ matrix.unity-version }}
394+
382395
test-run-linux:
383396
name: Run Linux ${{ matrix.unity-version }} Integration Test
384397
if: ${{ !startsWith(github.ref, 'refs/heads/release/') }}
@@ -407,11 +420,25 @@ jobs:
407420
unity-version: ${{ matrix.unity-version }}
408421
platform: windows
409422

423+
test-run-macos:
424+
name: Run macOS ${{ matrix.unity-version }} Integration Test
425+
if: ${{ !startsWith(github.ref, 'refs/heads/release/') }}
426+
needs: [test-build-macos, create-unity-matrix]
427+
secrets: inherit
428+
strategy:
429+
fail-fast: false
430+
matrix:
431+
unity-version: ${{ fromJSON(needs.create-unity-matrix.outputs.unity-matrix).unity-version }}
432+
uses: ./.github/workflows/test-run-desktop.yml
433+
with:
434+
unity-version: ${{ matrix.unity-version }}
435+
platform: macos
436+
410437
build-size-summary:
411438
name: Build Size
412439
runs-on: ubuntu-latest
413440
if: ${{ !startsWith(github.ref, 'refs/heads/release/') }}
414-
needs: [test-build-webgl, test-build-android, test-compile-ios, test-build-linux, test-build-windows]
441+
needs: [test-build-webgl, test-build-android, test-compile-ios, test-build-linux, test-build-windows, test-build-macos]
415442
steps:
416443
- name: Checkout
417444
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
name: "Test: Build macOS"
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+
build:
15+
name: macOS ${{ inputs.unity-version }}
16+
runs-on: macos-latest
17+
env:
18+
UNITY_VERSION: ${{ inputs.unity-version }}
19+
BUILD_PLATFORM: MacOS
20+
21+
steps:
22+
- name: Checkout
23+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
24+
25+
- name: Load env
26+
id: env
27+
run: |
28+
$u = (Get-Content scripts/unity-versions.json -Raw | ConvertFrom-Json).'${{ env.UNITY_VERSION }}'
29+
"unityVersion=$($u.version)" >> $env:GITHUB_OUTPUT
30+
"unityChangeset=$($u.changeset)" >> $env:GITHUB_OUTPUT
31+
32+
- name: Setup Unity
33+
uses: getsentry/setup-unity@1bbd385ae3b0505069aacc56d47f0a16366f10b1
34+
with:
35+
unity-version: ${{ steps.env.outputs.unityVersion }}
36+
unity-version-changeset: ${{ steps.env.outputs.unityChangeset }}
37+
unity-modules: mac-il2cpp
38+
39+
- name: Create Unity license config
40+
run: |
41+
sudo mkdir -p "/Library/Application Support/Unity/config"
42+
echo "$env:UNITY_LICENSE_SERVER_CONFIG" | sudo tee "/Library/Application Support/Unity/config/services-config.json" > /dev/null
43+
env:
44+
UNITY_LICENSE_SERVER_CONFIG: ${{ secrets.UNITY_LICENSE_SERVER_CONFIG }}
45+
46+
- name: Download IntegrationTest project
47+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
48+
with:
49+
name: test-${{ env.UNITY_VERSION }}
50+
51+
- name: Extract project archive
52+
run: tar -xvzf test-project.tar.gz
53+
54+
- name: Cache Unity Library
55+
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
56+
with:
57+
path: samples/IntegrationTest/Library
58+
key: Library-IntegrationTest-macos-${{ env.UNITY_VERSION }}-v1
59+
restore-keys: |
60+
Library-IntegrationTest-macos-${{ env.UNITY_VERSION }}-
61+
Library-IntegrationTest-macos-
62+
63+
- name: Restore cached build without Sentry
64+
id: cache-build-nosentry
65+
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
66+
with:
67+
path: samples/IntegrationTest/Build-NoSentry
68+
key: build-nosentry-MacOS-${{ inputs.unity-version }}
69+
70+
- name: Build without Sentry SDK
71+
if: steps.cache-build-nosentry.outputs.cache-hit != 'true'
72+
run: ./test/Scripts.Integration.Test/build-project.ps1 -UnityPath "$env:UNITY_PATH" -Platform MacOS -BuildDirName "Build-NoSentry"
73+
74+
- name: Download UPM package
75+
uses: ./.github/actions/wait-for-artifact
76+
with:
77+
name: package-release
78+
79+
- name: Extract UPM package
80+
run: ./test/Scripts.Integration.Test/extract-package.ps1
81+
82+
- name: Add Sentry to the project
83+
run: ./test/Scripts.Integration.Test/add-sentry.ps1 -UnityPath "$env:UNITY_PATH" -PackagePath "test-package-release"
84+
85+
- name: Configure Sentry
86+
run: ./test/Scripts.Integration.Test/configure-sentry.ps1 -UnityPath "$env:UNITY_PATH" -Platform MacOS
87+
env:
88+
SENTRY_DSN: ${{ secrets.SENTRY_TEST_DSN }}
89+
90+
- name: Build with Sentry SDK
91+
run: ./test/Scripts.Integration.Test/build-project.ps1 -UnityPath "$env:UNITY_PATH" -Platform MacOS -UnityVersion "$env:UNITY_VERSION"
92+
93+
- name: Compare build sizes
94+
run: ./test/Scripts.Integration.Test/measure-build-size.ps1 -Path1 "samples/IntegrationTest/Build-NoSentry" -Path2 "samples/IntegrationTest/Build" -Platform MacOS -UnityVersion "$env:UNITY_VERSION"
95+
96+
- name: Upload build size measurement
97+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
98+
with:
99+
name: build-size-MacOS-${{ env.UNITY_VERSION }}
100+
path: build-size-measurements/*.json
101+
retention-days: 1
102+
103+
# We create tar explicitly because upload-artifact is slow for many files.
104+
- name: Create archive
105+
run: |
106+
Remove-Item -Recurse -Force samples/IntegrationTest/Build/*_BackUpThisFolder_ButDontShipItWithYourGame -ErrorAction SilentlyContinue
107+
tar -cvzf test-app-desktop.tar.gz samples/IntegrationTest/Build
108+
109+
- name: Upload test app
110+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
111+
with:
112+
name: testapp-desktop-compiled-${{ env.UNITY_VERSION }}-macos
113+
if-no-files-found: error
114+
path: test-app-desktop.tar.gz
115+
retention-days: 14
116+
117+
- name: Upload IntegrationTest project on failure
118+
if: ${{ failure() }}
119+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
120+
with:
121+
name: failed-project-desktop-macos-${{ env.UNITY_VERSION }}
122+
path: |
123+
samples/IntegrationTest
124+
unity.log
125+
!samples/IntegrationTest/Build/*_BackUpThisFolder_ButDontShipItWithYourGame
126+
retention-days: 14

.github/workflows/test-build-windows.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,16 @@ jobs:
2424

2525
- name: Load env
2626
id: env
27-
run: echo "unityVersion=$(./scripts/ci-env.ps1 "unity$env:UNITY_VERSION")" >> $env:GITHUB_OUTPUT
27+
run: |
28+
$u = (Get-Content scripts/unity-versions.json -Raw | ConvertFrom-Json).'${{ env.UNITY_VERSION }}'
29+
"unityVersion=$($u.version)" >> $env:GITHUB_OUTPUT
30+
"unityChangeset=$($u.changeset)" >> $env:GITHUB_OUTPUT
2831
2932
- name: Setup Unity
30-
uses: getsentry/setup-unity@3bdc8c022b6d30ecf2d21d12a564bfa55a54fa2e
33+
uses: getsentry/setup-unity@1bbd385ae3b0505069aacc56d47f0a16366f10b1
3134
with:
3235
unity-version: ${{ steps.env.outputs.unityVersion }}
36+
unity-version-changeset: ${{ steps.env.outputs.unityChangeset }}
3337
unity-modules: windows-il2cpp
3438

3539
- name: Create Unity license config

.github/workflows/test-run-desktop.yml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88
platform:
99
required: true
1010
type: string
11-
description: "linux or windows"
11+
description: "linux, windows, or macos"
1212

1313
defaults:
1414
run:
@@ -17,7 +17,7 @@ defaults:
1717
jobs:
1818
run:
1919
name: ${{ inputs.platform }} ${{ inputs.unity-version }}
20-
runs-on: ${{ inputs.platform == 'linux' && 'ubuntu-latest' || 'windows-latest' }}
20+
runs-on: ${{ inputs.platform == 'linux' && 'ubuntu-latest' || inputs.platform == 'macos' && 'macos-latest' || 'windows-latest' }}
2121
env:
2222
SENTRY_DSN: ${{ secrets.SENTRY_TEST_DSN }}
2323
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
@@ -43,6 +43,11 @@ jobs:
4343
run: chmod +x samples/IntegrationTest/Build/test
4444
shell: bash
4545

46+
- name: Set executable permission (macOS)
47+
if: inputs.platform == 'macos'
48+
run: chmod +x samples/IntegrationTest/Build/test.app/Contents/MacOS/IntegrationTest
49+
shell: bash
50+
4651
- name: Run Integration Tests (Linux)
4752
if: inputs.platform == 'linux'
4853
timeout-minutes: 20
@@ -53,6 +58,14 @@ jobs:
5358
Invoke-Pester -Path test/IntegrationTest/Integration.Tests.ps1 -CI'
5459
shell: bash
5560

61+
- name: Run Integration Tests (macOS)
62+
if: inputs.platform == 'macos'
63+
timeout-minutes: 20
64+
run: |
65+
$env:SENTRY_TEST_PLATFORM = "Desktop"
66+
$env:SENTRY_TEST_APP = "samples/IntegrationTest/Build/test.app/Contents/MacOS/IntegrationTest"
67+
Invoke-Pester -Path test/IntegrationTest/Integration.Tests.ps1 -CI
68+
5669
- name: Run Integration Tests (Windows)
5770
if: inputs.platform == 'windows'
5871
timeout-minutes: 20

.github/workflows/update-deps.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,14 @@ jobs:
6060
with:
6161
ssh-key: ${{ secrets.CI_DEPLOY_KEY }}
6262

63-
- name: Update ci-env.ps1
63+
- name: Update unity-versions.json
6464
run: |
65-
$file = "scripts/ci-env.ps1"
66-
$regexVersion = '${{ matrix.unity-prefix }}' + "\.[0-9]+[a-z][0-9]+"
67-
echo "Regex: $regexVersion"
68-
(Get-Content $file) -replace $regexVersion, '${{ steps.version-select.outputs.version }}' | Out-File $file
65+
$file = "scripts/unity-versions.json"
66+
$data = Get-Content $file -Raw | ConvertFrom-Json
67+
$prefix = '${{ matrix.unity-prefix }}'
68+
$data.$prefix.version = '${{ steps.version-select.outputs.version }}'
69+
$data.$prefix.changeset = '${{ steps.version-select.outputs.changeset }}'
70+
$data | ConvertTo-Json -Depth 3 | Set-Content $file
6971
7072
- run: git --no-pager diff
7173

CLAUDE.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,12 @@ The CI system uses modular, reusable workflows in `.github/workflows/`:
131131
| 6000.0.x | Yes | Yes |
132132
| 6000.1.x | No | Yes |
133133

134-
Version mapping is defined in `scripts/ci-env.ps1`:
134+
Version mapping is defined in `scripts/unity-versions.json` (each entry has a `version` and a `changeset`):
135135

136136
- `2021.3``2021.3.45f2`
137-
- `2022.3``2022.3.70f1`
138-
- `6000.0``6000.0.48f1`
139-
- `6000.1``6000.1.17f1`
137+
- `2022.3``2022.3.62f3`
138+
- `6000.0``6000.0.74f1`
139+
- `6000.3``6000.3.14f1`
140140

141141
### Docker-Based Builds
142142

scripts/ci-docker.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
set -euo pipefail
33

44
unityPrefix="$1"
5-
unityVersion=$(pwsh ./scripts/ci-env.ps1 "unity$unityPrefix")
5+
unityVersion=$(jq -r --arg p "$unityPrefix" '.[$p].version' ./scripts/unity-versions.json)
66
imageVariant=$(echo "$2" | tr '[:upper:]' '[:lower:]')
77
licenseConfig=$3
88

scripts/ci-env.ps1

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

scripts/unity-versions.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"2021.3": {
3+
"version": "2021.3.45f2",
4+
"changeset": "88f88f591b2e"
5+
},
6+
"2022.3": {
7+
"version": "2022.3.62f3",
8+
"changeset": "96770f904ca7"
9+
},
10+
"6000.0": {
11+
"version": "6000.0.74f1",
12+
"changeset": "7685f01dc6be"
13+
},
14+
"6000.3": {
15+
"version": "6000.3.15f1",
16+
"changeset": "c1aa84e375f6"
17+
}
18+
}

0 commit comments

Comments
 (0)