repotoire 0.3.112

Graph-powered code analysis CLI. 114 detectors for security, architecture, and code quality.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
# CI/CD Integration

Integrate Repotoire into your continuous integration pipeline to catch issues before they reach production.

## Table of Contents

- [Quick Start]#quick-start
- [GitHub Actions]#github-actions
- [GitLab CI]#gitlab-ci
- [Jenkins]#jenkins
- [CircleCI]#circleci
- [Azure Pipelines]#azure-pipelines
- [Pre-commit Hooks]#pre-commit-hooks
- [Best Practices]#best-practices

---

## Quick Start

The key options for CI:

```bash
# Basic CI run
repotoire analyze . --fail-on critical --no-emoji

# Options:
#   --fail-on <LEVEL>   Exit code 1 if findings at this severity or higher
#   --no-emoji          Clean output for CI logs
#   --format json       Machine-readable output
#   --output FILE       Save report to file
```

---

## GitHub Actions

### Basic Workflow

```yaml
# .github/workflows/code-quality.yml
name: Code Quality

on:
  push:
    branches: [main]
  pull_request:
    branches: [main]

jobs:
  repotoire:
    runs-on: ubuntu-latest
    
    steps:
      - uses: actions/checkout@v4
      
      - name: Install Repotoire
        run: |
          curl -L https://github.com/Zach-hammad/repotoire/releases/latest/download/repotoire-linux-x86_64.tar.gz | tar xz
          sudo mv repotoire /usr/local/bin/
      
      - name: Run Code Analysis
        run: repotoire analyze . --fail-on critical --no-emoji
```

### With SARIF Upload (Code Scanning)

GitHub can display findings directly in pull requests using SARIF:

```yaml
# .github/workflows/code-quality.yml
name: Code Quality

on:
  push:
    branches: [main]
  pull_request:
    branches: [main]

jobs:
  repotoire:
    runs-on: ubuntu-latest
    permissions:
      security-events: write
      contents: read
    
    steps:
      - uses: actions/checkout@v4
      
      - name: Install Repotoire
        run: |
          curl -L https://github.com/Zach-hammad/repotoire/releases/latest/download/repotoire-linux-x86_64.tar.gz | tar xz
          sudo mv repotoire /usr/local/bin/
      
      - name: Run Code Analysis
        run: repotoire analyze . --format sarif --output results.sarif
        continue-on-error: true
      
      - name: Upload SARIF
        uses: github/codeql-action/upload-sarif@v3
        with:
          sarif_file: results.sarif
      
      - name: Fail on Critical
        run: repotoire analyze . --fail-on critical --no-emoji
```

### With Caching

Speed up repeated runs:

```yaml
jobs:
  repotoire:
    runs-on: ubuntu-latest
    
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0  # Full history for git analysis
      
      - name: Cache Repotoire Data
        uses: actions/cache@v4
        with:
          path: .repotoire
          key: repotoire-${{ runner.os }}-${{ hashFiles('**/*.py', '**/*.js', '**/*.ts') }}
          restore-keys: |
            repotoire-${{ runner.os }}-
      
      - name: Install Repotoire
        run: |
          curl -L https://github.com/Zach-hammad/repotoire/releases/latest/download/repotoire-linux-x86_64.tar.gz | tar xz
          sudo mv repotoire /usr/local/bin/
      
      - name: Run Analysis
        run: repotoire analyze . --fail-on high --no-emoji
```

### PR Comment with Results

Post findings as a comment on pull requests:

