Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

ci(verify): Windows real capture records its cache manifest, and a cached build without one is rebuilt

Richie McIlroy57f841195432
diff --git a/.github/workflows/verify-recording.yml b/.github/workflows/verify-recording.yml
index 392e6ba46..671fe6b73 100644
--- a/.github/workflows/verify-recording.yml
+++ b/.github/workflows/verify-recording.yml
@@ -386,8 +386,16 @@ jobs:
cargo test --locked --profile ci-verify -p cap-verify --test recording --no-run
echo "build seconds: $(( $(date +%s) - start ))"
+ # Without the manifest the next restore cannot tell which sources the
+ # cached build came from (scripts/verify/mtime.py).
+ - name: Record sources of the cached build
+ if: github.event_name != 'pull_request' && steps.setup.outputs.build-cache-hit != 'true'
+ shell: bash
+ run: |
+ "$(command -v python3 || command -v python)" scripts/verify/mtime.py record target/ci-verify/verify-src-manifest.txt
+
- name: Save build cache
- if: steps.setup.outputs.build-cache-hit != 'true'
+ if: github.event_name != 'pull_request' && steps.setup.outputs.build-cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: |
diff --git a/scripts/verify/mtime.py b/scripts/verify/mtime.py
index 4de0229d6..379f658e7 100644
--- a/scripts/verify/mtime.py
+++ b/scripts/verify/mtime.py
@@ -12,8 +12,10 @@ holds an up-to-date build.
the manifest get an old fixed mtime, so cargo
sees them as unchanged; every other file keeps
the checkout time and its crate rebuilds. With
- no manifest (cold build) every file gets the
- fixed time.
+ no manifest and no cached build (cold build)
+ every file gets the fixed time; a cached build
+ without a manifest is not trusted, and every
+ file gets the current time.
Only content equality is trusted, never commit times, so a stale build cannot
be reused for changed code.
@@ -64,6 +66,15 @@ def main():
for line in f:
blob, _, path = line.rstrip("\n").partition(" ")
saved[path] = blob
+ elif os.path.isdir(os.path.dirname(manifest)) and os.listdir(os.path.dirname(manifest)):
+ # A cached build saved without a manifest: nothing says which sources
+ # it was built from, and the fixed time would make cargo reuse all of
+ # it. Every file gets the current time, so every crate rebuilds.
+ print(f"no manifest at {manifest} beside a cached build: rebuilding every crate")
+ for path in current:
+ if os.path.isfile(path) and not os.path.islink(path):
+ os.utime(path, None)
+ return
else:
# Cold build: give every file the fixed time too. Build scripts
# without rerun-if-changed fingerprint the newest mtime of their