|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + pull_request: |
| 7 | + branches: [main] |
| 8 | + |
| 9 | +jobs: |
| 10 | + smoke-test: |
| 11 | + name: Python ${{ matrix.python-version }} smoke test |
| 12 | + runs-on: ubuntu-latest |
| 13 | + strategy: |
| 14 | + matrix: |
| 15 | + python-version: ["3.10", "3.12"] |
| 16 | + |
| 17 | + steps: |
| 18 | + - uses: actions/checkout@v4 |
| 19 | + |
| 20 | + - name: Set up Python ${{ matrix.python-version }} |
| 21 | + uses: actions/setup-python@v5 |
| 22 | + with: |
| 23 | + python-version: ${{ matrix.python-version }} |
| 24 | + |
| 25 | + - name: Install dependencies |
| 26 | + run: pip install -r requirements.txt |
| 27 | + |
| 28 | + - name: Syntax check — all simulation modules |
| 29 | + run: | |
| 30 | + python -m py_compile simulation/su2.py |
| 31 | + python -m py_compile simulation/su3.py |
| 32 | + python -m py_compile simulation/u1.py |
| 33 | + python -m py_compile simulation/lattice.py |
| 34 | + python -m py_compile simulation/fields.py |
| 35 | + python -m py_compile simulation/action.py |
| 36 | + python -m py_compile simulation/observables.py |
| 37 | + python -m py_compile simulation/updates.py |
| 38 | + python -m py_compile simulation/simulation.py |
| 39 | + python -m py_compile simulation/su2_l10_colab.py |
| 40 | +
|
| 41 | + - name: Smoke test — su2_l10_colab.py (L=4, 2 sweeps) |
| 42 | + run: | |
| 43 | + python - << 'EOF' |
| 44 | + import ast, sys |
| 45 | + with open("simulation/su2_l10_colab.py", encoding="utf-8") as f: |
| 46 | + src = f.read() |
| 47 | + ast.parse(src) |
| 48 | +
|
| 49 | + # Patch to tiny run |
| 50 | + src = src.replace("L = 10", "L = 4") |
| 51 | + src = src.replace("N_THERM = 4000", "N_THERM = 2") |
| 52 | + src = src.replace("N_MEAS = 500", "N_MEAS = 2") |
| 53 | + src = src.replace("N_SKIP = 5", "N_SKIP = 1") |
| 54 | + exec(src, {"__name__": "__main__"}) |
| 55 | +
|
| 56 | + import json |
| 57 | + with open("su2_l10_summary.json") as f: |
| 58 | + r = json.load(f) |
| 59 | + assert r["stub_mode"] == False, "stub_mode must be False" |
| 60 | + assert 0.0 < r["R_mean"] < 1.0, f"R_mean out of range: {r['R_mean']}" |
| 61 | + print(f"PASS R_mean={r['R_mean']:.4f} tau_int={r['tau_int']}") |
| 62 | + EOF |
| 63 | +
|
| 64 | + - name: Verify data files are valid JSON |
| 65 | + run: | |
| 66 | + python -c " |
| 67 | + import json, pathlib, sys |
| 68 | + errors = [] |
| 69 | + for f in pathlib.Path('data').glob('*.json'): |
| 70 | + try: |
| 71 | + json.loads(f.read_text(encoding='utf-8')) |
| 72 | + except Exception as e: |
| 73 | + errors.append(f'{f}: {e}') |
| 74 | + if errors: |
| 75 | + print('\\n'.join(errors)); sys.exit(1) |
| 76 | + print(f'All {len(list(pathlib.Path(\"data\").glob(\"*.json\")))} JSON files valid') |
| 77 | + " |
0 commit comments