```yaml
jobs:
  repotoire:
    runs-on: ubuntu-latest
    permissions:
      pull-requests: write
      contents: read
    
    steps:
      - uses: actions/checkout@v4
      
      - name: Install Repotoire
        run: |
          curl -L https://github.com/Zach-hammad/repotoire/releases/latest/download/repotoire-linux-x86_64.tar.gz | tar xz
          sudo mv repotoire /usr/local/bin/
      
      - name: Run Analysis
        id: analyze
        run: |
          repotoire analyze . --format markdown --output report.md --no-emoji
          echo "report<<EOF" >> $GITHUB_OUTPUT
          cat report.md >> $GITHUB_OUTPUT
          echo "EOF" >> $GITHUB_OUTPUT
        continue-on-error: true
      
      - name: Comment PR
        uses: actions/github-script@v7
        if: github.event_name == 'pull_request'
        with:
          script: |
            github.rest.issues.createComment({
              issue_number: context.issue.number,
              owner: context.repo.owner,
              repo: context.repo.repo,
              body: `## 🎼 Repotoire Report\n\n${{ steps.analyze.outputs.report }}`
            })
      
      - name: Fail on Critical
        run: repotoire analyze . --fail-on critical --no-emoji
```

---

## GitLab CI

### Basic Pipeline

```yaml
# .gitlab-ci.yml
stages:
  - quality

code-quality:
  stage: quality
  image: rust:latest
  before_script:
    - curl -L https://github.com/Zach-hammad/repotoire/releases/latest/download/repotoire-linux-x86_64.tar.gz | tar xz
    - mv repotoire /usr/local/bin/
  script:
    - repotoire analyze . --fail-on critical --no-emoji
  cache:
    paths:
      - .repotoire/
```

### With Code Quality Report

GitLab can display code quality reports in merge requests:

```yaml
# .gitlab-ci.yml
code-quality:
  stage: quality
  image: rust:latest
  before_script:
    - curl -L https://github.com/Zach-hammad/repotoire/releases/latest/download/repotoire-linux-x86_64.tar.gz | tar xz
    - mv repotoire /usr/local/bin/
  script:
    - repotoire analyze . --format json --output gl-code-quality-report.json --no-emoji
    - repotoire analyze . --fail-on high --no-emoji
  artifacts:
    reports:
      codequality: gl-code-quality-report.json
    paths:
      - gl-code-quality-report.json
    expire_in: 1 week
  cache:
    paths:
      - .repotoire/
```

### Merge Request Only

```yaml
code-quality:
  stage: quality
  rules:
    - if: $CI_PIPELINE_SOURCE == "merge_request_event"
  # ... rest of config
```

---

## Jenkins

### Declarative Pipeline

```groovy
// Jenkinsfile
pipeline {
    agent any
    
    stages {
        stage('Install Repotoire') {
            steps {
                sh '''
                    curl -L https://github.com/Zach-hammad/repotoire/releases/latest/download/repotoire-linux-x86_64.tar.gz | tar xz
                    chmod +x repotoire
                '''
            }
        }
        
        stage('Code Analysis') {
            steps {
                sh './repotoire analyze . --format json --output report.json --no-emoji'
                sh './repotoire analyze . --fail-on critical --no-emoji'
            }
            post {
                always {
                    archiveArtifacts artifacts: 'report.json', fingerprint: true
                }
            }
        }
    }
}
```

### With HTML Report

```groovy
pipeline {
    agent any
    
    stages {
        stage('Install') {
            steps {
                sh '''
                    curl -L https://github.com/Zach-hammad/repotoire/releases/latest/download/repotoire-linux-x86_64.tar.gz | tar xz
                    chmod +x repotoire
                '''
            }
        }
        
        stage('Analyze') {
            steps {
                sh './repotoire analyze . --format html --output report.html --no-emoji'
            }
            post {
                always {
                    publishHTML(target: [
                        allowMissing: false,
                        alwaysLinkToLastBuild: true,
                        keepAll: true,
                        reportDir: '.',
                        reportFiles: 'report.html',
                        reportName: 'Repotoire Report'
                    ])
                }
            }
        }
        
        stage('Quality Gate') {
            steps {
                sh './repotoire analyze . --fail-on critical --no-emoji'
            }
        }
    }
}
```

### Scripted Pipeline

```groovy
node {
    stage('Checkout') {
        checkout scm
    }
    
    stage('Install Repotoire') {
        sh '''
            curl -L https://github.com/Zach-hammad/repotoire/releases/latest/download/repotoire-linux-x86_64.tar.gz | tar xz
            chmod +x repotoire
        '''
    }
    
    stage('Code Quality') {
        def status = sh(
            script: './repotoire analyze . --fail-on critical --no-emoji',
            returnStatus: true
        )
        
        if (status != 0) {
            currentBuild.result = 'UNSTABLE'
            error('Critical code quality issues found!')
        }
    }
}
```

---

## CircleCI

### Basic Config

```yaml
# .circleci/config.yml
version: 2.1

