From fc892a0623ba0dba1f2d01b2be52994a57f936f3 Mon Sep 17 00:00:00 2001 From: Webber Takken Date: Sat, 24 Oct 2026 22:33:03 +0200 Subject: [PATCH] ci: key Library caches per build configuration (#864) Server and Player builds shared a cache key, and every job could fall back to any other job's Library through the bare Library- restore key. A Library remembers its last standalone subtarget, so a macOS Player build that restored an Ubuntu Server Library tried to build a Mac Dedicated Server and failed. Keys now include the scripting backend and subtarget, prefix fallbacks are gone, and the v2 prefix leaves the polluted caches behind. Co-authored-by: Frostebite --- .github/workflows/build-tests-mac.yml | 9 +++++---- .github/workflows/build-tests-ubuntu.yml | 9 +++++---- .github/workflows/build-tests-windows.yml | 9 +++++---- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/.github/workflows/build-tests-mac.yml b/.github/workflows/build-tests-mac.yml index b38e4f3b..92e68c35 100644 --- a/.github/workflows/build-tests-mac.yml +++ b/.github/workflows/build-tests-mac.yml @@ -59,10 +59,11 @@ jobs: id: cache-restore with: path: ${{ matrix.projectPath }}/Library - key: Library-${{ matrix.projectPath }}-macos-${{ matrix.targetPlatform }}-${{ matrix.unityVersion }}-${{ matrix.buildProfile }} - restore-keys: | - Library-${{ matrix.projectPath }}-macos- - Library- + # One cache per build configuration and no prefix fallback: a Library + # remembers the settings of the build that produced it (such as the + # standalone subtarget), so restoring another configuration's Library + # changes what gets built. Bump the version to discard every Library cache. + key: Library-v2-${{ matrix.projectPath }}-macos-${{ matrix.targetPlatform }}-${{ matrix.unityVersion }}-il2cpp-true-subtarget-player-${{ matrix.buildProfile }} ########################### # Set Scripting Backend # diff --git a/.github/workflows/build-tests-ubuntu.yml b/.github/workflows/build-tests-ubuntu.yml index 6dfc96ff..7eb9c9bb 100644 --- a/.github/workflows/build-tests-ubuntu.yml +++ b/.github/workflows/build-tests-ubuntu.yml @@ -138,10 +138,11 @@ jobs: id: cache-restore with: path: ${{ matrix.projectPath }}/Library - key: Library-${{ matrix.projectPath }}-ubuntu-${{ matrix.targetPlatform }}-${{ matrix.unityVersion }}-${{ matrix.buildProfile }} - restore-keys: | - Library-${{ matrix.projectPath }}-ubuntu- - Library- + # One cache per build configuration and no prefix fallback: a Library + # remembers the settings of the build that produced it (such as the + # standalone subtarget), so restoring another configuration's Library + # changes what gets built. Bump the version to discard every Library cache. + key: Library-v2-${{ matrix.projectPath }}-ubuntu-${{ matrix.targetPlatform }}-${{ matrix.unityVersion }}-il2cpp-${{ matrix.buildWithIl2cpp == true }}-subtarget-${{ contains(matrix.additionalParameters, '-standaloneBuildSubtarget Server') && 'server' || 'player' }}-${{ matrix.buildProfile }} ########################### # Set Scripting Backend # diff --git a/.github/workflows/build-tests-windows.yml b/.github/workflows/build-tests-windows.yml index 3cf89315..725668a2 100644 --- a/.github/workflows/build-tests-windows.yml +++ b/.github/workflows/build-tests-windows.yml @@ -66,10 +66,11 @@ jobs: id: cache-restore with: path: ${{ matrix.projectPath }}/Library - key: Library-${{ matrix.projectPath }}-windows-${{ matrix.targetPlatform }}-${{ matrix.unityVersion }}-${{ matrix.buildProfile }} - restore-keys: | - Library-${{ matrix.projectPath }}-windows- - Library- + # One cache per build configuration and no prefix fallback: a Library + # remembers the settings of the build that produced it (such as the + # standalone subtarget), so restoring another configuration's Library + # changes what gets built. Bump the version to discard every Library cache. + key: Library-v2-${{ matrix.projectPath }}-windows-${{ matrix.targetPlatform }}-${{ matrix.unityVersion }}-il2cpp-true-subtarget-player-${{ matrix.buildProfile }} ########################### # Set Scripting Backend #