Skip to main content

Examples & Tutorials

Real-world examples of webhook setup, CI/CD integration, Docker deployment, and common drep workflows.

Webhook Setup

Configure webhooks to automatically trigger drep scans and PR reviews when code is pushed.

Gitea Webhook

  1. Start drep webhook server:
    bash
    drep serve --host 0.0.0.0 --port 8000
  2. In Gitea, go to Repository → Settings → Webhooks
  3. Add webhook with these settings:
    • Target URL: http://your-server:8000/webhooks/gitea
    • HTTP Method: POST
    • Trigger On: Push events, Pull request events
    • Active: Checked

GitHub Webhook

  1. Start drep webhook server (same as above)
  2. In GitHub, go to Repository → Settings → Webhooks → Add webhook
  3. Configure:
    • Payload URL: http://your-server:8000/webhooks/github
    • Content type: application/json
    • Events: Push events, Pull requests

Public Internet Access

For GitHub webhooks, your drep server must be accessible from the public internet. Consider using ngrok for local development or deploy to a VPS.

Docker Deployment

Deploy drep with Docker for easy setup and reproducible environments.

Docker Compose with Ollama

Complete setup with drep and Ollama LLM backend:

yaml
version: '3.8'
services:
  drep:
    image: ghcr.io/slb350/drep:latest
    ports:
      - "8000:8000"
    volumes:
      - ./config.yaml:/app/config.yaml
      - ./data:/app/data
    environment:
      - DREP_LLM_ENDPOINT=http://ollama:11434
      - GITEA_TOKEN=${GITEA_TOKEN}
    depends_on:
      - ollama

  ollama:
    image: ollama/ollama:latest
    ports:
      - "11434:11434"
    volumes:
      - ollama_data:/root/.ollama

volumes:
  ollama_data:

Start services:

bash
# Pull Ollama model
docker compose exec ollama ollama pull qwen2.5-coder:32b

# Start services
docker compose up -d

# View logs
docker compose logs -f drep

CI/CD Integration

GitHub Actions

Run drep in your GitHub Actions workflow:

yaml
name: drep Code Review

on:
  pull_request:
    types: [opened, synchronize]

jobs:
  drep-review:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3

      - name: Set up Python
        uses: actions/setup-python@v4
        with:
          python-version: '3.11'

      - name: Install drep
        run: pip install drep-ai

      - name: Review PR
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          DREP_LLM_ENDPOINT: ${{ secrets.LLM_ENDPOINT }}
        run: |
          drep review ${{ github.repository }} ${{ github.event.pull_request.number }}

GitLab CI

yaml
drep-review:
  image: python:3.11
  stage: test
  only:
    - merge_requests
  script:
    - pip install drep-ai
    - drep review $CI_PROJECT_PATH $CI_MERGE_REQUEST_IID
  variables:
    GITLAB_TOKEN: $GITLAB_TOKEN
    DREP_LLM_ENDPOINT: $LLM_ENDPOINT

Real Output Examples

PR Review Summary

Example of drep's PR review comment:

## 🤖 drep AI Code Review

Looks great overall! Tests cover the new behavior and naming is clear.

**Recommendation:** ✅ Approve

---
*Generated by drep using qwen3-30b-a3b*

Docstring Suggestion

Example docstring generated by drep:

python
def calculate_total(prices: List[float], tax_rate: float) -> float:
    """
    Compute the final invoice total including tax.

    Args:
        prices: Individual line-item amounts.
        tax_rate: Tax rate expressed as a decimal.

    Returns:
        Total amount with tax applied.
    """
    subtotal = sum(prices)
    return subtotal * (1 + tax_rate)

Metrics Output

Example of drep metrics --detailed:

===== LLM Usage Report =====
Session duration: 0h 5m 32s
Total requests: 127 (115 successful, 12 failed, 95 cached)
Success rate: 90.6%
Cache hit rate: 74.8%

Tokens used: 45,230 prompt + 12,560 completion = 57,790 total
Estimated cost: $0.29 USD (or $0 with LM Studio)

Performance:
  Average latency: 1250ms
  Min/Max: 450ms / 3200ms

By Analyzer:
  code_quality: 45 requests (12,345 tokens)
  docstring: 38 requests (8,901 tokens)
  pr_review: 44 requests (36,544 tokens)

Common Workflows

Manual Repository Scan

bash
# Scan repository and show metrics
drep scan myorg/myrepo --show-metrics

# Scan with custom config
drep scan myorg/myrepo --config production.yaml

# Export metrics to JSON
drep metrics --export scan-results.json

Pull Request Review

bash
# Review PR and post comments
drep review myorg/myrepo 42

# Dry run (no comments posted)
drep review myorg/myrepo 42 --no-post

# Review multiple PRs
for pr in 42 43 44; do
  drep review myorg/myrepo $pr
done

Documentation Linting

bash
# Lint all markdown files
drep lint-docs ./docs

# JSON output for CI
drep lint-docs ./docs --output json

# Lint specific file
drep lint-docs README.md

Need More Examples?

Check out the drep repository for more examples, or create an issue to request specific use cases.