|
| 1 | +Run the same lint and test checks that GitHub Actions CI runs, but locally and only for the modules that have changed. This prevents CI failures and blocked Docker builds before they happen. |
| 2 | + |
| 3 | +## What to do |
| 4 | + |
| 5 | +**Step 1 — Detect changed modules** |
| 6 | + |
| 7 | +Run this command from the repo root and collect the output: |
| 8 | + |
| 9 | +```bash |
| 10 | +git diff --name-only HEAD |
| 11 | +git diff --name-only --cached |
| 12 | +``` |
| 13 | + |
| 14 | +From the file paths, determine which of these four modules are affected: |
| 15 | +- `knowledge-graph-api` — any path starting with `knowledge-graph-api/` |
| 16 | +- `knowledge-graph-mcp` — any path starting with `knowledge-graph-mcp/` |
| 17 | +- `knowledge-graph-agents` — any path starting with `knowledge-graph-agents/` |
| 18 | +- `knowledge-graph-ui` — any path starting with `knowledge-graph-ui/` |
| 19 | + |
| 20 | +If `$ARGUMENTS` names a specific module (e.g. `api`, `mcp`, `agents`, `ui`), check only that one instead. |
| 21 | + |
| 22 | +If no files are changed and no argument is given, check all four modules. |
| 23 | + |
| 24 | +**Step 2 — Run checks for each affected module** |
| 25 | + |
| 26 | +Run each check in sequence. Stop immediately if any command exits non-zero and report the failure clearly. Do not skip to the next module after a failure — fix first. |
| 27 | + |
| 28 | +### knowledge-graph-api |
| 29 | + |
| 30 | +```bash |
| 31 | +cd knowledge-graph-api |
| 32 | +pip install -r requirements.txt -q |
| 33 | +ruff check . |
| 34 | +pytest tests/ -v --tb=short |
| 35 | +cd .. |
| 36 | +``` |
| 37 | + |
| 38 | +### knowledge-graph-mcp |
| 39 | + |
| 40 | +```bash |
| 41 | +cd knowledge-graph-mcp |
| 42 | +pip install -e . -q |
| 43 | +pip install ruff pytest pytest-asyncio -q |
| 44 | +ruff check . |
| 45 | +pytest tests/ -v --tb=short |
| 46 | +cd .. |
| 47 | +``` |
| 48 | + |
| 49 | +### knowledge-graph-agents |
| 50 | + |
| 51 | +```bash |
| 52 | +cd knowledge-graph-agents |
| 53 | +pip install --pre -r requirements.txt -q |
| 54 | +pip install ruff -q |
| 55 | +ruff check . |
| 56 | +pytest tests/ -v --tb=short |
| 57 | +cd .. |
| 58 | +``` |
| 59 | + |
| 60 | +### knowledge-graph-ui |
| 61 | + |
| 62 | +```bash |
| 63 | +cd knowledge-graph-ui |
| 64 | +npm ci --silent |
| 65 | +npm run lint |
| 66 | +npx tsc --noEmit |
| 67 | +cd .. |
| 68 | +``` |
| 69 | + |
| 70 | +**Step 3 — Report** |
| 71 | + |
| 72 | +After all checks finish, print a summary table: |
| 73 | + |
| 74 | +| Module | Lint | Tests | Result | |
| 75 | +|--------|------|-------|--------| |
| 76 | +| api | ✓/✗ | ✓/✗ | PASS/FAIL | |
| 77 | +| ... | | | | |
| 78 | + |
| 79 | +If everything passed: confirm it is safe to commit and push. |
| 80 | + |
| 81 | +If anything failed: show the exact error output and tell the user which file and line to fix before committing. |
| 82 | + |
| 83 | +## Key rules |
| 84 | + |
| 85 | +- Always run from the repo root (`knowledge-graph/`), not from inside a module directory. |
| 86 | +- Use `--tb=short` for pytest so failures are readable without being overwhelming. |
| 87 | +- `ruff check` errors that end with `[*]` are auto-fixable — offer to run `ruff check --fix .` in that module if any are found. |
| 88 | +- Never commit or push as part of this check — this command only validates, it does not modify git state. |
0 commit comments