jobs:
  code-quality:
    docker:
      - image: cimg/base:stable
    steps:
      - checkout
      - run:
          name: Install Repotoire
          command: |
            curl -L https://github.com/Zach-hammad/repotoire/releases/latest/download/repotoire-linux-x86_64.tar.gz | tar xz
            sudo mv repotoire /usr/local/bin/
      - run:
          name: Run Analysis
          command: repotoire analyze . --fail-on critical --no-emoji
      - store_artifacts:
          path: .repotoire
          destination: analysis-cache

workflows:
  main:
    jobs:
      - code-quality
```

### With Caching

```yaml
version: 2.1

jobs:
  code-quality:
    docker:
      - image: cimg/base:stable
    steps:
      - checkout
      
      - restore_cache:
          keys:
            - repotoire-{{ checksum "Cargo.lock" }}
            - repotoire-
      
      - run:
          name: Install Repotoire
          command: |
            if [ ! -f /usr/local/bin/repotoire ]; then
              curl -L https://github.com/Zach-hammad/repotoire/releases/latest/download/repotoire-linux-x86_64.tar.gz | tar xz
              sudo mv repotoire /usr/local/bin/
            fi
      
      - run:
          name: Run Analysis
          command: repotoire analyze . --format json --output report.json --no-emoji
      
      - run:
          name: Quality Gate
          command: repotoire analyze . --fail-on critical --no-emoji
      
      - save_cache:
          paths:
            - .repotoire
          key: repotoire-{{ checksum "Cargo.lock" }}
      
      - store_artifacts:
          path: report.json

workflows:
  quality:
    jobs:
      - code-quality
```

### Orb (Reusable)

```yaml
# Create as: .circleci/orbs/repotoire.yml
version: 2.1

description: Repotoire code quality analysis

commands:
  analyze:
    parameters:
      fail_on:
        type: string
        default: "critical"
    steps:
      - run:
          name: Install Repotoire
          command: |
            curl -L https://github.com/Zach-hammad/repotoire/releases/latest/download/repotoire-linux-x86_64.tar.gz | tar xz
            sudo mv repotoire /usr/local/bin/
      - run:
          name: Run Analysis
          command: repotoire analyze . --fail-on << parameters.fail_on >> --no-emoji

jobs:
  quality-check:
    docker:
      - image: cimg/base:stable
    parameters:
      fail_on:
        type: string
        default: "critical"
    steps:
      - checkout
      - analyze:
          fail_on: << parameters.fail_on >>
```

---

## Azure Pipelines

```yaml
# azure-pipelines.yml
trigger:
  - main

pool:
  vmImage: 'ubuntu-latest'

steps:
  - checkout: self
    fetchDepth: 0

  - script: |
      curl -L https://github.com/Zach-hammad/repotoire/releases/latest/download/repotoire-linux-x86_64.tar.gz | tar xz
      sudo mv repotoire /usr/local/bin/
    displayName: 'Install Repotoire'

  - script: repotoire analyze . --format sarif --output $(Build.ArtifactStagingDirectory)/results.sarif --no-emoji
    displayName: 'Run Analysis'
    continueOnError: true

  - task: PublishBuildArtifacts@1
    inputs:
      PathtoPublish: '$(Build.ArtifactStagingDirectory)'
      ArtifactName: 'CodeAnalysis'

  - script: repotoire analyze . --fail-on critical --no-emoji
    displayName: 'Quality Gate'
