The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
test(ci): drop desktop bundle smoke tests that only read the workflow
ethernet9a746d407b1e
diff --git a/tests/ci/test_desktop_bundle_smoke.py b/tests/ci/test_desktop_bundle_smoke.pyindex 84a798e89c8..3482e7b0311 100644--- a/tests/ci/test_desktop_bundle_smoke.py+++ b/tests/ci/test_desktop_bundle_smoke.py@@ -1,7 +1,5 @@-"""Replay artifact handoffs and publication; evaluate the actual workflow gates."""-import copy+"""Replay artifact handoffs and publication against a fake R2."""import hashlib-import itertoolsimport jsonimport shutilimport subprocess@@ -13,16 +11,12 @@ import hermes_yamlimport pytestfrom tests.ci.desktop_release_roles import (- CANARY_TAG as TAG, DOWNLOADABLE_DISPATCHES, NATIVE_TARGETS, SHA, admitted, canary_publisher,- gate, native_builds, needs_of, phase_result, selection_gates, smoke_callers, stage_step,- termux_builder, universal_assembler, updater_publishers,+ CANARY_TAG as TAG, NATIVE_TARGETS, SHA, native_builds, needs_of, phase_result, selection_gates,+ smoke_callers, stage_step, termux_builder, universal_assembler, updater_publishers,)from tests.ci.test_commit_build_staging import ROOT, shell_step-from tests.ci.test_desktop_release_tag_admission import _BASH, _child_env, _workflow+from tests.ci.test_desktop_release_tag_admission import _child_env, _workflowfrom tests.scripts.test_release_r2 import r2_server # noqa: F401-from scripts.releases.job_groups import JOB_GROUPS--ALL_JOBS = ','.join(JOB_GROUPS)def smoke_workflow():@@ -37,215 +31,18 @@ def smoke_fetch_script():return script-def selected_needs(jobs, name, selected):- """Admitted needs whose validate outputs select only `selected` groups."""- needs = admitted(needs_of(jobs[name]))- needs['validate']['outputs'] = {group: ('true' if group in selected else 'false')- for group in JOB_GROUPS}- return needs-def native_consumers(jobs):- """Jobs that act on a native build's result rather than observe it.- Every job that directly needs a selection gate or a smoke and does not- opt into always() (observers such as summaries must survive failures).- """- producers = set(selection_gates(jobs).values()) | set(smoke_callers(jobs).values())- return [name for name, job in jobs.items()- if producers & set(needs_of(job)) and 'always()' not in str(job.get('if', ''))]-def test_native_consumers_and_publication_fail_closed_across_trust_skips(tmp_path):- jobs = _workflow()['jobs']- legs = native_builds(jobs)- base_inputs = DOWNLOADABLE_DISPATCHES['tag']- consumers = native_consumers(jobs)- assert set(smoke_callers(jobs).values()) | {universal_assembler(jobs)} \- | set(updater_publishers(jobs).values()) <= set(consumers), consumers- for name in consumers:- job = jobs[name]- admitting = []- for dispatch, inputs in DOWNLOADABLE_DISPATCHES.items():- needs = admitted(needs_of(job), channel=dispatch == 'channel')- # A skipped trust branch exists in the ancestry of every native result.- needs.update({leg: {'result': 'skipped'} for leg in legs.values() if leg not in needs})- if gate(job['if'], inputs, needs):- admitting.append((dispatch, inputs, needs))- assert admitting, f'{name} never runs for a downloadable build'- for dispatch, inputs, needs in admitting:- assert not gate(job['if'], inputs, needs, cancelled=True), (name, dispatch)- for dependency in needs_of(job):- for result in ('failure', 'skipped', 'cancelled'):- faulty = copy.deepcopy(needs)- faulty[dependency]['result'] = result- assert not gate(job['if'], inputs, faulty), (name, dispatch, dependency, result)- emptied = copy.deepcopy(needs)- emptied['validate']['outputs'] = {}- assert not gate(job['if'], inputs, emptied), (name, dispatch)-- # Smokes and the universal assembly run for every downloadable build of- # the build phase, and never for dry runs or later stable phases.- scope_jobs = list(smoke_callers(jobs).values()) + [universal_assembler(jobs)]- for name in scope_jobs:- needs = admitted(needs_of(jobs[name]))- for phase, commit, upload, allowed in [- ('', SHA, False, True), ('candidate', '', False, True),- ('', '', True, True), ('', '', False, False),- ('publish', '', False, False), ('promote', '', False, False),- ]:- inputs = {**base_inputs, 'release-phase': phase, 'build_commit': commit,- 'upload_release': upload}- assert gate(jobs[name]['if'], inputs, needs) is allowed, (name, inputs)- # A group the caller did not select stays skipped; its consumers refuse.- for name in scope_jobs:- assert not gate(jobs[name]['if'], base_inputs,- selected_needs(jobs, name, {'termux'})), name- for platform, name in updater_publishers(jobs).items():- for key, value in [('build_commit', SHA), ('upload_release', False),- ('release-phase', 'candidate'), ('release-phase', 'promote')]:- assert not gate(jobs[name]['if'], {**base_inputs, key: value}, admitted(needs_of(jobs[name])))- groups = [target for target in NATIVE_TARGETS if target.startswith(f'{platform}-')]- if platform == 'win32':- groups.append('win32-bundle')- for group in groups:- assert not gate(jobs[name]['if'], base_inputs,- selected_needs(jobs, name, {group})), (name, group)-- for target, name in selection_gates(jobs).items():- job = jobs[name]- release, commit_leg = legs[(target, 'release')], legs[(target, 'commit')]- outcomes = ('success', 'failure', 'skipped', 'cancelled')- for commit, release_result, commit_result in itertools.product(('', SHA), outcomes, outcomes):- needs = admitted(needs_of(job))- needs[release] = {'result': release_result}- needs[commit_leg] = {'result': commit_result}- selected = gate(job['env']['SELECTED_BUILD_SUCCEEDED'], {'build_commit': commit}, needs, job_if=False)- expected = (commit == '' and release_result == 'success' and commit_result == 'skipped') or (- commit != '' and commit_result == 'success' and release_result == 'skipped')- assert selected is expected- (check,) = [step for step in job['steps'] if 'run' in step]- result = subprocess.run([_BASH, '-e', '-c', check['run']], cwd=tmp_path,- env=_child_env(SELECTED_BUILD_SUCCEEDED=str(selected).lower()),- capture_output=True, text=True, timeout=5)- assert (result.returncode == 0) is expected---def test_only_selection_gates_consume_native_build_legs():- """Every consumer sees a build through its selection gate, which requires- the chosen trust branch to succeed; a direct need would accept a skip."""- jobs = _workflow()['jobs']- legs = set(native_builds(jobs).values())- gates = set(selection_gates(jobs).values())- for name, job in jobs.items():- assert not (legs & set(needs_of(job))) or name in gates, f'{name} needs a native build leg directly'-def test_signature_cache_saves_only_in_the_writable_build():- jobs = _workflow()['jobs']- windows = [(name, mode) for (target, mode), name in native_builds(jobs).items() if target.startswith('win32-')]- assert {mode for _, mode in windows} == {'release', 'commit'}- for name, mode in windows:- commit = SHA if mode == 'commit' else ''- job = jobs[name]- 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[universal_assembler(jobs)]- 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')- # The assembly's save-tools-cache: false must turn the tool cache save off.- enabled = {'cache': 'true', 'save-tools-cache': 'true'}- assert gate(tools['if'], enabled, {}, job_if=False)- assert not gate(tools['if'], {**enabled, 'save-tools-cache': 'false'}, {}, job_if=False)- 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']- executions = []- for name in smoke_callers(jobs).values():- caller = jobs[name]- assert caller['permissions'] == {'contents': 'read'} and 'secrets' not in caller- formats = caller.get('strategy', {}).get('matrix', {}).get('format', [caller['with']['format']])- for fmt in formats:- executions.append((caller['with']['platform'], caller['with']['arch'], fmt))- assert set(executions) == {(platform, arch, fmt) for arch in ('arm64', 'x64')- for platform, formats in [('darwin', ('dmg', 'zip')), ('win32', ('msix',))]- for fmt in formats}- runners = {name: job for name, job in workflow['jobs'].items()- if any('actions/checkout@' in step.get('uses', '') for step in job.get('steps', []))}- # The admission job rejects unsupported targets before any runner spawns- # and needs no source; every job that checks out is a read-only smoke runner.- assert runners and len(runners) < len(workflow['jobs'])- for name, job in runners.items():- assert job['cache-mode'] == 'read' and 'environment' not in job- checkout = next(step for step in job['steps'] if 'actions/checkout@' in step.get('uses', ''))- assert checkout['with']['persist-credentials'] is False- # A channel build smokes the trusted controller's checkout, not the- # admitted source — the runner fetches the pinned channel request itself.- assert checkout['with']['ref'] in (- '${{ inputs.sha }}',- "${{ inputs.channel-build != '' && inputs.controller-sha || inputs.sha }}")- recording = next(step for step in job['steps'] if step.get('id') == 'recording')- assert 'save-cache' not in recording['with']- upload = next(step for step in job['steps'] if 'actions/upload-artifact@' in step.get('uses', ''))- # Evidence of a failed verdict is the evidence that matters.- assert gate(upload['if'], {}, {}, job_if=False, failed=True)- assert upload['with']['path'].endswith('/out')- # The chat steps are the smoke verdict. Recording stop and artifact- # upload run after that and are evidence; a 403 there must not fail- # the job or skip channel publication.- stop = next(step for step in job['steps'] if step.get('name') == 'Stop screen recording')- assert stop['continue-on-error'] is True and upload['continue-on-error'] is True- for verdict in ('macos-chat', 'windows-chat'):- chat = next(step for step in job['steps'] if step.get('id') == verdict)- assert 'continue-on-error' not in chat-- 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'])- assert 'save-cache' not in recorder['inputs']- # ffmpeg comes from the PM toolchain: the action must verify, not install.- verify = next(step for step in recorder['runs']['steps'] if step.get('name') == 'Verify ffmpeg from the PM toolchain')- assert gate(verify['if'], {'mode': 'start'}, {}, job_if=False)- assert not gate(verify['if'], {'mode': 'stop'}, {}, job_if=False)- for step in recorder['runs']['steps']:- run = step.get('run', '')- assert 'ffmpeg' not in run or 'winget' not in run and 'brew install' not in run and 'apt-get' not in run, \- f"step {step.get('name')} installs ffmpeg through an OS package manager"-- 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:- # A job that never checks out (the smoke admission job's bare case- # statement) needs no toolchain.- drivers = [job for job in document['jobs'].values()- if any('actions/checkout@' in step.get('uses', '') for step in job.get('steps', []))]- assert drivers- for job in drivers:- steps = job['steps']- setup = next(step for step in steps if step.get('uses') == './.github/actions/setup-pm')- assert setup['with']['toolchain'] == 'all' and not setup['with'].get('extras')- assert 'ffmpeg' in setup['with']['packages'].split(',')- assert all(setup['with'][key] is False for key in ('cache', 'cache-node', 'cache-python'))- install = next(step for step in steps if step.get('name') == 'Install locked chat driver dependencies')- assert steps.index(setup) < steps.index(install)- args = install['run'].split()- assert args[:2] == ['npm', 'ci'] and args[args.index('--workspace') + 1] == 'tests-js'- assert {'--include-workspace-root', '--omit=dev', '--ignore-scripts', '--no-audit', '--no-fund'} <= set(args)+++++def transport_env(tmp_path, server, *, commit=False):@@ -321,7 +118,7 @@ def test_download_faults_never_export_an_accepted_artifact(tmp_path, r2_server,assert not (tmp_path / 'smoke/out/download.json').exists()-def test_stable_phase_and_canary_gates_require_smoke_but_preserve_other_phases(tmp_path, r2_server):+def test_stable_phase_result_requires_smoke_but_preserves_other_phases(tmp_path, r2_server):jobs = _workflow()['jobs']gates, smokes = selection_gates(jobs), smoke_callers(jobs)group_jobs = {target: [gates[target], smokes[target]] for target in NATIVE_TARGETS}@@ -371,23 +168,6 @@ def test_stable_phase_and_canary_gates_require_smoke_but_preserve_other_phases(tassert run_phase('candidate', {'darwin-arm64'}, failed=smokes['darwin-arm64']).returncode != 0assert run_phase('publish', set(), failed=store).returncode != 0- canary = jobs[canary_publisher(jobs)]- inputs = {'build_commit': '', 'upload_release': True, 'tag': TAG}- needs = admitted(needs_of(canary))- assert gate(canary['if'], inputs, needs)- # The publisher runs always() to report, so it must itself refuse any- # prerequisite that did not succeed: builds, smokes, updaters, the table.- for name in needs_of(canary):- if name == 'validate':- continue- for state in ('failure', 'skipped', 'cancelled'):- faulty = copy.deepcopy(needs)- faulty[name]['result'] = state- assert not gate(canary['if'], inputs, faulty), (name, state)- emptied = copy.deepcopy(needs)- emptied['validate']['outputs'] = {}- assert not gate(canary['if'], inputs, emptied)- assert not gate(canary['if'], {**inputs, 'tag': 'v0.28.0'}, needs), 'a stable tag is not a canary'def test_canary_publisher_consumes_staged_bytes_and_writes_pointer_last(tmp_path, r2_server):