diff --git a/.github/workflows/test-linux.yml b/.github/workflows/test-linux.yml index f0ccb94b2..707a78608 100644 --- a/.github/workflows/test-linux.yml +++ b/.github/workflows/test-linux.yml @@ -105,6 +105,27 @@ jobs: UNREAL_VERSION: ${{ inputs.unreal-version }} run: unzip sentry-unreal-*-engine"$UNREAL_VERSION".zip -d checkout/sample/Plugins/sentry + - name: Compute DDC cache key + id: ddc-cache-key + run: | + HASH="${{ hashFiles('checkout/sample/Content/**', 'checkout/sample/Config/**/*.ini', 'checkout/sample/*.uproject') }}" + KEY="ue-${{ inputs.unreal-version }}-linux-ddc-${HASH}" + echo "key=${KEY}" >> $GITHUB_OUTPUT + echo "DDC cache key: ${KEY}" + + - name: Configure project-local DDC + shell: pwsh + run: ./checkout/scripts/configure-local-ddc.ps1 -ProjectPath checkout/sample + + - name: Restore cached DDC + id: cache-ddc + uses: actions/cache/restore@v4 + with: + path: checkout/sample/DerivedDataCache + key: ${{ steps.ddc-cache-key.outputs.key }} + restore-keys: | + ue-${{ inputs.unreal-version }}-linux-ddc + - name: Set permissions for sample # sentry-native requires write access to sample project directory in order to initialize itself properly run: docker exec -w /workspace/checkout unreal chmod -R +x sample @@ -117,7 +138,7 @@ jobs: run: | docker exec unreal bash -c " mkdir -p ~/.config/Unreal\ Engine/UnrealBuildTool ; - cp /workspace/checkout/.github/BuildConfiguration.xml ~/.config/Unreal\ Engine/UnrealBuildTool/ " + cp /workspace/checkout/.github/BuildConfiguration.xml ~/.config/Unreal\ Engine/UnrealBuildTool/ " - name: Run tests id: run-tests @@ -139,6 +160,7 @@ jobs: -platform=Linux \ -nop4 \ -cook \ + -iterate \ -build \ -stage \ -prereqss \ @@ -154,6 +176,13 @@ jobs: -NoSplash \ -NullRHI + - name: Save DDC to cache + if: ${{ success() && steps.cache-ddc.outputs.cache-hit != 'true' }} + uses: actions/cache/save@v4 + with: + path: checkout/sample/DerivedDataCache + key: ${{ steps.ddc-cache-key.outputs.key }} + - name: Collect sample test info if: ${{ always() && steps.run-tests.outcome == 'failure' }} uses: actions/upload-artifact@v4 diff --git a/.github/workflows/test-windows.yml b/.github/workflows/test-windows.yml index 3c1defdeb..ae8029372 100644 --- a/.github/workflows/test-windows.yml +++ b/.github/workflows/test-windows.yml @@ -52,6 +52,27 @@ jobs: New-Item -ItemType Directory -Path "$env:WORKSPACE_PATH\checkout\sample\Plugins\sentry" -Force Expand-Archive -Path "sentry-unreal-*-engine$env:UNREAL_VERSION.zip" -DestinationPath "$env:WORKSPACE_PATH\checkout\sample\Plugins\sentry" -Force + - name: Compute DDC cache key + id: ddc-cache-key + run: | + $hash = "${{ hashFiles('checkout/sample/Content/**', 'checkout/sample/Config/**/*.ini', 'checkout/sample/*.uproject') }}" + $key = "ue-${{ inputs.unreal-version }}-win64-ddc-${hash}" + echo "key=${key}" >> $env:GITHUB_OUTPUT + echo "DDC cache key: ${key}" + + - name: Configure project-local DDC + shell: pwsh + run: ./checkout/scripts/configure-local-ddc.ps1 -ProjectPath checkout/sample + + - name: Restore cached DDC + id: cache-ddc + uses: actions/cache/restore@v4 + with: + path: checkout/sample/DerivedDataCache + key: ${{ steps.ddc-cache-key.outputs.key }} + restore-keys: | + ue-${{ inputs.unreal-version }}-win64-ddc + - name: Update engine's build configuration run: | docker exec unreal powershell -Command 'New-Item -ItemType Directory -Path "$env:USERPROFILE\AppData\Roaming\Unreal Engine\UnrealBuildTool" -Force' @@ -77,6 +98,7 @@ jobs: -platform=Win64 ` -nop4 ` -cook ` + -iterate ` -build ` -stage ` -prereqss ` @@ -91,6 +113,13 @@ jobs: -NoSplash ` -NullRHI + - name: Save DDC to cache + if: ${{ success() && steps.cache-ddc.outputs.cache-hit != 'true' }} + uses: actions/cache/save@v4 + with: + path: checkout/sample/DerivedDataCache + key: ${{ steps.ddc-cache-key.outputs.key }} + - name: Collect sample test info if: ${{ always() && steps.run-tests.outcome == 'failure' }} uses: actions/upload-artifact@v4 diff --git a/scripts/configure-local-ddc.ps1 b/scripts/configure-local-ddc.ps1 new file mode 100644 index 000000000..12b28b939 --- /dev/null +++ b/scripts/configure-local-ddc.ps1 @@ -0,0 +1,51 @@ +#!/usr/bin/env pwsh +<# +.SYNOPSIS + Configures Unreal Engine to use project-local Derived Data Cache (DDC). + +.DESCRIPTION + This script modifies the project's DefaultEngine.ini to add DDC configuration + that forces Unreal to store the DDC within the project directory instead of + the user's home directory. This enables DDC caching in CI environments. + +.PARAMETER ProjectPath + Path to the Unreal project directory containing Config/DefaultEngine.ini + +.EXAMPLE + ./configure-local-ddc.ps1 -ProjectPath "sample" +#> + +param( + [Parameter(Mandatory=$true)] + [string]$ProjectPath +) + +$ErrorActionPreference = "Stop" + +$configPath = Join-Path $ProjectPath "Config/DefaultEngine.ini" + +if (-not (Test-Path $configPath)) { + Write-Error "DefaultEngine.ini not found at: $configPath" + exit 1 +} + +Write-Host "Configuring project-local DDC for: $ProjectPath" + +$ddcConfig = @" + +[InstalledDerivedDataBackendGraph] +MinimumDaysToKeepFile=7 +Root=(Type=KeyLength, Length=120, Inner=AsyncPut) +AsyncPut=(Type=AsyncPut, Inner=Hierarchy) +Hierarchy=(Type=Hierarchical, Inner=Boot, Inner=Pak, Inner=EnginePak, Inner=Local, Inner=Shared) +Boot=(Type=Boot, Filename="%GAMEDIR%DerivedDataCache/Boot.ddc", MaxCacheSize=512) +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) +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) +Pak=(Type=ReadPak, Filename="%GAMEDIR%DerivedDataCache/DDC.ddp") +EnginePak=(Type=ReadPak, Filename="%ENGINEDIR%DerivedDataCache/Compressed.ddp") +"@ + +Add-Content -Path $configPath -Value $ddcConfig + +Write-Host "✓ DDC configuration added to $configPath" +Write-Host " DDC will be stored at: /DerivedDataCache/"