Skip to content

ci: add the missing writer for the release-asset cache transport - #5541

Merged
zackees merged 3 commits into
masterfrom
feat/precache-release-assets
Nov 25, 2026
Merged

zackees merged 3 commits into
masterfrom
feat/precache-release-assets

Conversation

@zackees

@zackees zackees commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

The Actions cache is the only cross-job store today and ci.toml bounds it at
10 GB with default-branch-only writes, so the six app-build families left it in
Phase A of #1801 ("the release-asset transport (#782) can bring them back
outside this budget"). Nothing implemented that transport: fetch_libs_asset.py
could only read a pinned release asset, and nothing here could write one.

This adds the writer, the reader that discovers the pin, and the fixes found by
running both halves against the real store.

The store

ci/precache.py publishes to one rolling prerelease, ci-cache, in
obs-rust/obs-studio-libs:

cache-<family>-<platform>-<identity>.tar.zst
cache-<family>-<platform>-<identity>.manifest.json   (the pin: sha256, size, entries)

The manifest exists because fetch_libs_asset.fetch deliberately requires a
sha256 while a cache changes on every master push: the consumer reads the small
manifest, then fetches the blob through the same verified path Qt and FFmpeg
already use.

Verified end to end, live

Defects this fixes (all found by that run)

  1. The first push could never work. gh release upload fails when the
    release does not exist, and nothing creates ci-cache. push now creates it
    as a prerelease with --latest=false, so it never takes the libs repo's
    "Latest" slot from the dependency releases.
  2. Restores picked the wrong cache. pull took sorted(glob)[-1] — the
    lexicographically largest manifest — while identities embed toolchain and
    soldr versions (rustc1.98.1 sorts before rustc1.101.0). It now takes the
    newest release-asset timestamp; --identity pins an exact one; nothing
    published exits NO_CACHE (3) so a caller can distinguish a miss from a
    restore.
  3. Restores polluted the cache and could silently no-op. Extraction went
    straight into the destination, leaving fetch_libs_asset's .asset-sha256
    marker inside the cache tree. That marker is also fetch's "already
    downloaded" shortcut, so the next pull into the same directory would skip
    as a hit and a newer identity would never land. Extraction is now staged and
    merged without the stamp.
  4. The documented CLI order (FAMILY PLATFORM IDENTITY DIR) did not match the
    parser.

Not in this PR

No workflow writes or restores a real cache yet — that is the follow-up
(producers/consumers per platform, identity derived from
ci/native_cache_identity.py so both halves agree).

ci.toml says the six app-build families that left the Actions cache in Phase A
of #1801 can come back "outside this budget" via the release-asset transport
(#782). Only half of that existed: ci/fetch_libs_asset.py reads a pinned asset
from obs-rust/obs-studio-libs releases and verifies its sha256, and nothing in
the repo could write one.

Add ci/precache.py with the two verbs that close the loop:

  push FAMILY PLATFORM IDENTITY DIR   pack, digest, upload blob + manifest
  pull FAMILY PLATFORM DIR            read the manifest, then fetch the blob

The manifest exists because fetch() deliberately requires a sha256 while a
cache moves on every master push: the consumer downloads a few hundred bytes of
JSON, reads the digest, and then goes through the same verified path the Qt and
FFmpeg bundles already use. One reader for every big verified archive.

Packing is reproducible: members are sorted and ownership is zeroed, so
re-pushing an unchanged cache produces the identical digest and the upload is a
no-op. mtimes are deliberately preserved -- cargo and zccache compare them, and
normalising them would publish a cache that looks valid and silently rebuilds
everything.

Nothing calls it yet. Wiring a family is a behaviour change (which lane writes,
which lane restores, what happens on a miss) and belongs in its own review.
Two gate failures on the first push:

- RUF100 flagged `# noqa: E402` as unused, because ruff.toml enables only
  C901 and RUF100 -- E402 is not on, so the directive suppressed nothing.
- ci/test_no_sys_path_edits.py refused the `sys.path.insert`: `uv run
  ci/precache.py` already puts ci/ on sys.path, so the sibling import works
  by name, and the test's whole point is that a module should say where it
  comes from rather than mutate the search path.

The test now imports `precache` by name like the other ci/ tests import their
siblings.
Three defects found while proving the transport end to end against the real
`obs-rust/obs-studio-libs` release:

- `push` assumed the `ci-cache` release already existed, but nothing creates
  it -- and `gh release upload` fails outright when it is missing, so the first
  cache of a family could never be published. It is now created on first use as
  a prerelease with `--latest=false`, so it never takes the libs repository's
  "Latest" slot from the dependency releases.
- `pull` took `sorted(glob)[-1]`, i.e. the lexicographically largest manifest.
  Identities embed toolchain and soldr versions (`rustc1.98.1` sorts before
  `rustc1.101.0`), so that restores an older cache as soon as two versions
  coexist. It now takes the newest release-asset timestamp, and `--identity`
  pins an exact one. Nothing published exits NO_CACHE (3) so a caller can tell
  a miss from a restore.
- `pull` extracted straight into the destination, leaving `fetch_libs_asset`'s
  `.asset-sha256` marker inside the cache tree; worse, that marker makes the
  next pull into the same directory skip as a hit, so a newer identity would
  silently never land. Extraction is staged and merged without the stamp.

Also fixed the documented CLI order (FAMILY PLATFORM IDENTITY DIR) to match the
parser.

Verified against the live store: pushed a 114-entry probe tree to
`ci-cache`, pulled it back and compared -- 65/65 files byte-identical, no stamp
left behind. 15 unit tests pass.
@zackees
zackees added this pull request to the merge queue Nov 25, 2026
Merged via the queue into master with commit da62f89 Nov 25, 2026
43 checks passed
@zackees
zackees deleted the feat/precache-release-assets branch November 25, 2026 03:30
@obs-rust-project-manager obs-rust-project-manager Bot moved this from Ready to merge to Done in obs-rust Multiview Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant