|
76 | 76 | exit 1 |
77 | 77 | fi |
78 | 78 | echo "All $COUNT scripts passed ShellCheck" |
| 79 | +
|
| 80 | + - name: Python lint |
| 81 | + run: | |
| 82 | + PYFILES=$(find . -path './.skill-repo-tools' -prune -o -path './.git' -prune -o \ |
| 83 | + -name '*.py' -type f -print | sort) |
| 84 | + if [[ -z "$PYFILES" ]]; then |
| 85 | + echo "No Python files found, skipping" |
| 86 | + exit 0 |
| 87 | + fi |
| 88 | + COUNT=$(echo "$PYFILES" | wc -l) |
| 89 | + echo "Found $COUNT Python file(s)" |
| 90 | + # Collect directories containing .py files |
| 91 | + DIRS=$(echo "$PYFILES" | xargs -I{} dirname {} | sort -u | tr '\n' ' ') |
| 92 | + pip install ruff -q |
| 93 | + echo "=== ruff check ===" |
| 94 | + ruff check $DIRS |
| 95 | + echo "=== ruff format ===" |
| 96 | + ruff format --check $DIRS |
| 97 | +
|
| 98 | + - name: Validate checkpoint schemas |
| 99 | + run: | |
| 100 | + CHECKPOINT_FILES=$(find . -path './.skill-repo-tools' -prune -o -path './.git' -prune -o \ |
| 101 | + -name 'checkpoints.yaml' -o -name '*-checkpoints.yaml' | grep -v '.skill-repo-tools' | sort) |
| 102 | + if [[ -z "$CHECKPOINT_FILES" ]]; then |
| 103 | + echo "No checkpoint files found, skipping" |
| 104 | + exit 0 |
| 105 | + fi |
| 106 | + COUNT=$(echo "$CHECKPOINT_FILES" | wc -l) |
| 107 | + echo "Found $COUNT checkpoint file(s)" |
| 108 | + pip install pyyaml -q |
| 109 | + FAILED=0 |
| 110 | + while IFS= read -r f; do |
| 111 | + [[ -z "$f" ]] && continue |
| 112 | + echo "=== Validating $f ===" |
| 113 | + python3 -c " |
| 114 | + import sys, yaml |
| 115 | + with open('$f') as fh: |
| 116 | + data = yaml.safe_load(fh) |
| 117 | + if not isinstance(data, dict): |
| 118 | + print('ERROR: not a YAML mapping') |
| 119 | + sys.exit(1) |
| 120 | + has_mechanical = 'mechanical' in data |
| 121 | + has_llm = 'llm_reviews' in data |
| 122 | + if not has_mechanical and not has_llm: |
| 123 | + print('ERROR: must have mechanical and/or llm_reviews section') |
| 124 | + sys.exit(1) |
| 125 | + all_ids = [] |
| 126 | + for section in ('mechanical', 'llm_reviews'): |
| 127 | + items = data.get(section, []) |
| 128 | + if items is None: |
| 129 | + continue |
| 130 | + for item in items: |
| 131 | + if 'id' not in item: |
| 132 | + print(f'ERROR: entry in {section} missing id field') |
| 133 | + sys.exit(1) |
| 134 | + all_ids.append(item['id']) |
| 135 | + dupes = [x for x in all_ids if all_ids.count(x) > 1] |
| 136 | + if dupes: |
| 137 | + print(f'ERROR: duplicate checkpoint IDs: {set(dupes)}') |
| 138 | + sys.exit(1) |
| 139 | + m = len(data.get('mechanical', []) or []) |
| 140 | + l = len(data.get('llm_reviews', []) or []) |
| 141 | + print(f'Valid: {m} mechanical + {l} LLM review checkpoints') |
| 142 | + " || FAILED=1 |
| 143 | + done <<< "$CHECKPOINT_FILES" |
| 144 | + if [[ $FAILED -eq 1 ]]; then |
| 145 | + echo "::error::Checkpoint validation failed" |
| 146 | + exit 1 |
| 147 | + fi |
| 148 | + echo "All $COUNT checkpoint file(s) valid" |
0 commit comments