Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
ci(verify): reuse cached builds of unchanged workspace crates, README
Richie McIlroy2056e40e3648
diff --git a/.github/actions/engine-verify-setup/action.yml b/.github/actions/engine-verify-setup/action.ymlindex 646c74269..0869aff92 100644--- a/.github/actions/engine-verify-setup/action.yml+++ b/.github/actions/engine-verify-setup/action.yml@@ -54,8 +54,17 @@ runs:prefix-key: v1-verifyshared-key: ${{ inputs.target }}cache-bin: "false"+ cache-workspace-crates: "true"save-if: ${{ inputs.save-cache }}+ # Unchanged workspace crates are reused from the cache instead of being+ # rebuilt because the checkout touched every file (scripts/verify/mtime.py).+ - name: Reuse unchanged workspace crates+ if: inputs.rust-cache == 'true'+ shell: bash+ run: |+ "$(command -v python3 || command -v python)" scripts/verify/mtime.py apply target/ci-verify/.fingerprint/cap-verify-srcmanifest+- name: Native dependenciesshell: bashenv:diff --git a/.github/workflows/engine-verify-os.yml b/.github/workflows/engine-verify-os.ymlindex b301cd2e2..121a11b19 100644--- a/.github/workflows/engine-verify-os.yml+++ b/.github/workflows/engine-verify-os.yml@@ -82,6 +82,12 @@ jobs:scripts/verify/run.sh "${{ inputs.tier }}" --suites "${{ inputs.suites }}" --no-runfi+ - name: Record sources of the cached build+ if: inputs.save-cache+ shell: bash+ run: |+ "$(command -v python3 || command -v python)" scripts/verify/mtime.py record target/ci-verify/.fingerprint/cap-verify-srcmanifest+- name: Upload test archiveif: inputs.shards > 1uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2diff --git a/crates/verify/README.md b/crates/verify/README.mdnew file mode 100644index 000000000..c7413367b--- /dev/null+++ b/crates/verify/README.md@@ -0,0 +1,110 @@+# cap-verify: engine verification suite++Oracle tests for the playback, export, recording, editing and captions engines.+Fixtures are generated by code at test time. Every source video frame carries+its own identity as a block code, and every audio source carries+sample-accurate markers. An independent reference model computes which source+frame and sample each output frame and sample must show. A case passes only+when every checked frame and sample matches.++## Suites++The suites are listed in `scripts/verify/suites.json`:++| Suite | What it checks | FAST tier | FULL tier |+| --- | --- | --- | --- |+| `verify-self` | marker codecs, reference model, report | linux | linux, macos |+| `export` | every exported frame (MP4, GIF, both decoders on macOS) | linux, macos, windows | all |+| `playback` | offline-driven editor playback frames | linux, macos | all |+| `seek` | random, keyframe and scrub seeks | linux, macos | all |+| `decoder-model-ffmpeg` | FFmpeg decoder decisions on scripted media (`cap-rendering` `decoder::model`) | linux | linux |+| `decoder-model-avf` | AVAssetReader decoder decisions on scripted media | macos | macos |++Platform-independent logic runs on Linux only in CI. Suites that test platform+code run on that platform: AVFoundation, VideoToolbox and Metal on macOS;+Media Foundation, Direct3D and WASAPI on Windows. When you run the suite+locally, the platform-independent suites run on every OS.++`CAP_VERIFY_TIER=full` (the FULL tier) uses longer fixtures and more seeds.++## Running locally++```sh+scripts/verify/run.sh fast # what CI runs on this OS for a PR+scripts/verify/run.sh full # merge-queue and nightly tier+scripts/verify/run.sh fast --suites seek # one suite+scripts/verify/run.sh fast --case 'export/basic/*'+scripts/verify/run.sh fast --list # print the plan+```++Install cargo-nextest (`cargo install cargo-nextest --locked`) to run the+tests in parallel, one process per test. Without it, the script runs+`cargo test` per suite. The local run uses the `dev` profile and shares its+build with normal development. CI uses the `ci-verify` profile+(`CAP_VERIFY_CARGO_PROFILE=ci-verify`). Generated fixtures are cached in+`target/verify-fixtures`, or in `CAP_VERIFY_FIXTURE_DIR` when it is set.++Every failure prints the exact frames or samples that are wrong, the seed,+and a one-line repro command, for example:++```sh+CAP_VERIFY_CASE='export/backward-hold/backward-jumps/mp460/avf' CAP_VERIFY_TIER=fast cargo test -p cap-verify --test export -- --nocapture+CAP_DECODER_MODEL_CASE=decoder-model/avf/syn/edlist/playback CAP_DECODER_MODEL_SEED_INDEX=3 cargo test -p cap-rendering --lib decoder::model::avassetreader_answers_match_the_reference_model -- --nocapture+```++## Known failures: strict expectations++Known bugs on `main` are strict expected failures. They are listed in+`crates/verify/expectations.toml` and in+`crates/rendering/src/decoder/model/expectations.toml`, using the format from+`crates/verify-expect`:++```toml+[[xfail]]+case = "export/early-camera/full/*" # case id, * globs allowed+class = "future" # failure class that must still occur+platforms = ["macos"] # optional, absent = every platform+seeds = "0 3-7" # optional, seeded suites only+flaky = true # optional; state the measured rate+reason = "what is wrong"+link = "https://github.com/CapSoftware/Cap/pull/2595" # empty = no fix yet+```++- A failure that is not listed fails the run.+- A listed class or seed that no longer fails also fails the run, with+ "remove this xfail". When a fix lands, its expected failures must be removed+ in the same PR, so the fix is locked in.++To update the files after a deliberate change, run:++```sh+scripts/verify/bless.sh fast # run here and rewrite from the results+scripts/verify/bless.sh --run <run id> # rewrite from a CI run, all three OSes+```++Bless changes only the entries of the platforms that ran. It keeps the+reasons and links of existing entries, and gives each new failure a `TODO:`+reason. Replace every `TODO:` reason before you merge. Review the diff: a+blessed failure is a bug that the suite keeps checking.++## CI++`.github/workflows/engine-verify.yml`:++- **Plan.** `scripts/verify/plan.py` maps the changed paths to suites through+ the workspace dependency graph (`cargo metadata`). A PR that changes only+ docs, the web app or GPUI UI code runs no suite, and the job finishes in+ seconds.+- **Tiers.** FAST runs on every PR push. FULL runs when the PR has the+ `verify-full` label, in the merge queue, and nightly.+- **Jobs.** One job per platform builds the selected tests with the+ `ci-verify` profile and runs them with nextest. Dependencies are optimised+ and cached; workspace crates are not optimised. A platform with+ `shards > 1` in `suites.json` uploads a nextest archive, and shard jobs run+ partitions of it.+- **No retries.** A failed test is rerun once only so that the summary can+ label it flaky. The job still fails.+- **Summary.** Each job summary lists the failing cases, their exact frames+ or samples, and a repro command. The report records are uploaded as the+ `verify-report-*` artifacts, which `bless.sh --run` reads.+- **Gate.** Make the `Engine verify` job a required check.diff --git a/scripts/verify/mtime.py b/scripts/verify/mtime.pynew file mode 100644index 000000000..12bfb656c--- /dev/null+++ b/scripts/verify/mtime.py@@ -0,0 +1,77 @@+#!/usr/bin/env python3+"""Lets cargo reuse cached builds of unchanged workspace crates in CI.++Cargo decides whether a workspace crate is fresh by comparing the mtimes of+its source files with its last build. A fresh checkout gives every file the+current time, so every workspace crate would rebuild even when the Rust cache+holds an up-to-date build.++ mtime.py record <manifest> after a build: record the git blob id of every+ tracked file (stored inside the cached target)+ mtime.py apply <manifest> after restoring the cache: files whose blob id+ matches the manifest get an old fixed mtime, so+ cargo sees them as unchanged; every other file+ keeps the checkout time and its crate rebuilds++Only content equality is trusted, never commit times, so a stale build cannot+be reused for changed code.+"""++import os+import subprocess+import sys++OLD = 946684800 # 2000-01-01+++def blobs():+ out = subprocess.run(+ ["git", "ls-files", "-s", "-z"], check=True, capture_output=True+ ).stdout.decode("utf-8", "surrogateescape")+ entries = {}+ for item in out.split("\0"):+ if not item:+ continue+ meta, path = item.split("\t", 1)+ entries[path] = meta.split()[1]+ # The index ids only describe the files when the work tree matches it.+ dirty = subprocess.run(+ ["git", "diff", "--name-only", "-z"], check=True, capture_output=True+ ).stdout.decode("utf-8", "surrogateescape")+ for path in filter(None, dirty.split("\0")):+ entries[path] = "dirty"+ return entries+++def main():+ if len(sys.argv) != 3 or sys.argv[1] not in ("record", "apply"):+ sys.exit(__doc__)+ command, manifest = sys.argv[1], sys.argv[2]+ current = blobs()+ if command == "record":+ os.makedirs(os.path.dirname(os.path.abspath(manifest)), exist_ok=True)+ with open(manifest, "w", encoding="utf-8", errors="surrogateescape") as f:+ for path, blob in sorted(current.items()):+ f.write(f"{blob} {path}\n")+ print(f"recorded {len(current)} files in {manifest}")+ return+ if not os.path.exists(manifest):+ print(f"no manifest at {manifest}: every workspace crate rebuilds")+ return+ saved = {}+ with open(manifest, encoding="utf-8", errors="surrogateescape") as f:+ for line in f:+ blob, _, path = line.rstrip("\n").partition(" ")+ saved[path] = blob+ same = changed = 0+ for path, blob in current.items():+ if blob != "dirty" and saved.get(path) == blob and os.path.isfile(path) and not os.path.islink(path):+ os.utime(path, (OLD, OLD))+ same += 1+ else:+ changed += 1+ print(f"{same} files unchanged since the cached build, {changed} changed or new")+++if __name__ == "__main__":+ main()