Skip to content

Save vcpkg archives before the build and prefer matching ones - #691

Open
mtrojnar wants to merge 1 commit into
masterfrom
ci/vcpkg-cache-save-early
Open

mtrojnar wants to merge 1 commit into
masterfrom
ci/vcpkg-cache-save-early

Conversation

@mtrojnar

@mtrojnar mtrojnar commented Nov 5, 2026 •

Copy link
Copy Markdown
Member

Problem

The Windows jobs cache vcpkg's OpenSSL archives with the combined actions/cache step, which saves only if the whole job succeeds. A failed build therefore discards a freshly built OpenSSL. In the pkcs11-uri runs on 6 Oct, for example, the first run failed and the next push spent another 7–9 minutes per architecture rebuilding OpenSSL.

The restore fallback <id>-vcpkg- has a second weakness. A pull-request run searches all of its own keys before any master cache, so a PR's older archive wins over a master archive that matches the current runner image and vcpkg revision. vcpkg then rejects every package and rebuilds.

Fix

  • Save the archives straight after vcpkg install, in a separate step, so build failures no longer lose them.
  • Restore in two steps. The first accepts only archives for the current image and vcpkg revision, from any scope. The second falls back to older archives only if the first finds none.

Validation

No cache existed in this repository, so both CI runs on this PR tested the build-and-save path:

  • First run: both Windows jobs found no cache, rebuilt OpenSSL, passed, and saved new keys straight after vcpkg install.
  • Rerun: both jobs landed on a different runner image (images 20261026 and 20261101 are currently mixed). Step 1 found nothing for the current image, and step 2 restored the other image's archives. This repository's vcpkg packages use the image's C:/vcpkg checkout, so their ABIs differ between images: vcpkg rebuilt OpenSSL and saved a key for that image too.

Later runs on either image should now get an exact hit.

The combined actions/cache step saved the vcpkg archives only when the
whole job succeeded. A failed Windows build therefore discarded a
freshly built OpenSSL, and the next push rebuilt it again (6-9 minutes
per architecture).

Restore and save in separate steps, saving straight after vcpkg
install. Also restore in two steps: a pull-request run searches all of
its own keys before any base-branch cache, so the broad fallback could
restore a stale PR archive even when master had one matching the
current runner image and vcpkg revision. Accept only matching archives
first, from any scope, and fall back to older ones only if none exists.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant