|
| 1 | +// Zed debugger configurations for Baserow — shared/public baseline. |
| 2 | +// |
| 3 | +// ─── How to install ─────────────────────────────────────────────────────────── |
| 4 | +// Run the following from the repository root: |
| 5 | +// config/zed/apply_standard_baserow_zed_config.sh |
| 6 | +// This copies config/zed/.zed/ → .zed/ (overwriting any existing file). |
| 7 | +// |
| 8 | +// ─── Personal customisations ────────────────────────────────────────────────── |
| 9 | +// After running the script, open .zed/debug.json and add: |
| 10 | +// • Extra env vars specific to your environment (BASEROW_PUBLIC_URL, etc.) |
| 11 | +// • Additional launch configs for your own workflows (frontend, gunicorn, …) |
| 12 | +// .zed/ at the worktree root is git-ignored, so your edits are private. |
| 13 | +// |
| 14 | +// NO SECRETS are stored in this file — it is tracked in git and shared with |
| 15 | +// all Baserow contributors. Add any personal or sensitive env vars only to |
| 16 | +// .zed/debug.json after the script has copied it. |
| 17 | +// |
| 18 | +// ─── Adapter ────────────────────────────────────────────────────────────────── |
| 19 | +// All configs below use the Debugpy adapter. Zed will auto-install it on |
| 20 | +// first use. Open the Debug panel (Cmd-Shift-D / Ctrl-Shift-D) or run |
| 21 | +// `debugger: start` from the command palette to pick a configuration. |
| 22 | +[ |
| 23 | + { |
| 24 | + // ── backend: django runserver (launch) ───────────────────────────────── |
| 25 | + // |
| 26 | + // Starts the Django dev server under Debugpy so you can set breakpoints |
| 27 | + // directly in the editor and have them hit on incoming requests. |
| 28 | + // |
| 29 | + // WHY --noreload IS REQUIRED FOR BREAKPOINTS |
| 30 | + // Django's autoreloader works by forking a child process (identified by |
| 31 | + // the RUN_MAIN env var) that actually handles HTTP requests, while the |
| 32 | + // parent process monitors source files for changes. Debugpy is attached |
| 33 | + // to the *parent* at launch time, so any breakpoints you set in view or |
| 34 | + // model code are in the wrong process — they are never reached. |
| 35 | + // |
| 36 | + // --noreload disables the fork entirely: Django runs single-process, and |
| 37 | + // Debugpy (plus your breakpoints) lives in the same process that handles |
| 38 | + // every request. The trade-off is that you must restart this config |
| 39 | + // manually after editing Python source files. |
| 40 | + // |
| 41 | + // WHY `program` AND NOT `module` |
| 42 | + // Using `module: "baserow"` tells Debugpy to run `python -m baserow`. |
| 43 | + // The baserow __main__.py hands control to Django's execute_from_command_ |
| 44 | + // line(), which then re-invokes the autoreloader machinery *before* |
| 45 | + // Debugpy can intercept the fork. Pointing `program` at the entry-point |
| 46 | + // script bypasses that re-invocation path. |
| 47 | + // |
| 48 | + // ALTERNATIVE — if you need hot-reloading or are using Docker: |
| 49 | + // Use the "backend: django (attach to :5678)" config below instead. |
| 50 | + // It attaches *inside* the RUN_MAIN child where requests are handled, |
| 51 | + // so breakpoints work even with the autoreloader enabled. |
| 52 | + "label": "backend: django runserver (launch)", |
| 53 | + "adapter": "Debugpy", |
| 54 | + "request": "launch", |
| 55 | + "program": "$ZED_WORKTREE_ROOT/backend/baserow", |
| 56 | + "args": ["runserver", "--noreload", "0.0.0.0:8000"], |
| 57 | + "cwd": "$ZED_WORKTREE_ROOT", |
| 58 | + "python": "$ZED_WORKTREE_ROOT/.venv/bin/python", |
| 59 | + "django": true, |
| 60 | + "justMyCode": false, |
| 61 | + "console": "integratedTerminal", |
| 62 | + "env": { |
| 63 | + // Relative paths work because cwd is the worktree root. |
| 64 | + "PYTHONPATH": "backend/src:premium/backend/src:enterprise/backend/src", |
| 65 | + "DJANGO_SETTINGS_MODULE": "baserow.config.settings.dev", |
| 66 | + // Point at your local Postgres. Override in .zed/debug.json if needed. |
| 67 | + "DATABASE_HOST": "localhost", |
| 68 | + }, |
| 69 | + }, |
| 70 | + { |
| 71 | + // ── backend: django (attach to :5678) ────────────────────────────────── |
| 72 | + // |
| 73 | + // Attaches Zed's debugger to a Django dev-server that is already listening |
| 74 | + // for a Debugpy client on port 5678. This is the recommended approach |
| 75 | + // when you want breakpoints *and* hot-reloading at the same time. |
| 76 | + // |
| 77 | + // HOW TO USE (local venv) |
| 78 | + // 1. Start the backend with the debugger enabled: |
| 79 | + // BASEROW_BACKEND_DEBUGGER_ENABLED=1 just b run-dev-server |
| 80 | + // With that env var set, manage.py calls `debugpy.listen(5678)` and |
| 81 | + // then `debugpy.wait_for_client()` inside the RUN_MAIN child process |
| 82 | + // — the process that actually handles HTTP requests. |
| 83 | + // 2. Wait until you see "Debugpy waiting for client…" in the terminal. |
| 84 | + // 3. Launch this config from the Debug panel. Debugpy will resume the |
| 85 | + // server and breakpoints will be hit on the next request. |
| 86 | + // |
| 87 | + // HOW TO USE (Docker dev env) |
| 88 | + // Works identically with `just dc-dev up` once you set |
| 89 | + // BASEROW_BACKEND_DEBUGGER_ENABLED=1 in your docker-compose override. |
| 90 | + // The backend container already maps container port 5678 → host 5678. |
| 91 | + // The pathMappings below translate container paths to your local |
| 92 | + // worktree so that editor breakpoints resolve correctly. |
| 93 | + "label": "backend: django (attach to :5678)", |
| 94 | + "adapter": "Debugpy", |
| 95 | + "request": "attach", |
| 96 | + "tcp_connection": { "host": "127.0.0.1", "port": 5678 }, |
| 97 | + "cwd": "$ZED_WORKTREE_ROOT", |
| 98 | + "django": true, |
| 99 | + "justMyCode": false, |
| 100 | + "pathMappings": [ |
| 101 | + { |
| 102 | + "localRoot": "$ZED_WORKTREE_ROOT", |
| 103 | + "remoteRoot": "/baserow", |
| 104 | + }, |
| 105 | + ], |
| 106 | + }, |
| 107 | + { |
| 108 | + // ── backend: celery worker (launch) ──────────────────────────────────── |
| 109 | + // |
| 110 | + // Starts a Celery worker under Debugpy. Set breakpoints inside task |
| 111 | + // functions and they will be hit when a task is dispatched. |
| 112 | + // |
| 113 | + // --pool=solo runs Celery in single-threaded mode (no subprocess pool), |
| 114 | + // which is required for Debugpy breakpoints to work reliably — the pool |
| 115 | + // strategies that use forked sub-processes suffer the same issue as the |
| 116 | + // Django autoreloader. |
| 117 | + // |
| 118 | + // Queues consumed by this worker: |
| 119 | + // celery — default / general task queue |
| 120 | + // export — file-export tasks (spreadsheet, PDF, …) |
| 121 | + // automation_workflow — automation trigger / action tasks |
| 122 | + "label": "backend: celery worker (launch)", |
| 123 | + "adapter": "Debugpy", |
| 124 | + "request": "launch", |
| 125 | + "module": "celery", |
| 126 | + "args": [ |
| 127 | + "-A", |
| 128 | + "baserow", |
| 129 | + "worker", |
| 130 | + "-Q", |
| 131 | + "celery,export,automation_workflow", |
| 132 | + "-l", |
| 133 | + "INFO", |
| 134 | + "--pool=solo", |
| 135 | + ], |
| 136 | + "cwd": "$ZED_WORKTREE_ROOT", |
| 137 | + "python": "$ZED_WORKTREE_ROOT/.venv/bin/python", |
| 138 | + "justMyCode": false, |
| 139 | + "console": "integratedTerminal", |
| 140 | + "env": { |
| 141 | + "PYTHONPATH": "backend/src:premium/backend/src:enterprise/backend/src", |
| 142 | + "DJANGO_SETTINGS_MODULE": "baserow.config.settings.dev", |
| 143 | + "DATABASE_HOST": "localhost", |
| 144 | + }, |
| 145 | + }, |
| 146 | + { |
| 147 | + // ── backend: pytest current file ─────────────────────────────────────── |
| 148 | + // |
| 149 | + // Runs pytest against whichever test file is currently open/focused in Zed. |
| 150 | + // Make sure the test file is the active editor tab before launching. |
| 151 | + // |
| 152 | + // -v one line per test with pass/fail status |
| 153 | + // -s disable output capture so print() calls and logging appear inline |
| 154 | + // (useful when debugging a single failing test) |
| 155 | + "label": "backend: pytest current file", |
| 156 | + "adapter": "Debugpy", |
| 157 | + "request": "launch", |
| 158 | + "module": "pytest", |
| 159 | + "args": ["$ZED_FILE", "-v", "-s"], |
| 160 | + "cwd": "$ZED_WORKTREE_ROOT/backend", |
| 161 | + "python": "$ZED_WORKTREE_ROOT/.venv/bin/python", |
| 162 | + "justMyCode": false, |
| 163 | + "console": "integratedTerminal", |
| 164 | + "env": { |
| 165 | + // Absolute paths are required here because cwd is the backend sub-directory, |
| 166 | + // not the worktree root, so relative paths would not resolve correctly. |
| 167 | + "PYTHONPATH": "$ZED_WORKTREE_ROOT/backend/src:$ZED_WORKTREE_ROOT/premium/backend/src:$ZED_WORKTREE_ROOT/enterprise/backend/src:$ZED_WORKTREE_ROOT/backend/flake8_plugins", |
| 168 | + "DJANGO_SETTINGS_MODULE": "baserow.config.settings.test", |
| 169 | + "DATABASE_HOST": "localhost", |
| 170 | + }, |
| 171 | + }, |
| 172 | + { |
| 173 | + // ── backend: pytest all (with coverage) ──────────────────────────────── |
| 174 | + // |
| 175 | + // Runs the complete backend test suite across core, premium, and enterprise |
| 176 | + // packages and produces an XML coverage report. |
| 177 | + // |
| 178 | + // This can take several minutes on a full run. The report is written to: |
| 179 | + // <worktree-root>/html_coverage/cov.xml |
| 180 | + // |
| 181 | + // -n=auto parallelises test collection and execution across all available |
| 182 | + // CPU cores via pytest-xdist, significantly reducing wall-clock |
| 183 | + // time. Note: parallel runs disable Debugpy breakpoints — remove |
| 184 | + // this flag if you need to step through code during a full run. |
| 185 | + "label": "backend: pytest all (with coverage)", |
| 186 | + "adapter": "Debugpy", |
| 187 | + "request": "launch", |
| 188 | + "module": "pytest", |
| 189 | + "args": [ |
| 190 | + "-n=auto", |
| 191 | + "--cov-report=xml:html_coverage/cov.xml", |
| 192 | + "--cov-config=$ZED_WORKTREE_ROOT/backend/.coveragerc", |
| 193 | + "--cov=baserow", |
| 194 | + "backend/tests/", |
| 195 | + "premium/backend/tests/", |
| 196 | + "enterprise/backend/tests/", |
| 197 | + ], |
| 198 | + "cwd": "$ZED_WORKTREE_ROOT", |
| 199 | + "python": "$ZED_WORKTREE_ROOT/.venv/bin/python", |
| 200 | + "justMyCode": false, |
| 201 | + "console": "integratedTerminal", |
| 202 | + "env": { |
| 203 | + "PYTHONPATH": "backend/src:premium/backend/src:enterprise/backend/src", |
| 204 | + "DJANGO_SETTINGS_MODULE": "baserow.config.settings.test", |
| 205 | + "DATABASE_HOST": "localhost", |
| 206 | + }, |
| 207 | + }, |
| 208 | +] |
0 commit comments