Improve caching.

This commit is contained in:
John Preston
2026-08-21 09:55:41 +04:00
parent 1a132f4dd2
commit fcec4e8257

View File

@@ -382,15 +382,23 @@ jobs:
nuget sources Disable -Name "Microsoft Visual Studio Offline Packages"
nuget sources Add -Source https://api.nuget.org/v3/index.json & exit 0
# The caches are restored/saved explicitly (not via the combined
# actions/cache) because the combined action only saves in a post
# step gated on job success: any later build or packing failure
# would discard hours of library builds. The explicit saves below
# run right after the libraries are pruned, before the fragile
# steps.
- name: ThirdParty cache.
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
id: cache-third-party
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
with:
path: ${{ env.TBUILD }}\ThirdParty
key: ${{ runner.OS }}-${{ runner.arch }}-third-party-${{ env.CACHE_KEY }}
restore-keys: ${{ runner.OS }}-${{ runner.arch }}-third-party-
- name: Libraries cache.
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
id: cache-libs
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
with:
path: |
${{ env.LibrariesPath }}\*
@@ -402,7 +410,8 @@ jobs:
restore-keys: ${{ runner.OS }}-x64-libs-v2rel-
- name: Qt cache.
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
id: cache-qt
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
with:
path: |
${{ env.LibrariesPath }}\[qQ]t[_-]*
@@ -434,6 +443,34 @@ jobs:
shell: bash
run: find $LibrariesPath '(' '(' ! '(' -name '*.lib' -o -name '*.a' -o -name '*.exe' -o -name '*.h' -o -name '*.hpp' -o -name '*.inc' -o -name '*.cmake' -o -name '*.pc' -o -path '*/include/*' -o -path '*/objects-*' -o -path '*/cache_keys/*' -o -path '*/patches/*' -o -path '*/nv-codec-headers/*' ')' -type f ')' -o -empty ')' -delete
- name: Save ThirdParty cache.
if: steps.cache-third-party.outputs.cache-hit != 'true'
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
with:
path: ${{ env.TBUILD }}\ThirdParty
key: ${{ steps.cache-third-party.outputs.cache-primary-key }}
- name: Save Libraries cache.
if: steps.cache-libs.outputs.cache-hit != 'true'
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
with:
path: |
${{ env.LibrariesPath }}\*
!${{ env.LibrariesPath }}\cache_keys
!${{ env.LibrariesPath }}\[qQ]t[_-]*
${{ env.LibrariesPath }}\cache_keys\*
!${{ env.LibrariesPath }}\cache_keys\[qQ]t[_-]*
key: ${{ steps.cache-libs.outputs.cache-primary-key }}
- name: Save Qt cache.
if: steps.cache-qt.outputs.cache-hit != 'true'
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
with:
path: |
${{ env.LibrariesPath }}\[qQ]t[_-]*
${{ env.LibrariesPath }}\cache_keys\[qQ]t[_-]*
key: ${{ steps.cache-qt.outputs.cache-primary-key }}
- name: Telegram Desktop build.
run: |
cd %TBUILD%\%REPO_NAME%\Telegram
@@ -622,8 +659,13 @@ jobs:
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
# Restore/save is explicit (not the combined actions/cache): the
# combined action saves in a post step gated on job success, so
# every failed signing or packing attempt was discarding the full
# library build. The save below runs right after the prune step.
- name: Libraries cache.
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
id: cache-libs
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
with:
path: |
Libraries
@@ -650,6 +692,15 @@ jobs:
- name: Free up some disk space.
run: find Libraries '(' '(' ! '(' -name '*.a' -o -name '*.h' -o -name '*.hpp' -o -name '*.inc' -o -name '*.cmake' -o -path '*/include/*' -o -path '*/objects-*' -o -path '*/cache_keys/*' -o -path '*/patches/*' -o -perm +111 ')' -type f ')' -o -empty ')' -delete
- name: Save Libraries cache.
if: steps.cache-libs.outputs.cache-hit != 'true'
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
with:
path: |
Libraries
ThirdParty
key: ${{ steps.cache-libs.outputs.cache-primary-key }}
- name: Telegram Desktop build.
run: |
cd $REPO_NAME/Telegram
@@ -886,14 +937,21 @@ jobs:
uses: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be
with:
tool-cache: true
# The default large-packages cleanup apt-removes azure-cli,
# which the azure/login step below needs for update signing.
large-packages: false
- name: Set up Docker Buildx.
id: setup-buildx
uses: docker/setup-buildx-action@37fe631027851001ddb9b187196cc803df7f5f0e # v4
# Restore/save is explicit (not the combined actions/cache): the
# combined action saves in a post step gated on job success, so
# every failed build or packing attempt was discarding the whole
# docker layer cache. The save runs right after "Move cache.".
- name: Libraries cache.
id: cache-libs
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
with:
path: |
${{ runner.temp }}/.buildx-cache
@@ -923,6 +981,20 @@ jobs:
rm -rf ${{ runner.temp }}/.buildx-cache
mv ${{ runner.temp }}/.buildx-cache{-new,}
# The saved .mount-cache is the restored one, not the state after
# this run's docker build (cache-dance only extracts in its post
# step, which is also success-gated): slightly stale ccache/dnf
# mounts only cost time when the Dockerfile hash changes, while
# the fresh layer cache above carries the actual library builds.
- name: Save Libraries cache.
if: steps.cache-libs.outputs.cache-hit != 'true'
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
with:
path: |
${{ runner.temp }}/.buildx-cache
${{ runner.temp }}/.mount-cache
key: ${{ steps.cache-libs.outputs.cache-primary-key }}
- name: Generate a stub DesktopPrivate.
run: |
mkdir -p ../DesktopPrivate