|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + pull_request: |
| 7 | + branches: [main] |
| 8 | + |
| 9 | +concurrency: |
| 10 | + group: ci-${{ github.ref }} |
| 11 | + cancel-in-progress: true |
| 12 | + |
| 13 | +jobs: |
| 14 | + backend: |
| 15 | + name: Backend tests (pytest) |
| 16 | + runs-on: ubuntu-latest |
| 17 | + strategy: |
| 18 | + fail-fast: false |
| 19 | + matrix: |
| 20 | + python-version: ["3.10", "3.11", "3.12"] |
| 21 | + steps: |
| 22 | + - uses: actions/checkout@v4 |
| 23 | + |
| 24 | + - name: Set up Python ${{ matrix.python-version }} |
| 25 | + uses: actions/setup-python@v5 |
| 26 | + with: |
| 27 | + python-version: ${{ matrix.python-version }} |
| 28 | + cache: pip |
| 29 | + cache-dependency-path: | |
| 30 | + backend/requirements.txt |
| 31 | + backend/requirements-dev.txt |
| 32 | +
|
| 33 | + - name: Install backend dependencies |
| 34 | + working-directory: backend |
| 35 | + run: | |
| 36 | + python -m pip install --upgrade pip |
| 37 | + pip install -r requirements-dev.txt |
| 38 | +
|
| 39 | + - name: Run pytest |
| 40 | + working-directory: backend |
| 41 | + run: pytest -q |
| 42 | + |
| 43 | + frontend: |
| 44 | + name: Frontend JS syntax check |
| 45 | + runs-on: ubuntu-latest |
| 46 | + steps: |
| 47 | + - uses: actions/checkout@v4 |
| 48 | + |
| 49 | + - name: Set up Node |
| 50 | + uses: actions/setup-node@v4 |
| 51 | + with: |
| 52 | + node-version: "20" |
| 53 | + |
| 54 | + - name: Syntax-check frontend JS |
| 55 | + run: | |
| 56 | + set -e |
| 57 | + for f in frontend/*.js; do |
| 58 | + echo "node --check $f" |
| 59 | + node --check "$f" |
| 60 | + done |
| 61 | +
|
| 62 | + - name: Validate JSON content |
| 63 | + run: | |
| 64 | + set -e |
| 65 | + python3 -c " |
| 66 | + import json, pathlib, sys |
| 67 | + errors = 0 |
| 68 | + for p in list(pathlib.Path('frontend').rglob('*.json')) + list(pathlib.Path('curriculum').rglob('*.json')): |
| 69 | + try: |
| 70 | + json.loads(p.read_text()) |
| 71 | + print(f'ok {p}') |
| 72 | + except Exception as e: |
| 73 | + print(f'ERR {p}: {e}', file=sys.stderr) |
| 74 | + errors += 1 |
| 75 | + sys.exit(1 if errors else 0) |
| 76 | + " |
| 77 | +
|
| 78 | + scripts: |
| 79 | + name: Shell script lint + smoke |
| 80 | + runs-on: ubuntu-latest |
| 81 | + steps: |
| 82 | + - uses: actions/checkout@v4 |
| 83 | + |
| 84 | + - name: shellcheck install/run scripts |
| 85 | + run: | |
| 86 | + if [ -f install.sh ] || [ -f run.sh ]; then |
| 87 | + sudo apt-get update -y |
| 88 | + sudo apt-get install -y shellcheck |
| 89 | + for f in install.sh run.sh; do |
| 90 | + [ -f "$f" ] && shellcheck -x "$f" |
| 91 | + done |
| 92 | + else |
| 93 | + echo "no install.sh / run.sh yet; skipping" |
| 94 | + fi |
| 95 | +
|
| 96 | + - name: Set up Python |
| 97 | + uses: actions/setup-python@v5 |
| 98 | + with: |
| 99 | + python-version: "3.12" |
| 100 | + |
| 101 | + - name: Smoke-test install.sh (skip model pull, skip Ollama) |
| 102 | + env: |
| 103 | + TUTOR_SKIP_OLLAMA: "1" |
| 104 | + TUTOR_SKIP_MODEL_PULL: "1" |
| 105 | + TUTOR_NONINTERACTIVE: "1" |
| 106 | + run: | |
| 107 | + if [ -f install.sh ]; then |
| 108 | + chmod +x install.sh run.sh scripts/smoke_run.sh |
| 109 | + ./install.sh |
| 110 | + test -d backend/.venv |
| 111 | + backend/.venv/bin/python -c "import fastapi, uvicorn, httpx, pydantic" |
| 112 | + else |
| 113 | + echo "install.sh missing; skipping smoke test" |
| 114 | + fi |
| 115 | +
|
| 116 | + - name: Smoke-test run.sh (no Ollama; check /api/health and /) |
| 117 | + env: |
| 118 | + TUTOR_SKIP_OLLAMA: "1" |
| 119 | + TUTOR_PORT: "8801" |
| 120 | + run: | |
| 121 | + if [ -f scripts/smoke_run.sh ]; then |
| 122 | + chmod +x scripts/smoke_run.sh |
| 123 | + ./scripts/smoke_run.sh |
| 124 | + else |
| 125 | + echo "scripts/smoke_run.sh missing; skipping run.sh smoke" |
| 126 | + fi |
0 commit comments