Skip to content

Commit 37d4338

Browse files
authored
feat: SDK size impact as part of Summary (#2409)
1 parent 172bf5e commit 37d4338

File tree

7 files changed

+275
-8
lines changed

7 files changed

+275
-8
lines changed

.github/workflows/ci.yml

Lines changed: 66 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,18 @@ jobs:
162162
- name: Extract project archive
163163
run: tar -xvzf test-project.tar.gz
164164

165-
# - name: Build without Sentry SDK
166-
# run: ./test/Scripts.Integration.Test/build-project.ps1 -UnityPath "${{ env.UNITY_PATH }}" -Platform "${{ matrix.platform }}"
165+
- name: Restore cached build without Sentry
166+
id: cache-build-nosentry
167+
uses: actions/cache@v4
168+
with:
169+
path: samples/IntegrationTest/Build-NoSentry
170+
key: build-nosentry-${{ matrix.build_platform }}-${{ matrix.unity-version }}
171+
172+
- name: Build without Sentry SDK
173+
if: steps.cache-build-nosentry.outputs.cache-hit != 'true'
174+
run: ./test/Scripts.Integration.Test/build-project.ps1 -UnityPath "$env:UNITY_PATH" -Platform "$env:BUILD_PLATFORM" -CheckSymbols:$false -BuildDirName "Build-NoSentry"
175+
env:
176+
BUILD_PLATFORM: ${{ matrix.build_platform }}
167177

168178
- name: Download UPM package
169179
uses: vaind/download-artifact@e7141b6a94ef28aa3d828b52830cfa1f406a1848 # v4-with-wait-timeout
@@ -189,6 +199,19 @@ jobs:
189199
CHECK_SYMBOLS: ${{ matrix.check_symbols }}
190200
UNITY_VERSION: ${{ matrix.unity-version }}
191201

202+
- name: Compare build sizes
203+
run: ./test/Scripts.Integration.Test/measure-build-size.ps1 -Path1 "samples/IntegrationTest/Build-NoSentry" -Path2 "samples/IntegrationTest/Build" -Platform "$env:BUILD_PLATFORM" -UnityVersion "$env:UNITY_VERSION"
204+
env:
205+
BUILD_PLATFORM: ${{ matrix.build_platform }}
206+
UNITY_VERSION: ${{ matrix.unity-version }}
207+
208+
- name: Upload build size measurement
209+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
210+
with:
211+
name: build-size-${{ matrix.platform }}-${{ matrix.unity-version }}
212+
path: build-size-measurements/*.json
213+
retention-days: 1
214+
192215
# We create tar explicitly because upload-artifact is slow for many files.
193216
- name: Create archive
194217
shell: bash
@@ -390,8 +413,16 @@ jobs:
390413
- name: Extract project archive
391414
run: tar -xvzf test-project.tar.gz
392415

416+
- name: Restore cached build without Sentry
417+
id: cache-build-nosentry
418+
uses: actions/cache@v4
419+
with:
420+
path: samples/IntegrationTest/Build-NoSentry
421+
key: build-nosentry-Windows-${{ matrix.unity-version }}
422+
393423
- name: Build without Sentry SDK
394-
run: ./test/Scripts.Integration.Test/build-project.ps1 -UnityPath "$env:UNITY_PATH"
424+
if: steps.cache-build-nosentry.outputs.cache-hit != 'true'
425+
run: ./test/Scripts.Integration.Test/build-project.ps1 -UnityPath "$env:UNITY_PATH" -CheckSymbols:$false -BuildDirName "Build-NoSentry"
395426

396427
- name: Download UPM package
397428
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
@@ -412,8 +443,39 @@ jobs:
412443
env:
413444
UNITY_VERSION: ${{ matrix.unity-version }}
414445

446+
- name: Compare build sizes
447+
run: ./test/Scripts.Integration.Test/measure-build-size.ps1 -Path1 "samples/IntegrationTest/Build-NoSentry" -Path2 "samples/IntegrationTest/Build" -Platform "Windows" -UnityVersion "$env:UNITY_VERSION"
448+
env:
449+
UNITY_VERSION: ${{ matrix.unity-version }}
450+
451+
- name: Upload build size measurement
452+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
453+
with:
454+
name: build-size-Windows-${{ matrix.unity-version }}
455+
path: build-size-measurements/*.json
456+
retention-days: 1
457+
415458
- name: Run Smoke Test
416459
run: ./test/Scripts.Integration.Test/run-smoke-test.ps1 -Smoke
417460

418461
- name: Run Crash Test
419-
run: ./test/Scripts.Integration.Test/run-smoke-test.ps1 -Crash
462+
run: ./test/Scripts.Integration.Test/run-smoke-test.ps1 -Crash
463+
464+
build-size-summary:
465+
name: Build Size
466+
runs-on: ubuntu-latest
467+
if: ${{ !startsWith(github.ref, 'refs/heads/release/') }}
468+
needs: [smoke-test-build, smoke-test-build-android, smoke-test-compile-ios, desktop-smoke-test]
469+
steps:
470+
- name: Checkout
471+
uses: actions/checkout@v3
472+
473+
- name: Download all build size measurements
474+
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
475+
with:
476+
pattern: build-size-*
477+
path: build-size-measurements
478+
479+
- name: Create consolidated summary
480+
shell: pwsh
481+
run: ./scripts/create-build-size-summary.ps1

.github/workflows/smoke-test-build-android.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,17 @@ jobs:
4949
- name: Extract project archive
5050
run: tar -xvzf test-project.tar.gz
5151

52+
- name: Restore cached build without Sentry
53+
id: cache-build-nosentry
54+
uses: actions/cache@v4
55+
with:
56+
path: samples/IntegrationTest/Build-NoSentry
57+
key: build-nosentry-Android-${{ inputs.unity-version }}
58+
59+
- name: Build without Sentry SDK
60+
if: steps.cache-build-nosentry.outputs.cache-hit != 'true'
61+
run: ./test/Scripts.Integration.Test/build-project.ps1 -UnityPath "$env:UNITY_PATH" -Platform "Android" -CheckSymbols:$false -BuildDirName "Build-NoSentry"
62+
5263
- name: Download UPM package
5364
uses: vaind/download-artifact@e7141b6a94ef28aa3d828b52830cfa1f406a1848 # v4-with-wait-timeout
5465
with:
@@ -67,6 +78,16 @@ jobs:
6778
- name: Export APK - Runtime Initialization
6879
run: ./test/Scripts.Integration.Test/build-project.ps1 -UnityPath "$env:UNITY_PATH" -Platform "Android" -CheckSymbols:$true -UnityVersion "$env:UNITY_VERSION"
6980

81+
- name: Compare build sizes (Runtime)
82+
run: ./test/Scripts.Integration.Test/measure-build-size.ps1 -Path1 "samples/IntegrationTest/Build-NoSentry" -Path2 "samples/IntegrationTest/Build" -Platform "Android" -UnityVersion "$env:UNITY_VERSION"
83+
84+
- name: Upload build size measurement
85+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
86+
with:
87+
name: build-size-Android-${{ env.UNITY_VERSION }}
88+
path: build-size-measurements/*.json
89+
retention-days: 1
90+
7091
- name: Upload .apk
7192
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
7293
with:

.github/workflows/smoke-test-build-ios.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,30 @@ jobs:
5555
- name: Extract project archive
5656
run: tar -xvzf test-project.tar.gz
5757

58+
- name: Restore cached build without Sentry
59+
id: cache-build-nosentry
60+
uses: actions/cache@v4
61+
with:
62+
path: samples/IntegrationTest/Build-NoSentry
63+
key: build-nosentry-iOS-${{ inputs.unity-version }}
64+
65+
- name: Build without Sentry SDK
66+
if: steps.cache-build-nosentry.outputs.cache-hit != 'true'
67+
run: ./test/Scripts.Integration.Test/build-project.ps1 -UnityPath "$env:UNITY_PATH" -Platform "iOS" -CheckSymbols:$false -BuildDirName "Build-NoSentry"
68+
69+
- name: Create archive for build without Sentry
70+
shell: bash
71+
run: |
72+
rm -rf samples/IntegrationTest/Build-NoSentry/*_BackUpThisFolder_ButDontShipItWithYourGame
73+
tar -cvzf test-app-no-sentry.tar.gz samples/IntegrationTest/Build-NoSentry
74+
75+
- name: Upload build without Sentry
76+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
77+
with:
78+
name: testapp-ios-no-sentry-${{ env.UNITY_VERSION }}
79+
path: test-app-no-sentry.tar.gz
80+
retention-days: 1
81+
5882
- name: Download UPM package
5983
uses: vaind/download-artifact@e7141b6a94ef28aa3d828b52830cfa1f406a1848 # v4-with-wait-timeout
6084
with:

.github/workflows/smoke-test-compile-ios.yml

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,38 @@ jobs:
2525
- name: Checkout
2626
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3
2727

28+
- name: Restore cached compiled iOS build without Sentry
29+
if: ${{ inputs.init-type == 'runtime' }}
30+
id: cache-compiled-nosentry
31+
uses: actions/cache@v4
32+
with:
33+
path: IntegrationTest-NoSentry.app
34+
key: build-nosentry-iOS-compiled-${{ inputs.unity-version }}
35+
36+
- name: Download build without Sentry (for size comparison)
37+
if: ${{ inputs.init-type == 'runtime' && steps.cache-compiled-nosentry.outputs.cache-hit != 'true' }}
38+
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
39+
with:
40+
name: testapp-ios-no-sentry-${{ env.UNITY_VERSION }}
41+
42+
- name: Extract and compile build without Sentry
43+
if: ${{ inputs.init-type == 'runtime' && steps.cache-compiled-nosentry.outputs.cache-hit != 'true' }}
44+
run: |
45+
tar -xvzf test-app-no-sentry.tar.gz
46+
Move-Item -Path "samples/IntegrationTest/Build-NoSentry" -Destination "samples/IntegrationTest/Build"
47+
48+
- name: Compile Xcode project without Sentry
49+
if: ${{ inputs.init-type == 'runtime' && steps.cache-compiled-nosentry.outputs.cache-hit != 'true' }}
50+
run: ./scripts/smoke-test-ios.ps1 Build -UnityVersion "${env:UNITY_VERSION}" -iOSMinVersion "17.0"
51+
timeout-minutes: 20
52+
53+
- name: Save compiled app without Sentry
54+
if: ${{ inputs.init-type == 'runtime' && steps.cache-compiled-nosentry.outputs.cache-hit != 'true' }}
55+
run: |
56+
Copy-Item -Path "samples/IntegrationTest/Build/archive/Unity-iPhone/Build/Products/Release-iphonesimulator/IntegrationTest.app" `
57+
-Destination "IntegrationTest-NoSentry.app" -Recurse
58+
Remove-Item -Path "samples/IntegrationTest/Build" -Recurse -Force
59+
2860
- name: Download app project
2961
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
3062
with:
@@ -36,7 +68,7 @@ jobs:
3668
- name: iOS smoke test
3769
run: ./scripts/smoke-test-ios.ps1 Build -IsIntegrationTest -UnityVersion "${env:UNITY_VERSION}" -iOSMinVersion "17.0"
3870
timeout-minutes: 20
39-
71+
4072
- name: Upload integration-test project on failure
4173
if: ${{ failure() }}
4274
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
@@ -63,3 +95,20 @@ jobs:
6395
!**/Release-iphonesimulator/UnityFramework.framework/*
6496
# Lower retention period - we only need this to retry CI.
6597
retention-days: 14
98+
99+
- name: Compare build sizes
100+
if: ${{ inputs.init-type == 'runtime' }}
101+
run: |
102+
./test/Scripts.Integration.Test/measure-build-size.ps1 `
103+
-Path1 "IntegrationTest-NoSentry.app" `
104+
-Path2 "samples/IntegrationTest/Build/archive/Unity-iPhone/Build/Products/Release-iphonesimulator/IntegrationTest.app" `
105+
-Platform "iOS" `
106+
-UnityVersion "$env:UNITY_VERSION"
107+
108+
- name: Upload build size measurement
109+
if: ${{ inputs.init-type == 'runtime' }}
110+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
111+
with:
112+
name: build-size-iOS-${{ env.UNITY_VERSION }}
113+
path: build-size-measurements/*.json
114+
retention-days: 1
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
Set-StrictMode -Version latest
2+
$ErrorActionPreference = "Stop"
3+
4+
$measurements = @()
5+
Get-ChildItem -Path "build-size-measurements" -Recurse -Filter "*.json" | ForEach-Object {
6+
$data = Get-Content $_.FullName -Raw | ConvertFrom-Json
7+
$measurements += $data
8+
}
9+
10+
if ($measurements.Count -eq 0) {
11+
Write-Host "No build size measurements found. Skipping summary."
12+
exit 0
13+
}
14+
15+
function Format-Size {
16+
param ([long]$Bytes)
17+
18+
if ($Bytes -lt 1KB) { return "$Bytes B" }
19+
if ($Bytes -lt 1MB) { return "{0:N2} KB" -f ($Bytes / 1KB) }
20+
if ($Bytes -lt 1GB) { return "{0:N2} MB" -f ($Bytes / 1MB) }
21+
return "{0:N2} GB" -f ($Bytes / 1GB)
22+
}
23+
24+
$summary = @"
25+
## 📊 Build Size
26+
27+
| Platform + Version | Baseline | Sentry Impact |
28+
|--------------------|----------|---------------|
29+
"@
30+
31+
$measurements | Sort-Object Platform, UnityVersion | ForEach-Object {
32+
$baselineSize = Format-Size $_.WithoutSentry
33+
$diffSize = Format-Size ([Math]::Abs($_.Difference))
34+
35+
$sign = if ($_.Difference -gt 0) { "+" } elseif ($_.Difference -lt 0) { "-" } else { "" }
36+
37+
$summary += "`n| $($_.Platform) $($_.UnityVersion) | $baselineSize | $sign$diffSize |"
38+
}
39+
40+
$summary | Out-File -FilePath $env:GITHUB_STEP_SUMMARY
41+
Write-Host "Build size summary created successfully"

test/Scripts.Integration.Test/build-project.ps1

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
[string] $UnityPath,
33
[string] $Platform = "",
44
[string] $UnityVersion = "",
5-
[Switch] $CheckSymbols
5+
[Switch] $CheckSymbols,
6+
[string] $BuildDirName = "Build"
67
)
78

89
if (-not $Global:NewProjectPathCache)
@@ -14,7 +15,8 @@ if (-not $Global:NewProjectPathCache)
1415

1516
$unityPath = FormatUnityPath $UnityPath
1617
$buildMethod = BuildMethodFor $Platform
17-
$outputPath = "$(GetNewProjectBuildPath)/$(GetTestAppName $buildMethod)"
18+
$buildDirectory = "$(GetNewProjectPath)/$BuildDirName"
19+
$outputPath = "$buildDirectory/$(GetTestAppName $buildMethod)"
1820

1921
Write-Log "Executing ${buildMethod}:"
2022
$unityArgs = @("-batchmode", "-projectPath ", "$(GetNewProjectPath)", "-executeMethod", $buildMethod , "-buildPath", $outputPath, "-quit")
@@ -37,4 +39,4 @@ if ($Platform -eq "Android-Export")
3739
}
3840

3941
Write-Log "Project built successfully" -ForegroundColor Green
40-
Get-ChildItem $(GetNewProjectBuildPath)
42+
Get-ChildItem $buildDirectory
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
param(
2+
[Parameter(Mandatory=$true)]
3+
[string] $Path1,
4+
5+
[Parameter(Mandatory=$true)]
6+
[string] $Path2,
7+
8+
[string] $Platform = "Build",
9+
10+
[string] $UnityVersion = "unknown"
11+
)
12+
13+
Set-StrictMode -Version latest
14+
$ErrorActionPreference = "Stop"
15+
16+
function Get-Size {
17+
param ([string]$Path)
18+
19+
if (-not (Test-Path $Path)) {
20+
Write-Error "Path not found: $Path"
21+
exit 1
22+
}
23+
24+
$item = Get-Item $Path
25+
if ($item.PSIsContainer) {
26+
# Directory - sum all files
27+
$size = (Get-ChildItem -Path $Path -Recurse -File | Measure-Object -Property Length -Sum).Sum
28+
} else {
29+
# Single file
30+
$size = $item.Length
31+
}
32+
33+
return $size
34+
}
35+
36+
function Format-Size {
37+
param ([long]$Bytes)
38+
39+
if ($Bytes -lt 1KB) { return "$Bytes B" }
40+
if ($Bytes -lt 1MB) { return "{0:N2} KB" -f ($Bytes / 1KB) }
41+
if ($Bytes -lt 1GB) { return "{0:N2} MB" -f ($Bytes / 1MB) }
42+
return "{0:N2} GB" -f ($Bytes / 1GB)
43+
}
44+
45+
$size1 = Get-Size $Path1
46+
$size2 = Get-Size $Path2
47+
$diff = $size2 - $size1
48+
$percentChange = if ($size1 -gt 0) { ($diff / $size1) * 100 } else { 0 }
49+
50+
$diffFormatted = "$(if ($diff -gt 0) { '+' })$(Format-Size ([Math]::Abs($diff)))"
51+
$percentFormatted = "$(if ($diff -gt 0) { '+' })$([Math]::Round($percentChange, 2))%"
52+
53+
Write-Host "Without Sentry: $(Format-Size $size1)"
54+
Write-Host "With Sentry: $(Format-Size $size2)"
55+
Write-Host "Difference: $diffFormatted ($percentFormatted)"
56+
57+
# Save measurement to artifact for consolidated summary
58+
$measurement = @{
59+
Platform = $Platform
60+
UnityVersion = $UnityVersion
61+
WithoutSentry = $size1
62+
WithSentry = $size2
63+
Difference = $diff
64+
PercentChange = $percentChange
65+
} | ConvertTo-Json
66+
67+
New-Item -Path "build-size-measurements" -ItemType Directory -Force | Out-Null
68+
$measurement | Out-File -FilePath "build-size-measurements/$Platform-$UnityVersion.json"

0 commit comments

Comments
 (0)