Navegador

navegador / docs / guide / ci-cd.md
1
# CI/CD Integration
2
3
Navegador's `ci` subcommand is designed for non-interactive use in pipelines. All CI commands emit structured output and use exit codes that CI systems understand.
4
5
---
6
7
## CI commands
8
9
### `navegador ci ingest`
10
11
Ingest the repo and output a machine-readable summary. Exits non-zero on errors.
12
13
```bash
14
navegador ci ingest ./src
15
```
16
17
JSON output (always on in CI mode):
18
19
```json
20
{
21
"status": "ok",
22
"nodes_created": 1240,
23
"nodes_updated": 38,
24
"edges_created": 4821,
25
"files_processed": 87,
26
"errors": [],
27
"duration_seconds": 4.2
28
}
29
```
30
31
### `navegador ci stats`
32
33
Print graph statistics as JSON. Use to track graph growth over time or assert a minimum coverage threshold.
34
35
```bash
36
navegador ci stats
37
```
38
39
```json
40
{
41
"repositories": 1,
42
"files": 87,
43
"classes": 143,
44
"functions": 891,
45
"methods": 412,
46
"concepts": 14,
47
"rules": 9,
48
"decisions": 6,
49
"total_edges": 4821
50
}
51
```
52
53
### `navegador ci check`
54
55
Run assertion checks against the graph. Exits non-zero if any check fails.
56
57
```bash
58
navegador ci check
59
```
60
61
Checks run by default:
62
63
| Check | Condition for failure |
64
|---|---|
65
| `no-cycles` | Circular import chains detected |
66
| `min-coverage` | Functions with no tests below threshold |
67
| `critical-rules` | Code violates a `critical`-severity rule |
68
| `dead-code` | High-confidence dead code above threshold |
69
70
Configure checks in `navegador.toml`:
71
72
```toml
73
[ci.checks]
74
no-cycles = true
75
min-coverage = 60 # percent of functions with tests
76
critical-rules = true
77
dead-code = false # disable dead-code check
78
79
[ci.thresholds]
80
dead_code_max = 10 # fail if more than 10 dead-code candidates
81
uncovered_max_percent = 40 # fail if more than 40% of functions lack tests
82
```
83
84
### Running specific checks
85
86
```bash
87
navegador ci check --only no-cycles
88
navegador ci check --only critical-rules,min-coverage
89
navegador ci check --skip dead-code
90
```
91
92
---
93
94
## Exit codes
95
96
| Code | Meaning |
97
|---|---|
98
| `0` | Success — all checks passed |
99
| `1` | Check failure — one or more assertions failed |
100
| `2` | Ingest error — files could not be parsed (partial result) |
101
| `3` | Configuration error — bad flags or missing config |
102
| `4` | Connection error — cannot reach database or Redis |
103
104
---
105
106
## GitHub Actions
107
108
### Basic: ingest on push
109
110
```yaml
111
# .github/workflows/navegador.yml
112
name: navegador
113
114
on:
115
push:
116
branches: [main]
117
pull_request:
118
119
jobs:
120
graph:
121
runs-on: ubuntu-latest
122
steps:
123
- uses: actions/checkout@v4
124
125
- name: Install navegador
126
run: pip install navegador
127
128
- name: Ingest
129
run: navegador ci ingest ./src
130
131
- name: Check
132
run: navegador ci check
133
```
134
135
### With graph caching
136
137
Cache the SQLite database between runs to speed up incremental ingestion:
138
139
```yaml
140
- name: Cache navegador graph
141
uses: actions/cache@v4
142
with:
143
path: .navegador/navegador.db
144
key: navegador-${{ runner.os }}-${{ hashFiles('src/**') }}
145
restore-keys: navegador-${{ runner.os }}-
146
147
- name: Ingest
148
run: navegador ci ingest ./src
149
150
- name: Check
151
run: navegador ci check
152
```
153
154
### Shared graph via Redis (cluster mode)
155
156
Use a shared Redis instance for team-wide graph persistence across branches and PRs:
157
158
```yaml
159
- name: Ingest to shared graph
160
env:
161
NAVEGADOR_REDIS_URL: ${{ secrets.NAVEGADOR_REDIS_URL }}
162
run: |
163
navegador ci ingest ./src --cluster
164
navegador ci check --cluster
165
```
166
167
### PR impact report
168
169
Post an impact analysis comment on pull requests:
170
171
```yaml
172
- name: Impact analysis
173
if: github.event_name == 'pull_request'
174
run: |
175
CHANGED=$(git diff --name-only origin/main...HEAD | grep '\.py$' | head -20)
176
for f in $CHANGED; do
177
navegador ci ingest "$f"
178
done
179
navegador impact --changed-since origin/main --format json > impact.json
180
181
- name: Comment impact
182
if: github.event_name == 'pull_request'
183
uses: actions/github-script@v7
184
with:
185
script: |
186
const impact = require('./impact.json')
187
const body = `## Navegador impact analysis\n\n${impact.summary}`
188
github.rest.issues.createComment({
189
issue_number: context.issue.number,
190
owner: context.repo.owner,
191
repo: context.repo.repo,
192
body
193
})
194
```
195
196
---
197
198
## Editor integration
199
200
### VS Code
201
202
Install the [Navegador VS Code extension](https://marketplace.visualstudio.com/items?itemName=ConflictHQ.navegador) for inline context overlays and on-save re-ingest.
203
204
Or configure a task in `.vscode/tasks.json` to run on save:
205
206
```json
207
{
208
"version": "2.0.0",
209
"tasks": [
210
{
211
"label": "Navegador: re-ingest on save",
212
"type": "shell",
213
"command": "navegador ingest ${file}",
214
"group": "build",
215
"presentation": {
216
"reveal": "silent",
217
"panel": "shared"
218
},
219
"runOptions": {
220
"runOn": "folderOpen"
221
}
222
}
223
]
224
}
225
```
226
227
### Neovim
228
229
Add a post-write autocmd to trigger incremental ingest:
230
231
```lua
232
-- in your init.lua or a plugin config
233
vim.api.nvim_create_autocmd("BufWritePost", {
234
pattern = { "*.py", "*.ts", "*.tsx", "*.js" },
235
callback = function(ev)
236
local file = ev.file
237
vim.fn.jobstart({ "navegador", "ingest", file }, { detach = true })
238
end,
239
})
240
```
241
242
### Pre-commit hook
243
244
Run checks before committing:
245
246
```yaml
247
# .pre-commit-config.yaml
248
repos:
249
- repo: local
250
hooks:
251
- id: navegador-check
252
name: Navegador graph checks
253
entry: navegador ci check --only no-cycles,critical-rules
254
language: system
255
pass_filenames: false
256
stages: [commit]
257
```
258
259
---
260
261
## Secrets and auth
262
263
The graph database path and Redis URL should come from environment variables in CI, not from committed config:
264
265
```bash
266
# CI environment variables
267
NAVEGADOR_DB=.navegador/navegador.db # SQLite path
268
NAVEGADOR_REDIS_URL=redis://... # Redis URL (cluster mode)
269
GITHUB_TOKEN=ghp_... # for wiki ingestion
270
```
271
272
Set these as [GitHub Actions secrets](https://docs.github.com/en/actions/security-guides/using-secrets-in-github-actions) and reference them in your workflow with `${{ secrets.NAME }}`.
273

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button