ci: a vcpkg binary cache that works for CI runs; drop rust-cache from the Flutter builds (#17300)

* ci: give CI runs a vcpkg binary cache that works, saved from master only

vcpkg removed its x-gha backend, so every run builds the vcpkg ports from
source, 6 to 22 minutes per job. CI runs that publish nothing now restore the
vcpkg binary packages that the last master push saved for the same job,
through vcpkg's files backend and actions/cache, and a run saves only when it
built a package the cache lacked. Builds that publish (nightly, tags) set
VCPKG_BINARY_SOURCES to `clear` and never touch the cache.

rust-cache entries are 1.3 to 2.2 GB each and every PR saved its own, so
within the 10 GB limit they evicted master's and most runs missed. They are
now saved from master only; PRs still restore master's.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JAxkkiaGp2k8okvs4MpCUq

* DO NOT MERGE: let this PR's runs save the vcpkg cache, to test restoring it

* ci: drop rust-cache from the Flutter builds; save ci.yml's from master only

In the last two PR CI runs all 20 rust-cache restores in flutter-build.yml
and bridge.yml found nothing, and so did every job of the 2026-11-28 nightly.
Saving the ~2 GB entries still took up to 3.3 minutes per job and kept the
repository's cache above its 10 GB limit, which evicted most of the new vcpkg
entries within an hour of their first save. ci.yml keeps its rust-cache, but
only master saves it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JAxkkiaGp2k8okvs4MpCUq

* Revert the temporary save-on-PR commit

With it, this PR's runs saved the vcpkg cache, and a rerun of the Android
x86_64 job restored all 20 packages from it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JAxkkiaGp2k8okvs4MpCUq

* ci: keep only the current vcpkg packages in a saved entry; drop the iOS wiring

The save step now deletes the restored zips that no package installed by
this run uses before it saves. Otherwise each compiler, vcpkg commit or
port change carried the whole old set into every later entry, so an entry
grew by a full 32 to 104 MB set per such change, not by a few MB.

The iOS job runs only in builds that publish, where the restore and save
steps are skipped, so its wiring never ran: remove it.

Say that rust-cache rarely hit rather than never: macOS x64 had a hit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JAxkkiaGp2k8okvs4MpCUq

* ci: keep the bridge's rust-cache, saved from master only; log the vcpkg pruning

Every platform job waits for generate-bridge, which without rust-cache
compiles cargo-expand and flutter_rust_bridge_codegen from source on every
run (2 to 3 minutes). Its entry is about 1 GB, one per run rather than one
per platform job, so keep it and save it from master only, as ci.yml does.

The vcpkg save step now logs how many zips it kept and removed, and warns
when the status file is missing, so the first master run shows the pruning
working on each platform.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JAxkkiaGp2k8okvs4MpCUq

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
RustDeskandClaude Opus 5.5 authored and GitHub committed 2026-11-29 22:14:40 +08:00
1 parent aedb901f10
commit a98982d702
5 files changed
+147 -29

No files matched your search

@@ -0,0 +1,30 @@
name: Restore the vcpkg binary cache
description: >-
For CI runs that publish nothing. Restores the vcpkg binary packages a master push saved for
this job, and outputs the VCPKG_BINARY_SOURCES value that reads and extends them.
inputs:
name:
description: Tells this job's cache apart from the others, e.g. its Rust target.
required: true
outputs:
binary-sources:
description: The value to give VCPKG_BINARY_SOURCES.
value: ${{ steps.dir.outputs.binary-sources }}
runs:
using: composite
steps:
- id: dir
shell: bash
run: |
# vcpkg wants a native path; on Windows, cygpath turns RUNNER_TEMP into one with forward slashes.
dir="$(cygpath -m "$RUNNER_TEMP" 2>/dev/null || echo "$RUNNER_TEMP")/vcpkg-bincache"
mkdir -p "$dir"
echo "binary-sources=clear;files,$dir,readwrite" >> "$GITHUB_OUTPUT"
- uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ${{ runner.temp }}/vcpkg-bincache
key: vcpkg-bin-${{ runner.os }}-${{ runner.arch }}-${{ inputs.name }}-${{ github.run_id }}-${{ github.run_attempt }}
restore-keys: vcpkg-bin-${{ runner.os }}-${{ runner.arch }}-${{ inputs.name }}-
# vcpkg-cache-save compares against this to tell whether the run built any package.
- shell: bash
run: touch "$(cygpath -m "$RUNNER_TEMP" 2>/dev/null || echo "$RUNNER_TEMP")/vcpkg-bincache/.restored"
@@ -0,0 +1,36 @@
name: Save the vcpkg binary cache
description: >-
Saves what vcpkg-cache-restore set up, but only when this run built a package that was not in
the cache, so an unchanged run does not store another copy.
inputs:
name:
description: The same name that was given to vcpkg-cache-restore.
required: true
runs:
using: composite
steps:
- id: built
shell: bash
run: |
dir="$(cygpath -m "$RUNNER_TEMP" 2>/dev/null || echo "$RUNNER_TEMP")/vcpkg-bincache"
if [ -n "$(find "$dir" -name '*.zip' -newer "$dir/.restored" -print -quit)" ]; then
echo "any=true" >> "$GITHUB_OUTPUT"
# Drop the zips no installed package uses (an older compiler, vcpkg commit or port
# version), or every later entry carries them along and the entry only grows.
status="$VCPKG_ROOT/installed/vcpkg/status"
if [ -s "$status" ]; then
keep="$(sed -n 's/^Abi: //p' "$status" | tr -d '\r')"
removed=0
while read -r z; do
grep -qxF "$(basename "$z" .zip)" <<<"$keep" || { rm -f "$z"; removed=$((removed + 1)); }
done < <(find "$dir" -name '*.zip')
echo "Kept $(find "$dir" -name '*.zip' | wc -l | tr -d ' ') package zip(s), removed $removed."
else
echo "::warning::$status not found: saving every zip, so the entry keeps the old packages."
fi
fi
- if: steps.built.outputs.any == 'true'
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ${{ runner.temp }}/vcpkg-bincache
key: vcpkg-bin-${{ runner.os }}-${{ runner.arch }}-${{ inputs.name }}-${{ github.run_id }}-${{ github.run_attempt }}
+2
View File
@@ -78,6 +78,8 @@ jobs:
if: ${{ inputs.use-cache }}
with:
prefix-key: bridge-${{ matrix.job.os }}
# As in ci.yml: PRs restore master's entry instead of each saving its own.
save-if: ${{ github.ref == 'refs/heads/master' }}
- name: Cache Bridge
id: cache-bridge
+3
View File
@@ -173,6 +173,9 @@ jobs:
rustc -V
- uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2
with:
# PRs restore master's entry; letting each PR save its own ~2 GB evicts the other caches.
save-if: ${{ github.ref == 'refs/heads/master' }}
- name: Build
uses: actions-rs/cargo@844f36862e911db73fe0815f00a4a2602c279505 # v1
+76 -29
View File
@@ -66,9 +66,10 @@ env:
SIGN_BASE_URL: "${{ secrets.SIGN_BASE_URL }}-2"
# Builds that publish (upload-artifact: nightly and tags) neither restore nor save a cache: the
# rust-cache, run-vcpkg, run-on-arch image and bridge caches are skipped there, and so is exporting
# vcpkg binary, run-vcpkg, run-on-arch image and bridge caches are skipped there, and so is exporting
# the cache token to the build steps. Other workflow runs can write those caches, so a published
# binary must not be built from one. CI runs keep them.
# binary must not be built from one. CI runs keep them. There is no rust-cache here: its ~2 GB
# entries rarely hit within the repository's 10 GB cache limit and evicted everything else.
jobs:
validate-update-metadata-keys:
runs-on: ubuntu-22.04
@@ -317,11 +318,6 @@ jobs:
targets: ${{ matrix.job.target }}
components: "rustfmt"
- uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2
if: ${{ !inputs.upload-artifact }}
with:
prefix-key: ${{ matrix.job.os }}
- name: Setup vcpkg with Github Actions binary cache
uses: lukka/run-vcpkg@b1a0dd252f06b9e25b3c022a9a03bd7a427fb6a2 # v11
with:
@@ -329,8 +325,16 @@ jobs:
vcpkgGitCommitId: ${{ env.VCPKG_COMMIT_ID }}
doNotCache: ${{ inputs.upload-artifact }}
- name: Restore vcpkg binary cache
id: vcpkg-cache
if: ${{ !inputs.upload-artifact }}
uses: ./.github/actions/vcpkg-cache-restore
with:
name: ${{ matrix.job.target }}
- name: Install vcpkg dependencies
env:
VCPKG_BINARY_SOURCES: ${{ steps.vcpkg-cache.outputs.binary-sources || 'clear' }}
VCPKG_DEFAULT_HOST_TRIPLET: ${{ matrix.job.vcpkg-triplet }}
run: |
if ! $VCPKG_ROOT/vcpkg \
@@ -349,6 +353,12 @@ jobs:
head -n 100 "${VCPKG_ROOT}/buildtrees/ffmpeg/build-${{ matrix.job.vcpkg-triplet }}-rel-out.log" || true
shell: bash
- name: Save vcpkg binary cache
if: ${{ !inputs.upload-artifact && github.ref == 'refs/heads/master' }}
uses: ./.github/actions/vcpkg-cache-save
with:
name: ${{ matrix.job.target }}
- name: Set SODIUM_LIB_DIR (arm64)
# libsodium-sys ships no arm64 Windows prebuilt lib; point it at the vcpkg-built one
# (only for arm64 — leaving it unset lets x64 use the crate's bundled lib).
@@ -663,11 +673,6 @@ jobs:
--profile minimal --no-self-update --force-non-host
rustup default nightly-2023-10-13-${{ matrix.job.target }} --force-non-host
- uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2
if: ${{ !inputs.upload-artifact }}
with:
prefix-key: ${{ matrix.job.os }}-sciter
- name: Setup vcpkg with Github Actions binary cache
uses: lukka/run-vcpkg@b1a0dd252f06b9e25b3c022a9a03bd7a427fb6a2 # v11
with:
@@ -675,8 +680,16 @@ jobs:
vcpkgGitCommitId: ${{ env.VCPKG_COMMIT_ID }}
doNotCache: ${{ inputs.upload-artifact }}
- name: Restore vcpkg binary cache
id: vcpkg-cache
if: ${{ !inputs.upload-artifact }}
uses: ./.github/actions/vcpkg-cache-restore
with:
name: ${{ matrix.job.target }}
- name: Install vcpkg dependencies
env:
VCPKG_BINARY_SOURCES: ${{ steps.vcpkg-cache.outputs.binary-sources || 'clear' }}
VCPKG_DEFAULT_HOST_TRIPLET: ${{ matrix.job.vcpkg-triplet }}
run: |
if ! $VCPKG_ROOT/vcpkg \
@@ -695,6 +708,12 @@ jobs:
head -n 100 "${VCPKG_ROOT}/buildtrees/ffmpeg/build-${{ matrix.job.vcpkg-triplet }}-rel-out.log" || true
shell: bash
- name: Save vcpkg binary cache
if: ${{ !inputs.upload-artifact && github.ref == 'refs/heads/master' }}
uses: ./.github/actions/vcpkg-cache-save
with:
name: ${{ matrix.job.target }}
- name: Build rustdesk
id: build
shell: bash
@@ -901,12 +920,6 @@ jobs:
targets: ${{ matrix.job.target }}
components: "rustfmt"
- uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2
if: ${{ !inputs.upload-artifact }}
with:
prefix-key: rustdesk-lib-cache-ios
key: ${{ matrix.job.target }}
- name: Restore bridge files
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
@@ -1098,11 +1111,6 @@ jobs:
targets: ${{ matrix.job.target }}
components: "rustfmt"
- uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2
if: ${{ !inputs.upload-artifact }}
with:
prefix-key: ${{ matrix.job.os }}
- name: Restore bridge files
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
@@ -1122,7 +1130,16 @@ jobs:
vcpkgGitCommitId: ${{ env.VCPKG_COMMIT_ID }}
doNotCache: ${{ inputs.upload-artifact }}
- name: Restore vcpkg binary cache
id: vcpkg-cache
if: ${{ !inputs.upload-artifact }}
uses: ./.github/actions/vcpkg-cache-restore
with:
name: ${{ matrix.job.target }}
- name: Install vcpkg dependencies
env:
VCPKG_BINARY_SOURCES: ${{ steps.vcpkg-cache.outputs.binary-sources || 'clear' }}
run: |
if ! $VCPKG_ROOT/vcpkg \
install \
@@ -1138,6 +1155,12 @@ jobs:
fi
head -n 100 "${VCPKG_ROOT}/buildtrees/ffmpeg/build-${{ matrix.job.vcpkg-triplet }}-rel-out.log" || true
- name: Save vcpkg binary cache
if: ${{ !inputs.upload-artifact && github.ref == 'refs/heads/master' }}
uses: ./.github/actions/vcpkg-cache-save
with:
name: ${{ matrix.job.target }}
- name: Show version information (Rust, cargo, Clang)
shell: bash
run: |
@@ -1604,7 +1627,16 @@ jobs:
vcpkgGitCommitId: ${{ env.VCPKG_COMMIT_ID }}
doNotCache: ${{ inputs.upload-artifact }}
- name: Restore vcpkg binary cache
id: vcpkg-cache
if: ${{ !inputs.upload-artifact }}
uses: ./.github/actions/vcpkg-cache-restore
with:
name: ${{ matrix.job.target }}
- name: Install vcpkg dependencies
env:
VCPKG_BINARY_SOURCES: ${{ steps.vcpkg-cache.outputs.binary-sources || 'clear' }}
run: |
case ${{ matrix.job.target }} in
aarch64-linux-android)
@@ -1632,6 +1664,12 @@ jobs:
fi
shell: bash
- name: Save vcpkg binary cache
if: ${{ !inputs.upload-artifact && github.ref == 'refs/heads/master' }}
uses: ./.github/actions/vcpkg-cache-save
with:
name: ${{ matrix.job.target }}
- name: Restore bridge files
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
@@ -1644,12 +1682,6 @@ jobs:
toolchain: ${{ env.RUST_VERSION }}
components: "rustfmt"
- uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2
if: ${{ !inputs.upload-artifact }}
with:
prefix-key: rustdesk-lib-cache-android # TODO: drop '-android' part after caches are invalidated
key: ${{ matrix.job.target }}
- name: Build rustdesk lib
env:
ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }}
@@ -2077,8 +2109,17 @@ jobs:
vcpkgGitCommitId: ${{ env.VCPKG_COMMIT_ID }}
doNotCache: ${{ inputs.upload-artifact }}
- name: Restore vcpkg binary cache
id: vcpkg-cache
if: ${{ !inputs.upload-artifact && (matrix.job.arch == 'x86_64' || env.UPLOAD_ARTIFACT == 'true') }}
uses: ./.github/actions/vcpkg-cache-restore
with:
name: ${{ matrix.job.target }}
- name: Install vcpkg dependencies
if: matrix.job.arch == 'x86_64' || env.UPLOAD_ARTIFACT == 'true'
env:
VCPKG_BINARY_SOURCES: ${{ steps.vcpkg-cache.outputs.binary-sources || 'clear' }}
run: |
sudo apt install -y libva-dev && apt show libva-dev
if ! $VCPKG_ROOT/vcpkg \
@@ -2097,6 +2138,12 @@ jobs:
head -n 100 "${VCPKG_ROOT}/buildtrees/ffmpeg/build-${{ matrix.job.vcpkg-triplet }}-rel-out.log" || true
shell: bash
- name: Save vcpkg binary cache
if: ${{ !inputs.upload-artifact && github.ref == 'refs/heads/master' && (matrix.job.arch == 'x86_64' || env.UPLOAD_ARTIFACT == 'true') }}
uses: ./.github/actions/vcpkg-cache-save
with:
name: ${{ matrix.job.target }}
- name: Restore bridge files
if: matrix.job.arch == 'x86_64' || env.UPLOAD_ARTIFACT == 'true'
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1