From 788fe7fdb8e388492592b767c2c713a22c47af5c Mon Sep 17 00:00:00 2001 From: Weiming Liao Date: Sat, 5 Dec 2026 02:55:55 +0800 Subject: [PATCH 1/2] [test] ci: drop three redundant native runtime parameterizations --- tests/test_native_runtime.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/tests/test_native_runtime.py b/tests/test_native_runtime.py index b23ace852..f7a6af919 100644 --- a/tests/test_native_runtime.py +++ b/tests/test_native_runtime.py @@ -119,10 +119,17 @@ def respond(): assert json.loads(result.stdout) == response -@pytest.mark.parametrize('runtime', ['default', 'opencode', 'codex', 'claude']) -@pytest.mark.parametrize("missing_rollout", [False, True]) +@pytest.mark.parametrize( + ('runtime', 'missing_rollout'), + [ + pytest.param('default', False, id='False-default'), + pytest.param('opencode', False, id='False-opencode'), + pytest.param('codex', False, id='False-codex'), + pytest.param('codex', True, id='True-codex'), + pytest.param('claude', False, id='False-claude'), + ], +) def test_native_events_real_cli_and_shared_write(tmp_path, monkeypatch, runtime, missing_rollout): - missing_rollout = missing_rollout and runtime == "codex" monkeypatch.setattr(native, "codex_session_available", lambda _: not missing_rollout) monkeypatch.setenv("TEST_MISSING_ROLLOUT", "1" if missing_rollout else "0") local = LocalProjects(tmp_path) From c362df3571168c62839f203109265de01c64d8d7 Mon Sep 17 00:00:00 2001 From: Weiming Liao Date: Sat, 5 Dec 2026 02:56:37 +0800 Subject: [PATCH 2/2] [ci] python: parallelize suite across three file shards and isolate native CLI regressions --- .github/workflows/release-checks.yml | 93 ++++++++++++-- scripts/ci/check_test_layers.py | 106 +++++++++++++++- scripts/ci/python_shards.json | 177 +++++++++++++++++++++++++++ scripts/ci/summarize_checks.py | 2 +- tests/test_ci_layers.py | 80 ++++++++++++ tests/test_ci_scope.py | 9 +- tests/test_ci_summary.py | 6 +- 7 files changed, 449 insertions(+), 24 deletions(-) create mode 100644 scripts/ci/python_shards.json diff --git a/.github/workflows/release-checks.yml b/.github/workflows/release-checks.yml index 65cb8d8cb..912e1f529 100644 --- a/.github/workflows/release-checks.yml +++ b/.github/workflows/release-checks.yml @@ -73,6 +73,10 @@ jobs: if: ${{ !cancelled() && ((needs.static.result == 'success' && needs.static.outputs.run-heavy != 'false') || (!inputs.static-checks && needs.static.result == 'skipped')) }} runs-on: ubuntu-22.04 timeout-minutes: 30 + strategy: + fail-fast: false + matrix: + shard: [core, agent-cli, media] steps: - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0 - uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38 # v6.5.0 @@ -103,13 +107,70 @@ jobs: npm exec --no -- opencode --version python -m pip check - name: Check layer imports - if: always() && steps.install.outcome == 'success' + if: always() && steps.install.outcome == 'success' && matrix.shard == 'core' run: lint-imports # Runs before the Python suite: a failing or hanging test run must not hide # whether the checked-in contracts still match the models. - name: Check generated contracts - if: always() && steps.install.outcome == 'success' + if: always() && steps.install.outcome == 'success' && matrix.shard == 'core' run: python scripts/generate_contracts.py --check + - name: Collect full Python inventory / 收集完整 Python 清单 + if: always() && steps.install.outcome == 'success' && matrix.shard == 'core' && inputs.python-mark-expression == '' + run: python -m pytest tests --collect-only -q -m cpu --ci-profile=test-results/inventory.json + - name: Python tests (${{ matrix.shard }}) + if: always() && steps.install.outcome == 'success' + env: + PYTEST_MARK_EXPRESSION: ${{ inputs.python-mark-expression }} + PYTHON_SHARD: ${{ matrix.shard }} + run: | + files=() + while IFS= read -r path; do + if [ -n "$path" ]; then files+=("$path"); fi + done < <(python scripts/ci/check_test_layers.py --list-shard "$PYTHON_SHARD") + python -m pytest "${files[@]}" -q -ra -m "cpu${PYTEST_MARK_EXPRESSION:+ and ($PYTEST_MARK_EXPRESSION)}" --durations=50 --junitxml="test-results/python-${PYTHON_SHARD}.xml" --ci-profile="test-results/python-${PYTHON_SHARD}.json" + - name: Upload Python timing evidence / 上传 Python 耗时证据 + if: always() && steps.install.outcome == 'success' + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 + with: + name: python-test-evidence-${{ matrix.shard }}-${{ github.run_attempt }} + path: test-results/ + retention-days: 14 + if-no-files-found: warn + + python-native: + needs: static + if: ${{ !cancelled() && ((needs.static.result == 'success' && needs.static.outputs.run-heavy != 'false') || (!inputs.static-checks && needs.static.result == 'skipped')) }} + runs-on: ubuntu-22.04 + timeout-minutes: 30 + steps: + - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0 + - uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38 # v6.5.0 + with: + node-version-file: .nvmrc + cache: npm + - uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0 + with: + python-version: '3.12' + cache: pip + cache-dependency-path: requirements.txt + - name: Install media and runtime tools + run: | + sudo apt-get update + sudo apt-get install --yes ffmpeg bubblewrap ripgrep + rg --version + ffmpeg -version + ffprobe -version + ffmpeg -hide_banner -encoders 2>&1 | grep 'libx264 ' + - id: install + name: Install locked dependencies + run: | + git rev-parse HEAD + node --version + npm --version + python --version + python -m pip install -v -r requirements.txt + npm exec --no -- opencode --version + python -m pip check - name: Bundled OpenCode model gateway regression if: always() && steps.install.outcome == 'success' timeout-minutes: 5 @@ -137,19 +198,11 @@ jobs: python -m pytest tests/test_agent_visual_gate.py::test_harness_native_visual_input -m cpu -q -ra --basetemp "$RUNNER_TEMP/harness-visual-pytest" --junitxml=test-results/harness-visual.xml --ci-profile=test-results/harness-visual.json - - name: Python tests - if: always() && steps.install.outcome == 'success' - env: - PYTEST_MARK_EXPRESSION: ${{ inputs.python-mark-expression }} - run: python -m pytest tests -q -ra -m "cpu${PYTEST_MARK_EXPRESSION:+ and ($PYTEST_MARK_EXPRESSION)}" --durations=50 --junitxml=test-results/python.xml --ci-profile=test-results/python.json - - name: Check full layer inventory / 核对完整分层清单 - if: always() && steps.install.outcome == 'success' && inputs.python-mark-expression == '' - run: python scripts/ci/check_test_layers.py --profile test-results/python.json --require-executed - - name: Upload Python timing evidence / 上传 Python 耗时证据 + - name: Upload native CLI timing evidence / 上传原生 CLI 耗时证据 if: always() && steps.install.outcome == 'success' uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 with: - name: python-test-evidence-${{ github.run_attempt }} + name: python-native-evidence-${{ github.run_attempt }} path: test-results/ retention-days: 14 if-no-files-found: warn @@ -331,7 +384,7 @@ jobs: # cancelled or unexpectedly skipped lanes, including static-gate failures. checks: if: always() - needs: [static, python, frontend, browser, desktop] + needs: [static, python, python-native, frontend, browser, desktop] runs-on: ubuntu-22.04 timeout-minutes: 5 steps: @@ -341,3 +394,17 @@ jobs: CHECK_RESULTS: ${{ toJSON(needs) }} STATIC_ENABLED: ${{ toJSON(inputs.static-checks) }} run: python scripts/ci/summarize_checks.py + - name: Download Python shard evidence / 下载 Python 分片证据 + if: needs.python.result == 'success' && inputs.python-mark-expression == '' + uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0 + with: + pattern: python-test-evidence-*-${{ github.run_attempt }} + path: python-evidence + merge-multiple: true + - name: Check full layer inventory / 核对完整分层清单 + if: needs.python.result == 'success' && inputs.python-mark-expression == '' + run: >- + python scripts/ci/check_test_layers.py + --profile python-evidence/inventory.json + --shard-profiles python-evidence/python-core.json python-evidence/python-agent-cli.json python-evidence/python-media.json + --require-executed diff --git a/scripts/ci/check_test_layers.py b/scripts/ci/check_test_layers.py index 62b597db9..61e38b5c5 100644 --- a/scripts/ci/check_test_layers.py +++ b/scripts/ci/check_test_layers.py @@ -9,6 +9,26 @@ LAYERS = {'ready', 'merge', 'nightly'} +def load_shards_manifest(manifest): + if manifest.get('schema_version') != 1 or not isinstance(manifest.get('shards'), dict) or not manifest['shards']: + raise ValueError('Unsupported or empty Python shards manifest') + shards = {} + seen = set() + for name, files in manifest['shards'].items(): + if not isinstance(name, str) or not name or not isinstance(files, list) or not files: + raise ValueError('Invalid shard entry: ' + str(name)) + if any(not isinstance(path, str) or not path.startswith('tests/') for path in files): + raise ValueError('Invalid test path in shard: ' + name) + if len(files) != len(set(files)): + raise ValueError('Duplicate test path in shard: ' + name) + overlap = seen.intersection(files) + if overlap: + raise ValueError('Test path listed in multiple shards: ' + ', '.join(sorted(overlap))) + seen.update(files) + shards[name] = list(files) + return shards + + def audit(profile, contract, manifest, *, require_executed=False): if profile.get('schema_version') != 1 or contract.get('schema_version') != 1: raise ValueError('Unsupported evidence or contract schema') @@ -65,17 +85,95 @@ def audit(profile, contract, manifest, *, require_executed=False): } +def audit_shards(inventory, shard_profiles, shards_manifest, contract, manifest, *, require_executed=False): + audit(inventory, contract, manifest, require_executed=False) + shards = load_shards_manifest(shards_manifest) + if len(shard_profiles) != len(shards): + raise ValueError(f'Expected {len(shards)} shard profiles, got {len(shard_profiles)}') + expected_selection = inventory['metadata'].get('selection', '') + paths_to_shard = {tuple(files): name for name, files in shards.items()} + matched_shards = set() + shard_outcomes = {} + shard_counts = {} + for shard_profile in shard_profiles: + if shard_profile.get('schema_version') != 1: + raise ValueError('Unsupported shard evidence schema') + scope = shard_profile['metadata'] + shard_paths = tuple(scope.get('paths') or []) + shard_name = paths_to_shard.get(shard_paths) + if shard_name is None or shard_name in matched_shards: + raise ValueError('Unexpected or duplicate shard profile paths') + if (not shard_profile.get('collection_complete') or scope.get('selection') != expected_selection + or scope.get('keyword') or shard_profile['deselected_count'] + or scope.get('ignore') or scope.get('ignore_glob')): + raise ValueError('Incomplete or filtered shard profile: ' + shard_name) + if require_executed and (not shard_profile.get('complete') or shard_profile.get('exit_status') != 0): + raise ValueError('Shard execution did not complete cleanly: ' + shard_name) + cases = shard_profile['tests'] + if len(cases) != shard_profile['collected_count']: + raise ValueError('Missing collected test identities in shard: ' + shard_name) + for case in cases: + nodeid = case['nodeid'] + if nodeid in shard_outcomes: + raise ValueError('Duplicate test identity across shards: ' + nodeid) + shard_outcomes[nodeid] = case.get('outcome', 'not_run') + matched_shards.add(shard_name) + shard_counts[shard_name] = len(cases) + if matched_shards != set(shards): + raise ValueError('Missing shard profiles: ' + ', '.join(sorted(set(shards) - matched_shards))) + inventory_ids = {case['nodeid'] for case in inventory['tests']} + shard_ids = set(shard_outcomes) + if inventory_ids != shard_ids: + missing = sorted(inventory_ids - shard_ids) + extra = sorted(shard_ids - inventory_ids) + detail = [] + if missing: + detail.append('missing=' + ', '.join(missing[:5])) + if extra: + detail.append('extra=' + ', '.join(extra[:5])) + raise ValueError('Shard coverage does not match full inventory: ' + '; '.join(detail)) + merged = { + **inventory, + 'complete': all(bool(p.get('complete')) for p in shard_profiles), + 'exit_status': 0 if all(p.get('exit_status') == 0 for p in shard_profiles) else 1, + 'tests': [{**case, 'outcome': shard_outcomes[case['nodeid']]} for case in inventory['tests']], + } + result = audit(merged, contract, manifest, require_executed=require_executed) + result['shards'] = shard_counts + return result + + def main(): parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument('--profile', type=Path, required=True) + parser.add_argument('--profile', type=Path) + parser.add_argument('--shard-profiles', type=Path, nargs='+') + parser.add_argument('--shards-manifest', type=Path, default=ROOT / 'scripts/ci/python_shards.json') + parser.add_argument('--list-shard', type=str) parser.add_argument('--require-executed', action='store_true') parser.add_argument('--contract', type=Path, default=ROOT / 'tests/ci_ready_contract.json') parser.add_argument('--browser-manifest', type=Path, default=ROOT / 'tests/browser/manifest.json') args = parser.parse_args() try: - values = [json.loads(path.read_text(encoding='utf-8')) - for path in (args.profile, args.contract, args.browser_manifest)] - result = audit(*values, require_executed=args.require_executed) + if args.list_shard: + shards = load_shards_manifest(json.loads(args.shards_manifest.read_text(encoding='utf-8'))) + if args.list_shard not in shards: + raise ValueError('Unknown shard: ' + args.list_shard) + print('\n'.join(shards[args.list_shard])) + return + if not args.profile: + raise ValueError('--profile is required') + inventory = json.loads(args.profile.read_text(encoding='utf-8')) + contract = json.loads(args.contract.read_text(encoding='utf-8')) + browser_manifest = json.loads(args.browser_manifest.read_text(encoding='utf-8')) + if args.shard_profiles: + shard_profiles = [json.loads(path.read_text(encoding='utf-8')) for path in args.shard_profiles] + shards_manifest = json.loads(args.shards_manifest.read_text(encoding='utf-8')) + result = audit_shards( + inventory, shard_profiles, shards_manifest, contract, browser_manifest, + require_executed=args.require_executed, + ) + else: + result = audit(inventory, contract, browser_manifest, require_executed=args.require_executed) except (ValueError, KeyError, TypeError, OSError) as error: raise SystemExit('Layer audit failed / 分层核对失败: ' + str(error)) from None print(json.dumps(result, ensure_ascii=False)) diff --git a/scripts/ci/python_shards.json b/scripts/ci/python_shards.json new file mode 100644 index 000000000..c2b76342c --- /dev/null +++ b/scripts/ci/python_shards.json @@ -0,0 +1,177 @@ +{ + "schema_version": 1, + "shards": { + "core": [ + "tests/test_a2_repros.py", + "tests/test_app_settings.py", + "tests/test_ark_plan_models.py", + "tests/test_asset_names.py", + "tests/test_atlascloud.py", + "tests/test_bench_creation_projects.py", + "tests/test_bench_turn_timing.py", + "tests/test_bigmodel_image.py", + "tests/test_bigmodel_video.py", + "tests/test_blockout.py", + "tests/test_canvas_sources.py", + "tests/test_canvas_text_cli.py", + "tests/test_capability_acceptance.py", + "tests/test_capability_contract.py", + "tests/test_capability_contract_integration.py", + "tests/test_capability_freshness.py", + "tests/test_capability_identity.py", + "tests/test_capability_input_projection.py", + "tests/test_ci_hardware.py", + "tests/test_ci_layers.py", + "tests/test_ci_profile.py", + "tests/test_ci_scope.py", + "tests/test_ci_security.py", + "tests/test_ci_summary.py", + "tests/test_command_version_contract.py", + "tests/test_continuation_availability.py", + "tests/test_creation_api.py", + "tests/test_creation_artifacts.py", + "tests/test_creation_assembly.py", + "tests/test_creation_assets.py", + "tests/test_creation_canvas_service.py", + "tests/test_creation_contracts.py", + "tests/test_creation_generation_service.py", + "tests/test_creation_history_service.py", + "tests/test_creation_layers.py", + "tests/test_creation_node_versions.py", + "tests/test_creation_parameters.py", + "tests/test_creation_reference_editor.py", + "tests/test_creation_storage.py", + "tests/test_creation_tool_drafts.py", + "tests/test_creation_workflow.py", + "tests/test_cutout_capability_acceptance.py", + "tests/test_daily_benchmark.py", + "tests/test_desktop_host.py", + "tests/test_directory_links.py", + "tests/test_endpoint_closure.py", + "tests/test_execution_files.py", + "tests/test_fasth3_capability_acceptance.py", + "tests/test_fasth3_continuation.py", + "tests/test_fasth3_inputs.py", + "tests/test_fasth3_video_edit.py", + "tests/test_ffmpeg_frame_sync.py", + "tests/test_generation_errors.py", + "tests/test_generation_recovery.py", + "tests/test_h3_keyframes.py", + "tests/test_hidden_reference_roundtrip.py", + "tests/test_higgsfield_open.py", + "tests/test_image_input_policy.py", + "tests/test_image_quality_test.py", + "tests/test_installation.py", + "tests/test_kling_video.py", + "tests/test_launcher.py", + "tests/test_layer_boundary.py", + "tests/test_library.py", + "tests/test_local_json.py", + "tests/test_localization.py", + "tests/test_minimax_image.py", + "tests/test_minimax_speech.py", + "tests/test_minimax_video.py", + "tests/test_model_availability.py", + "tests/test_model_catalog.py", + "tests/test_model_configs.py", + "tests/test_model_gateway.py", + "tests/test_model_http_logging.py", + "tests/test_model_reasoning_trace.py", + "tests/test_moss.py", + "tests/test_multimodal_references.py", + "tests/test_nightly_perf_artifact.py", + "tests/test_omni_exported_video_capabilities.py", + "tests/test_openai_images.py", + "tests/test_owner_rights.py", + "tests/test_owner_rights_journal.py", + "tests/test_owner_rights_lifecycle.py", + "tests/test_owner_rights_resume.py", + "tests/test_pipeline.py", + "tests/test_posix_execution_files.py", + "tests/test_process_helpers.py", + "tests/test_prompt_optimization.py", + "tests/test_public_target.py", + "tests/test_query_guidance.py", + "tests/test_rename.py", + "tests/test_request_capability_acceptance.py", + "tests/test_result_download_security.py", + "tests/test_retired_entry.py", + "tests/test_rule_facts.py", + "tests/test_runtime_catalog.py", + "tests/test_runtime_readiness.py", + "tests/test_self_hosted.py", + "tests/test_self_hosted_proxy.py", + "tests/test_self_hosted_queue.py", + "tests/test_structure_reference.py", + "tests/test_vllm_omni_h3.py", + "tests/test_vllm_omni_image.py", + "tests/test_voice_library.py", + "tests/test_windows_git_control_pipe.py", + "tests/test_windows_powershell.py", + "tests/test_zhipu.py" + ], + "agent-cli": [ + "tests/test_agent_artifacts.py", + "tests/test_agent_citations.py", + "tests/test_agent_gateway.py", + "tests/test_agent_job_lineage.py", + "tests/test_agent_metadata.py", + "tests/test_agent_source_references.py", + "tests/test_agent_timing.py", + "tests/test_agent_tools_voices.py", + "tests/test_agent_visual_gate.py", + "tests/test_antigravity_runtime.py", + "tests/test_asset_download_cli.py", + "tests/test_assistant_capability_parameters.py", + "tests/test_assistant_conversation_trace.py", + "tests/test_assistant_conversations.py", + "tests/test_assistant_queue.py", + "tests/test_cli.py", + "tests/test_cli_discovery.py", + "tests/test_deepseek_engine.py", + "tests/test_deepseek_runtime.py", + "tests/test_jiuwenswarm_engine.py", + "tests/test_jiuwenswarm_media.py", + "tests/test_jiuwenswarm_runtime.py", + "tests/test_native_runtime.py", + "tests/test_native_sessions.py", + "tests/test_pi_runtime.py", + "tests/test_skill_snapshot.py" + ], + "media": [ + "tests/test_canvas_text_cli_http.py", + "tests/test_creation_crop.py", + "tests/test_creation_image_edits.py", + "tests/test_creation_media_publication.py", + "tests/test_creation_timeline_render.py", + "tests/test_creation_timeline_text.py", + "tests/test_heif.py", + "tests/test_motion_document.py", + "tests/test_motion_generation.py", + "tests/test_motion_inspect_v2.py", + "tests/test_motion_reference_assets.py", + "tests/test_motion_wave1.py", + "tests/test_motion_wave2_wave3.py", + "tests/test_subject_library.py", + "tests/test_timeline_fonts.py", + "tests/test_timeline_packages.py", + "tests/test_timeline_source_connections.py", + "tests/test_tool_lifecycle.py", + "tests/test_tool_model_errors.py", + "tests/test_tool_native_mask.py", + "tests/test_tool_optional_image.py", + "tests/test_tool_task_history.py", + "tests/test_tool_tasks.py", + "tests/test_video_blockout.py", + "tests/test_video_capabilities.py", + "tests/test_video_capability_acceptance.py", + "tests/test_video_compatibility.py", + "tests/test_video_compression.py", + "tests/test_video_gateway.py", + "tests/test_video_link_import.py", + "tests/test_video_request_projection.py", + "tests/test_video_resolution.py", + "tests/test_video_role_capabilities.py" + ] + } +} diff --git a/scripts/ci/summarize_checks.py b/scripts/ci/summarize_checks.py index 2daa4db0d..663ee2a14 100644 --- a/scripts/ci/summarize_checks.py +++ b/scripts/ci/summarize_checks.py @@ -9,7 +9,7 @@ def main(): static_enabled = json.loads(os.environ['STATIC_ENABLED']) if not isinstance(static_enabled, bool): raise SystemExit('STATIC_ENABLED must be a JSON boolean') - expected = {'static', 'python', 'frontend', 'browser', 'desktop'} + expected = {'static', 'python', 'python-native', 'frontend', 'browser', 'desktop'} if set(results) != expected: raise SystemExit('Missing or unexpected release-check lanes') scope = results['static'].get('outputs', {}) diff --git a/tests/test_ci_layers.py b/tests/test_ci_layers.py index ce63dd1b0..18e739d21 100644 --- a/tests/test_ci_layers.py +++ b/tests/test_ci_layers.py @@ -123,3 +123,83 @@ def test_cpu_filter_cannot_hide_accelerator_cases_from_full_audit(evidence): evidence[0]['deselected_count'] = 1 with pytest.raises(ValueError, match='unfiltered'): audit_module.audit(*evidence) + + +def _shard_fixture(evidence): + inventory, contract, manifest = copy.deepcopy(evidence) + inventory['complete'] = False + inventory['exit_status'] = 0 + for case in inventory['tests']: + case['outcome'] = 'not_run' + shards_manifest = { + 'schema_version': 1, + 'shards': { + 'core': ['tests/test_core.py'], + 'media': ['tests/test_media.py'], + }, + } + shard_core = { + 'schema_version': 1, 'collection_complete': True, 'collected_count': 1, + 'deselected_count': 0, + 'metadata': {'paths': ['tests/test_core.py'], 'selection': '', 'keyword': ''}, + 'complete': True, 'exit_status': 0, + 'tests': [{**evidence[0]['tests'][0], 'outcome': 'passed'}], + } + shard_media = { + 'schema_version': 1, 'collection_complete': True, 'collected_count': 1, + 'deselected_count': 0, + 'metadata': {'paths': ['tests/test_media.py'], 'selection': '', 'keyword': ''}, + 'complete': True, 'exit_status': 0, + 'tests': [{**evidence[0]['tests'][1], 'outcome': 'passed'}], + } + return inventory, [shard_core, shard_media], shards_manifest, contract, manifest + + +def test_audit_shards_verifies_complete_partition_and_execution(evidence): + inventory, shard_profiles, shards_manifest, contract, manifest = _shard_fixture(evidence) + result = audit_module.audit_shards( + inventory, shard_profiles, shards_manifest, contract, manifest, require_executed=True, + ) + assert result['tests'] == 2 + assert result['shards'] == {'core': 1, 'media': 1} + assert result['representative_outcomes'] == {'passed': 1} + + +def test_audit_shards_rejects_missing_or_duplicate_case_across_shards(evidence): + inventory, shard_profiles, shards_manifest, contract, manifest = _shard_fixture(evidence) + shard_profiles[1]['tests'] = [] + shard_profiles[1]['collected_count'] = 0 + with pytest.raises(ValueError, match='does not match full inventory'): + audit_module.audit_shards(inventory, shard_profiles, shards_manifest, contract, manifest) + + inventory, shard_profiles, shards_manifest, contract, manifest = _shard_fixture(evidence) + shard_profiles[1]['tests'].append(copy.deepcopy(shard_profiles[0]['tests'][0])) + shard_profiles[1]['collected_count'] = 2 + with pytest.raises(ValueError, match='Duplicate test identity across shards'): + audit_module.audit_shards(inventory, shard_profiles, shards_manifest, contract, manifest) + + +def test_audit_shards_rejects_incomplete_shard_or_skipped_representative(evidence): + inventory, shard_profiles, shards_manifest, contract, manifest = _shard_fixture(evidence) + shard_profiles[0]['complete'] = False + with pytest.raises(ValueError, match='did not complete cleanly'): + audit_module.audit_shards( + inventory, shard_profiles, shards_manifest, contract, manifest, require_executed=True, + ) + + inventory, shard_profiles, shards_manifest, contract, manifest = _shard_fixture(evidence) + shard_profiles[0]['tests'][0]['outcome'] = 'skipped' + with pytest.raises(ValueError, match='execution'): + audit_module.audit_shards( + inventory, shard_profiles, shards_manifest, contract, manifest, require_executed=True, + ) + + +def test_repo_python_shards_manifest_covers_every_test_module_once(): + import json + root = Path(__file__).resolve().parents[1] + manifest = json.loads((root / 'scripts/ci/python_shards.json').read_text(encoding='utf-8')) + shards = audit_module.load_shards_manifest(manifest) + listed = {path for files in shards.values() for path in files} + on_disk = {f'tests/{path.name}' for path in (root / 'tests').glob('test_*.py')} + assert listed == on_disk diff --git a/tests/test_ci_scope.py b/tests/test_ci_scope.py index e774db83c..f1283d489 100644 --- a/tests/test_ci_scope.py +++ b/tests/test_ci_scope.py @@ -177,7 +177,7 @@ def test_real_selector_outputs_drive_real_aggregate(repository, tmp_path, event) decision = dict(line.split('=', 1) for line in output.read_text(encoding='utf-8').splitlines()) assert decision == json.loads(selected.stdout) results = {'static': {'result': 'success', 'outputs': decision}, - **{lane: {'result': 'skipped'} for lane in ['python', 'frontend', 'browser', 'desktop']}} + **{lane: {'result': 'skipped'} for lane in ['python', 'python-native', 'frontend', 'browser', 'desktop']}} aggregated = subprocess.run([sys.executable, str(ROOT / 'scripts/ci/summarize_checks.py')], env={**env, 'CHECK_RESULTS': json.dumps(results), 'STATIC_ENABLED': 'true'}, capture_output=True, text=True, encoding='utf-8') @@ -300,12 +300,15 @@ def test_workflow_wires_every_heavy_lane_to_successful_static_scope(): assert jobs['static']['steps'][-1]['id'] == 'scope' assert jobs['static']['steps'][-1]['run'] == 'python scripts/ci/select_checks.py' assert set(jobs['static']['outputs']) == {'run-heavy', 'run-desktop', 'scope-reason', 'changed-files'} - for lane in ['python', 'frontend', 'browser']: + for lane in ['python', 'python-native', 'frontend', 'browser']: assert jobs[lane]['needs'] == 'static' assert "needs.static.result == 'success' && needs.static.outputs.run-heavy != 'false'" in jobs[lane]['if'] assert "!inputs.static-checks && needs.static.result == 'skipped'" in jobs[lane]['if'] + shards = json.loads((ROOT / 'scripts/ci/python_shards.json').read_text(encoding='utf-8'))['shards'] + assert jobs['python']['strategy']['fail-fast'] is False + assert jobs['python']['strategy']['matrix']['shard'] == list(shards) assert jobs['checks']['if'] == 'always()' - assert set(jobs['checks']['needs']) == {'static', 'python', 'frontend', 'browser', 'desktop'} + assert set(jobs['checks']['needs']) == {'static', 'python', 'python-native', 'frontend', 'browser', 'desktop'} def test_ci_and_release_share_read_only_installer_checks(): diff --git a/tests/test_ci_summary.py b/tests/test_ci_summary.py index 9f699a5e7..62dd61cb2 100644 --- a/tests/test_ci_summary.py +++ b/tests/test_ci_summary.py @@ -10,7 +10,7 @@ pytestmark = [pytest.mark.cpu, pytest.mark.ready] SCRIPT = Path(__file__).resolve().parents[1] / 'scripts/ci/summarize_checks.py' -LANES = ['static', 'python', 'frontend', 'browser', 'desktop'] +LANES = ['static', 'python', 'python-native', 'frontend', 'browser', 'desktop'] def run_summary(tmp_path, statuses, enabled=True, *, scope=None, event='pull_request'): @@ -46,7 +46,7 @@ def test_unsuccessful_required_lane_blocks_merge(tmp_path, lane, status): def test_static_failure_and_skipped_test_jobs_do_not_pass(tmp_path): result, _ = run_summary(tmp_path, { - 'static': 'failure', 'python': 'skipped', + 'static': 'failure', 'python': 'skipped', 'python-native': 'skipped', 'frontend': 'skipped', 'browser': 'skipped', 'desktop': 'skipped', }) assert result.returncode != 0 @@ -54,7 +54,7 @@ def test_static_failure_and_skipped_test_jobs_do_not_pass(tmp_path): def test_intentionally_disabled_static_lane_is_allowed(tmp_path): result, _ = run_summary(tmp_path, { - 'static': 'skipped', 'python': 'success', + 'static': 'skipped', 'python': 'success', 'python-native': 'success', 'frontend': 'success', 'browser': 'success', 'desktop': 'success', }, enabled=False) assert result.returncode == 0, result.stderr