Skip to content

The agent that grows with you

fix caching and record

ethernet59b8eeb5c510
diff --git a/.github/actions/e2e-screen-record/action.yml b/.github/actions/e2e-screen-record/action.yml
index cf4eba87e72..a712ff9a4d5 100644
--- a/.github/actions/e2e-screen-record/action.yml
+++ b/.github/actions/e2e-screen-record/action.yml
@@ -14,6 +14,9 @@ inputs:
output:
description: Path of the recording (mkv).
required: true
+ save-cache:
+ description: Disable cache writes when the calling job has a read-only cache token.
+ default: 'true'
runs:
using: composite
@@ -69,7 +72,7 @@ runs:
- name: Restore cached ffmpeg (windows)
if: inputs.mode == 'start' && runner.os == 'Windows'
id: ffmpeg-cache
- uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5
+ uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5
with:
path: ${{ runner.temp }}\test-bins\ffmpeg
key: e2e-ffmpeg-${{ runner.os }}-v1
@@ -83,6 +86,13 @@ runs:
winget install -e --id Gyan.FFmpeg --silent --accept-source-agreements --accept-package-agreements --disable-interactivity --location "$env:RUNNER_TEMP\ffmpeg_dir"
Copy-Item -Path "$env:RUNNER_TEMP\ffmpeg_dir\*\*" -Destination $bins -Recurse -Force
+ - name: Save cached ffmpeg (windows)
+ if: inputs.mode == 'start' && runner.os == 'Windows' && inputs.save-cache == 'true' && steps.ffmpeg-cache.outputs.cache-hit != 'true'
+ uses: actions/cache/save@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5
+ with:
+ path: ${{ runner.temp }}\test-bins\ffmpeg
+ key: ${{ steps.ffmpeg-cache.outputs.cache-primary-key }}
+
- name: Add ffmpeg to PATH (windows)
if: inputs.mode == 'start' && runner.os == 'Windows'
shell: pwsh
diff --git a/.github/actions/setup-pm/action.yml b/.github/actions/setup-pm/action.yml
index 9fcc17c7c22..56bdda9d60a 100644
--- a/.github/actions/setup-pm/action.yml
+++ b/.github/actions/setup-pm/action.yml
@@ -13,6 +13,9 @@ inputs:
cache:
description: Cache the verified PM tool store.
default: 'true'
+ save-tools-cache:
+ description: Save the verified PM tools on success. Set false for restore-only jobs.
+ default: 'true'
cache-python:
description: Cache uv downloads and built wheels; never cache the dependency environment.
default: 'true'
@@ -63,7 +66,7 @@ outputs:
value: ${{ steps.prepare.outputs.target }}
tools-cache-hit:
description: Exact PM store cache hit.
- value: ${{ steps.tools-cache.outputs.cache-hit }}
+ value: ${{ steps.tools-cache.outputs.cache-hit || steps.tools-cache-restore.outputs.cache-hit }}
python-cache-hit:
description: Exact uv dependency cache hit.
value: ${{ steps.python-cache.outputs.cache-hit || steps.python-cache-restore.outputs.cache-hit }}
@@ -102,12 +105,20 @@ runs:
- name: Cache verified PM tools
id: tools-cache
- if: inputs.cache == 'true'
+ if: inputs.cache == 'true' && inputs.save-tools-cache == 'true'
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ${{ steps.prepare.outputs.store }}
key: setup-pm-tools-v1-${{ steps.prepare.outputs.target }}-${{ inputs.toolchain }}-${{ hashFiles('pm/lock.json') }}-${{ inputs.cache-suffix }}
+ - name: Restore verified PM tools without saving
+ id: tools-cache-restore
+ if: inputs.cache == 'true' && inputs.save-tools-cache == 'false'
+ uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
+ with:
+ path: ${{ steps.prepare.outputs.store }}
+ key: setup-pm-tools-v1-${{ steps.prepare.outputs.target }}-${{ inputs.toolchain }}-${{ hashFiles('pm/lock.json') }}-${{ inputs.cache-suffix }}
+
- name: Preserve and retrieve the pinned toolchain
if: inputs.archive-inputs == 'true'
shell: bash
diff --git a/.github/workflows/desktop-bundle-smoke.yml b/.github/workflows/desktop-bundle-smoke.yml
index 36ee497d4b6..dbc4b2d3c90 100644
--- a/.github/workflows/desktop-bundle-smoke.yml
+++ b/.github/workflows/desktop-bundle-smoke.yml
@@ -117,6 +117,7 @@ jobs:
uses: ./.github/actions/e2e-screen-record
with:
mode: start
+ save-cache: false
output: ${{ env.SMOKE_ROOT }}/out/recording.mkv
- name: Install and chat on macOS
diff --git a/.github/workflows/desktop-bundled-release.yml b/.github/workflows/desktop-bundled-release.yml
index f614957d608..ee1381d1a0f 100644
--- a/.github/workflows/desktop-bundled-release.yml
+++ b/.github/workflows/desktop-bundled-release.yml
@@ -347,11 +347,12 @@ jobs:
producer: desktop
key: ${{ steps.build-cache.outputs.cache-key }}
- - name: Cache verified payload signatures
- uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
+ - name: Restore verified payload signatures
+ id: payload-signatures
+ uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ${{ github.workspace }}/.cache/electron-builder-payload-signatures
- # Each run saves additions. Content and signing policy select entries.
+ # Release runs save additions. Content and signing policy select entries.
key: payload-signatures-v1-${{ runner.os }}-${{ matrix.target.label }}-${{ github.run_id }}-${{ github.run_attempt }}
restore-keys: |
payload-signatures-v1-${{ runner.os }}-${{ matrix.target.label }}-
@@ -405,6 +406,14 @@ jobs:
working-directory: apps/desktop
run: node ../../node_modules/vitest/vitest.mjs run --project electron scripts/payload-sign-cache.test.mjs scripts/batch-sign-binaries.test.mjs
+ # Commit jobs share these steps but have read-only cache tokens.
+ - name: Save verified payload signatures
+ if: inputs.build_commit == ''
+ uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
+ with:
+ path: ${{ github.workspace }}/.cache/electron-builder-payload-signatures
+ key: ${{ steps.payload-signatures.outputs.cache-primary-key }}
+
- name: Audit bundle architecture
shell: bash
run: |
@@ -859,6 +868,8 @@ jobs:
toolchain: all
archive-inputs: true
cache-python: false
+ save-tools-cache: false
+ save-node-cache: false
- name: Install the locked Windows bundle tooling
uses: ./.github/actions/retry
@@ -891,8 +902,8 @@ jobs:
*) echo "ELECTRON_DEFAULT_CACHE=$HOME/.cache/electron" >> "$GITHUB_ENV" ;;
esac
- - name: Cache electron + electron-builder toolchain
- uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
+ - name: Restore electron + electron-builder toolchain
+ uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: |
${{ github.workspace }}/.cache/electron-builder
diff --git a/tests/ci/test_desktop_bundle_smoke.py b/tests/ci/test_desktop_bundle_smoke.py
index 7db818b3c4a..a34a988b382 100644
--- a/tests/ci/test_desktop_bundle_smoke.py
+++ b/tests/ci/test_desktop_bundle_smoke.py
@@ -115,6 +115,32 @@ def test_native_consumers_and_publication_fail_closed_across_trust_skips(tmp_pat
assert (result.returncode == 0) is expected
+def test_signature_cache_saves_only_in_the_writable_build():
+ jobs = _workflow()['jobs']
+ for branch, commit in [('release', ''), ('commit', SHA)]:
+ job = jobs[f'build-win32-{branch}']
+ steps = job['steps']
+ cache_steps = [step for step in steps
+ if 'payload-signatures' in step.get('with', {}).get('path', '')]
+ assert all(not step['uses'].startswith('actions/cache@') for step in cache_steps)
+ restore = next(step for step in cache_steps if step['uses'].startswith('actions/cache/restore@'))
+ save = next(step for step in cache_steps if step['uses'].startswith('actions/cache/save@'))
+ assert save['with']['path'] == restore['with']['path']
+ assert save['with']['key'] == '${{ steps.' + restore['id'] + '.outputs.cache-primary-key }}'
+ assert gate(save['if'], {'build_commit': commit}, {}, job_if=False) is (job['cache-mode'] == 'write')
+ verify = next(step for step in steps if step.get('name') == 'Verify native signature cache contracts')
+ assert steps.index(restore) < steps.index(verify) < steps.index(save)
+ assembly = jobs['assemble-win32-bundle']
+ assert assembly['cache-mode'] == 'read'
+ setup = next(step for step in assembly['steps'] if step.get('uses') == './.github/actions/setup-pm')
+ assert setup['with']['cache-python'] is False
+ assert setup['with']['save-tools-cache'] is False and setup['with']['save-node-cache'] is False
+ action = hermes_yaml.safe_load((ROOT / '.github/actions/setup-pm/action.yml').read_text())
+ tools = next(step for step in action['runs']['steps'] if step.get('id') == 'tools-cache')
+ assert "inputs.save-tools-cache == 'true'" in tools['if']
+ assert all(not step.get('uses', '').startswith('actions/cache@') for step in assembly['steps'])
+
+
def test_smoke_matrix_native_routes_and_driver_only_dependencies():
workflow = smoke_workflow()
jobs = _workflow()['jobs']
@@ -134,9 +160,16 @@ def test_smoke_matrix_native_routes_and_driver_only_dependencies():
checkout = next(step for step in job['steps'] if 'actions/checkout@' in step.get('uses', ''))
assert checkout['with']['persist-credentials'] is False
assert checkout['with']['ref'] == '${{ inputs.sha }}'
+ recording = next(step for step in job['steps'] if step.get('id') == 'recording')
+ assert recording['with']['save-cache'] is False
upload = next(step for step in job['steps'] if 'actions/upload-artifact@' in step.get('uses', ''))
assert upload['if'] == 'always()' and upload['with']['path'].endswith('/out')
+ recorder = hermes_yaml.safe_load((ROOT / '.github/actions/e2e-screen-record/action.yml').read_text())
+ assert all(not step.get('uses', '').startswith('actions/cache@') for step in recorder['runs']['steps'])
+ save = next(step for step in recorder['runs']['steps'] if step.get('uses', '').startswith('actions/cache/save@'))
+ assert "inputs.save-cache == 'true'" in save['if']
+
workflows = [workflow] + [hermes_yaml.safe_load((ROOT / '.github/workflows' / name).read_text(encoding='utf-8-sig'))
for name in ('install-e2e-run.yml', 'install-e2e-macos-run.yml', 'install-e2e-windows-run.yml')]
for document in workflows: