Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 80 additions & 13 deletions .github/workflows/release-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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 }}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里的匹配只读当前 run_attempt。比如上一轮 core 已过、只重跑失败的 media,汇总会重跑,但 inventory.json 和 python-core.json 还在旧 attempt,最后变成「测试过了、门禁仍红」。部分重跑也要按 shard 找到本 run、同一受测 SHA 上实际成功的那次产物;如果暂不支持,请明确报错提示 Re-run all jobs。建议补一例「旧 core + 新 media」的聚合测试。GitHub 重跑行为 (Partial reruns can leave successful shard evidence in an earlier 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
106 changes: 102 additions & 4 deletions scripts/ci/check_test_layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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))
Expand Down
Loading
Loading