Skip to content

Commit de833b1

Browse files
authored
chore: CI build times optimization (DDC caching) (#1132)
* Test cooked content and ddc caching * Test * Fix caching * Test ddc * Test * Clean up * Update SentryPlaygroundGameInstance.cpp * Move DDC config to a separate script * Fix warning * Test * Test * Test squash docker images * Revert "Test squash docker images" This reverts commit 158245e. * Add missing quotes
1 parent eb5082d commit de833b1

File tree

3 files changed

+110
-1
lines changed

3 files changed

+110
-1
lines changed

.github/workflows/test-linux.yml

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,27 @@ jobs:
105105
UNREAL_VERSION: ${{ inputs.unreal-version }}
106106
run: unzip sentry-unreal-*-engine"$UNREAL_VERSION".zip -d checkout/sample/Plugins/sentry
107107

108+
- name: Compute DDC cache key
109+
id: ddc-cache-key
110+
run: |
111+
HASH="${{ hashFiles('checkout/sample/Content/**', 'checkout/sample/Config/**/*.ini', 'checkout/sample/*.uproject') }}"
112+
KEY="ue-${{ inputs.unreal-version }}-linux-ddc-${HASH}"
113+
echo "key=${KEY}" >> $GITHUB_OUTPUT
114+
echo "DDC cache key: ${KEY}"
115+
116+
- name: Configure project-local DDC
117+
shell: pwsh
118+
run: ./checkout/scripts/configure-local-ddc.ps1 -ProjectPath checkout/sample
119+
120+
- name: Restore cached DDC
121+
id: cache-ddc
122+
uses: actions/cache/restore@v4
123+
with:
124+
path: checkout/sample/DerivedDataCache
125+
key: ${{ steps.ddc-cache-key.outputs.key }}
126+
restore-keys: |
127+
ue-${{ inputs.unreal-version }}-linux-ddc
128+
108129
- name: Set permissions for sample
109130
# sentry-native requires write access to sample project directory in order to initialize itself properly
110131
run: docker exec -w /workspace/checkout unreal chmod -R +x sample
@@ -117,7 +138,7 @@ jobs:
117138
run: |
118139
docker exec unreal bash -c "
119140
mkdir -p ~/.config/Unreal\ Engine/UnrealBuildTool ;
120-
cp /workspace/checkout/.github/BuildConfiguration.xml ~/.config/Unreal\ Engine/UnrealBuildTool/ "
141+
cp /workspace/checkout/.github/BuildConfiguration.xml ~/.config/Unreal\ Engine/UnrealBuildTool/ "
121142
122143
- name: Run tests
123144
id: run-tests
@@ -139,6 +160,7 @@ jobs:
139160
-platform=Linux \
140161
-nop4 \
141162
-cook \
163+
-iterate \
142164
-build \
143165
-stage \
144166
-prereqss \
@@ -154,6 +176,13 @@ jobs:
154176
-NoSplash \
155177
-NullRHI
156178
179+
- name: Save DDC to cache
180+
if: ${{ success() && steps.cache-ddc.outputs.cache-hit != 'true' }}
181+
uses: actions/cache/save@v4
182+
with:
183+
path: checkout/sample/DerivedDataCache
184+
key: ${{ steps.ddc-cache-key.outputs.key }}
185+
157186
- name: Collect sample test info
158187
if: ${{ always() && steps.run-tests.outcome == 'failure' }}
159188
uses: actions/upload-artifact@v4

.github/workflows/test-windows.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,27 @@ jobs:
5252
New-Item -ItemType Directory -Path "$env:WORKSPACE_PATH\checkout\sample\Plugins\sentry" -Force
5353
Expand-Archive -Path "sentry-unreal-*-engine$env:UNREAL_VERSION.zip" -DestinationPath "$env:WORKSPACE_PATH\checkout\sample\Plugins\sentry" -Force
5454
55+
- name: Compute DDC cache key
56+
id: ddc-cache-key
57+
run: |
58+
$hash = "${{ hashFiles('checkout/sample/Content/**', 'checkout/sample/Config/**/*.ini', 'checkout/sample/*.uproject') }}"
59+
$key = "ue-${{ inputs.unreal-version }}-win64-ddc-${hash}"
60+
echo "key=${key}" >> $env:GITHUB_OUTPUT
61+
echo "DDC cache key: ${key}"
62+
63+
- name: Configure project-local DDC
64+
shell: pwsh
65+
run: ./checkout/scripts/configure-local-ddc.ps1 -ProjectPath checkout/sample
66+
67+
- name: Restore cached DDC
68+
id: cache-ddc
69+
uses: actions/cache/restore@v4
70+
with:
71+
path: checkout/sample/DerivedDataCache
72+
key: ${{ steps.ddc-cache-key.outputs.key }}
73+
restore-keys: |
74+
ue-${{ inputs.unreal-version }}-win64-ddc
75+
5576
- name: Update engine's build configuration
5677
run: |
5778
docker exec unreal powershell -Command 'New-Item -ItemType Directory -Path "$env:USERPROFILE\AppData\Roaming\Unreal Engine\UnrealBuildTool" -Force'
@@ -77,6 +98,7 @@ jobs:
7798
-platform=Win64 `
7899
-nop4 `
79100
-cook `
101+
-iterate `
80102
-build `
81103
-stage `
82104
-prereqss `
@@ -91,6 +113,13 @@ jobs:
91113
-NoSplash `
92114
-NullRHI
93115
116+
- name: Save DDC to cache
117+
if: ${{ success() && steps.cache-ddc.outputs.cache-hit != 'true' }}
118+
uses: actions/cache/save@v4
119+
with:
120+
path: checkout/sample/DerivedDataCache
121+
key: ${{ steps.ddc-cache-key.outputs.key }}
122+
94123
- name: Collect sample test info
95124
if: ${{ always() && steps.run-tests.outcome == 'failure' }}
96125
uses: actions/upload-artifact@v4

scripts/configure-local-ddc.ps1

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/usr/bin/env pwsh
2+
<#
3+
.SYNOPSIS
4+
Configures Unreal Engine to use project-local Derived Data Cache (DDC).
5+
6+
.DESCRIPTION
7+
This script modifies the project's DefaultEngine.ini to add DDC configuration
8+
that forces Unreal to store the DDC within the project directory instead of
9+
the user's home directory. This enables DDC caching in CI environments.
10+
11+
.PARAMETER ProjectPath
12+
Path to the Unreal project directory containing Config/DefaultEngine.ini
13+
14+
.EXAMPLE
15+
./configure-local-ddc.ps1 -ProjectPath "sample"
16+
#>
17+
18+
param(
19+
[Parameter(Mandatory=$true)]
20+
[string]$ProjectPath
21+
)
22+
23+
$ErrorActionPreference = "Stop"
24+
25+
$configPath = Join-Path $ProjectPath "Config/DefaultEngine.ini"
26+
27+
if (-not (Test-Path $configPath)) {
28+
Write-Error "DefaultEngine.ini not found at: $configPath"
29+
exit 1
30+
}
31+
32+
Write-Host "Configuring project-local DDC for: $ProjectPath"
33+
34+
$ddcConfig = @"
35+
36+
[InstalledDerivedDataBackendGraph]
37+
MinimumDaysToKeepFile=7
38+
Root=(Type=KeyLength, Length=120, Inner=AsyncPut)
39+
AsyncPut=(Type=AsyncPut, Inner=Hierarchy)
40+
Hierarchy=(Type=Hierarchical, Inner=Boot, Inner=Pak, Inner=EnginePak, Inner=Local, Inner=Shared)
41+
Boot=(Type=Boot, Filename="%GAMEDIR%DerivedDataCache/Boot.ddc", MaxCacheSize=512)
42+
Local=(Type=FileSystem, ReadOnly=false, Clean=false, Flush=false, PurgeTransient=true, DeleteUnused=true, UnusedFileAge=34, FoldersToClean=-1, Path="%GAMEDIR%DerivedDataCache", EnvPathOverride=UE-LocalDataCachePath, EditorOverrideSetting=LocalDerivedDataCache)
43+
Shared=(Type=FileSystem, ReadOnly=false, Clean=false, Flush=false, DeleteUnused=true, UnusedFileAge=10, FoldersToClean=-1, Path="%GAMEDIR%DerivedDataCache/Shared", EnvPathOverride=UE-SharedDataCachePath, EditorOverrideSetting=SharedDerivedDataCache, CommandLineOverride=SharedDataCachePath)
44+
Pak=(Type=ReadPak, Filename="%GAMEDIR%DerivedDataCache/DDC.ddp")
45+
EnginePak=(Type=ReadPak, Filename="%ENGINEDIR%DerivedDataCache/Compressed.ddp")
46+
"@
47+
48+
Add-Content -Path $configPath -Value $ddcConfig
49+
50+
Write-Host "✓ DDC configuration added to $configPath"
51+
Write-Host " DDC will be stored at: <ProjectDir>/DerivedDataCache/"

0 commit comments

Comments
 (0)