ci: make parser smoke test resilient (warn if ESC07.sop missing) #6
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI: Python workflow (imports + parser smoke test) | ||
| on: | ||
| push: | ||
| branches: [ "main" ] | ||
| pull_request: | ||
| branches: [ "main" ] | ||
| jobs: | ||
| ci: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout repo | ||
| uses: actions/checkout@v4 | ||
| - name: Set up Python | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: "3.12" | ||
| - name: Install dependencies | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| if [ -f requirements.txt ]; then pip install -r requirements.txt; fi | ||
| - name: Import smoke test | ||
| run: | | ||
| python - <<'PY' | ||
| import sys | ||
| import matplotlib | ||
| try: | ||
| import networkx | ||
| print("OK networkx", networkx.__version__) | ||
| except Exception as e: | ||
| print("networkx not installed:", e) | ||
| print("OK matplotlib", matplotlib.__version__) | ||
| PY | ||
| - name: Parser smoke test (ESC07.sop) | ||
| run: | | ||
| python - <<'PY' | ||
| import os, sys | ||
| from instance_parser import parse_sop_file | ||
| p = os.path.join("sop_instances", "ESC07.sop") | ||
| if not os.path.exists(p): | ||
| print("::warning :: Missing sop_instances/ESC07.sop — skipping parser test (will not fail CI).") | ||
| sys.exit(0) | ||
| try: | ||
| nodes, matrix, precedence = parse_sop_file(p) | ||
| assert len(nodes) == len(matrix), "nodes and matrix size mismatch" | ||
| except Exception as e: | ||
| print(f"::error :: Parser failed: {e}") | ||
| sys.exit(1) | ||
| print(f"OK parser: {len(nodes)} nodes, {len(precedence)} precedence rules") | ||
| PY | ||