```

---

## Pre-commit Hooks

### Using pre-commit framework

```yaml
# .pre-commit-config.yaml
repos:
  - repo: local
    hooks:
      - id: repotoire
        name: Repotoire Code Quality
        entry: repotoire analyze . --relaxed --no-emoji
        language: system
        pass_filenames: false
        stages: [pre-commit]
```

Install:
```bash
pip install pre-commit
pre-commit install
```

### Using Git hooks directly

```bash
# .git/hooks/pre-commit
#!/bin/bash

echo "Running Repotoire analysis..."

if ! repotoire analyze . --fail-on critical --no-emoji --relaxed; then
    echo ""
    echo "❌ Critical issues found. Fix them before committing."
    echo "   Run 'repotoire findings' to see details."
    exit 1
fi

echo "✅ Code quality check passed"
```

Make it executable:
```bash
chmod +x .git/hooks/pre-commit
```

### Pre-push Hook

For longer analysis on push:

```bash
# .git/hooks/pre-push
#!/bin/bash

echo "Running full Repotoire analysis..."

if ! repotoire analyze . --fail-on high --no-emoji; then
    echo ""
    echo "❌ High-severity issues found. Fix them before pushing."
    exit 1
fi
```

---

## Best Practices

### 1. Start Lenient, Get Stricter

Begin with `--fail-on critical`, then gradually raise the bar:

```yaml
# Week 1-2: Block only critical
- run: repotoire analyze . --fail-on critical

# Week 3-4: Block high and above
- run: repotoire analyze . --fail-on high

# Eventually: Block medium and above
- run: repotoire analyze . --fail-on medium
```

### 2. Use `--relaxed` for Speed

In pre-commit hooks, use `--relaxed` for faster feedback:

```bash
repotoire analyze . --relaxed  # Only high/critical, faster
```

### 3. Cache Analysis Data

Cache `.repotoire/` directory between runs:

```yaml
# GitHub Actions
- uses: actions/cache@v4
  with:
    path: .repotoire
    key: repotoire-${{ hashFiles('**/*.py', '**/*.js') }}
```

### 4. Skip Git Analysis in CI

If git history analysis is slow:

```bash
repotoire analyze . --no-git
```

### 5. Generate Reports

Always generate a report artifact:

```bash
repotoire analyze . --format json --output report.json
repotoire analyze . --format html --output report.html
```

### 6. Use SARIF for GitHub

SARIF integrates findings directly into GitHub's Security tab and PR diffs.

### 7. Baseline for Existing Projects

For legacy codebases, skip existing findings and only fail on new ones:

```bash
# First run: establish baseline
repotoire analyze . --format json --output baseline.json

# CI: compare against baseline (future feature)
# For now, start with --relaxed and improve gradually
```

### 8. Exit Codes

| Code | Meaning |
|------|---------|
| 0 | Success (no findings above threshold) |
| 1 | Findings at/above `--fail-on` severity |
| 2 | Error during analysis |

Use in scripts:

```bash
repotoire analyze . --fail-on critical
if [ $? -eq 1 ]; then
    echo "Quality gate failed!"
    exit 1
fi
```

---

## Troubleshooting

### "cmake not found" during install

Pre-built binaries don't need cmake. Use the curl/tar install:

```bash
curl -L https://github.com/Zach-hammad/repotoire/releases/latest/download/repotoire-linux-x86_64.tar.gz | tar xz
```

### Analysis taking too long

```bash
# Skip git history
repotoire analyze . --no-git

# Use relaxed mode
repotoire analyze . --relaxed

# Increase workers
repotoire analyze . --workers 16
```

### "No such file: .repotoire"

Run `repotoire clean` to reset, then re-run analysis:

```bash
repotoire clean
repotoire analyze .
```