File size: 1,614 Bytes
7ed7e97
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env python3
"""Validate the complete TestPrism verified-task release."""

from __future__ import annotations

import sys
from pathlib import Path


ROOT = Path(__file__).resolve().parent
TASKS = ROOT / "verified_tasks" / "test"
EXPECTED_TASKS = 2000
FORBIDDEN_NAMES = {".DS_Store", "attempts.jsonl", ".env", "__pycache__"}


def main() -> int:
    errors: list[str] = []
    task_files = sorted(TASKS.glob("*/*/task.yaml"))
    task_keys = [str(path.parent.relative_to(TASKS)) for path in task_files]

    if len(task_keys) != EXPECTED_TASKS:
        errors.append(
            f"expected {EXPECTED_TASKS} task.yaml files, found {len(task_keys)}"
        )
    if len(set(task_keys)) != len(task_keys):
        errors.append("duplicate task keys found")
    for task_file in task_files:
        task_dir = task_file.parent
        if not (task_dir / "solution.sh").is_file():
            errors.append(f"missing solution.sh: {task_dir.relative_to(TASKS)}")
    for path in ROOT.rglob("*"):
        if any(part in FORBIDDEN_NAMES for part in path.relative_to(ROOT).parts):
            errors.append(f"forbidden release path: {path.relative_to(ROOT)}")

    if errors:
        print(f"FAIL: {len(errors)} data validation error(s)", file=sys.stderr)
        for error in errors[:100]:
            print(f"- {error}", file=sys.stderr)
        if len(errors) > 100:
            print(f"- ... {len(errors) - 100} more", file=sys.stderr)
        return 1

    print(f"PASS: {len(task_keys)} verified tasks; release hygiene checks passed")
    return 0


if __name__ == "__main__":
    raise SystemExit(main())