Skip to main content

Historical deployment analysis โ€” walk git history, deploy per day, test all endpoints, capture screenshots, restore working fragments

Project description

rebuild

AI Cost Tracking

PyPI Version Python License AI Cost Human Time Model

  • ๐Ÿค– LLM usage: $1.0500 (7 commits)
  • ๐Ÿ‘ค Human dev: ~$220 (2.2h @ $100/h, 30min dedup)

Generated on 2026-05-01 using openrouter/qwen/qwen3-coder-next


Historical deployment analysis โ€” walk git history day by day, deploy per commit, test all endpoints, capture screenshots, restore working fragments.

Version Python License Tests


What it does

  1. Walk โ€” iterates through git history day by day (configurable range)
  2. Deploy โ€” starts the service per commit (docker-compose / uvicorn / none)
  3. Scan โ€” detects endpoints via deta scan โ†’ OpenAPI โ†’ Traefik labels fallback
  4. Test โ€” runs testql scenarios or falls back to HTTP probe per endpoint
  5. Screenshot โ€” Playwright screenshots per endpoint with retry/timeout
  6. Report โ€” generates report.html + results.json per day + timeline index.html
  7. Restore โ€” extracts the last working day of an endpoint as an isolated project
  8. Dashboard โ€” overlays health% timeline with avg cyclomatic complexity (via toon)

Install

pip install rebuild

# with Playwright screenshots
pip install "rebuild[screenshots]"
playwright install chromium

# development
pip install -e ".[dev]"

Quick start

# Dry-run: scan last 30 days without deploy
rebuild walk . --days 30 --dry-run

# Full walk with docker-compose
rebuild walk . --days 30 --deploy docker-compose

# Walk a specific date range
rebuild walk /path/to/repo --from 2024-01-01 --to 2024-04-01

# Restore last working version of an endpoint
rebuild restore /api/health .

# Generate timeline report from existing results
rebuild report

# Generate CC vs health% dashboard
rebuild dashboard --repo .

# Show version
rebuild version

CLI reference

rebuild walk

rebuild walk [REPO] [OPTIONS]

  REPO                    Path to git repository (default: .)

Options:
  --days INT              How many days back (default: 30)
  --from TEXT             Start date YYYY-MM-DD
  --to TEXT               End date YYYY-MM-DD
  --output PATH           Output directory (default: .rebuild)
  --deploy TEXT           Deploy method: auto|docker-compose|uvicorn|none
  --health-url TEXT       Health check URL (default: http://localhost:8003/api/health)
  --base-url TEXT         Base service URL (default: http://localhost:8003)
  --screenshots / --no-screenshots
                          Take Playwright screenshots (default: true)
  --dry-run               Scan only, no deploy

rebuild restore

rebuild restore ENDPOINT [REPO] [OPTIONS]

  ENDPOINT                Endpoint path e.g. /api/health

Options:
  --output PATH           Target project directory (default: restored/)
  --results-dir PATH      Walk results directory (default: .rebuild)

rebuild report

rebuild report [OPTIONS]

Options:
  --results-dir PATH      Walk results directory (default: .rebuild)

rebuild dashboard

rebuild dashboard [OPTIONS]

Options:
  --results-dir PATH      Walk results directory (default: .rebuild)
  --repo PATH             Repository path for CC extraction via toon (optional)

Output structure

.rebuild/
  2024-03-15/
    commit.txt              # sha ยท message ยท author ยท timestamp
    endpoints.json          # detected endpoints
    results.json            # HTTP / testql results per endpoint
    testql-results.json     # raw testql output (if testql available)
    report.html             # per-day HTML report with screenshots
    screenshots/
      GET_api_health.png
      GET_api_items.png
  index.html                # timeline of all days
  dashboard.html            # CC vs health% chart (after rebuild dashboard)

Configuration โ€” rebuild.yaml

project:
  name: "my-api"
  repo: "."

deploy:
  method: docker-compose          # docker-compose | uvicorn | custom | none
  compose_file: docker-compose.yml
  health_url: http://localhost:8003/api/health
  health_timeout: 60
  health_interval: 2

scan:
  days: 30
  earliest_commit_per_day: true

testql:
  scenarios_dir: testql-scenarios/
  base_url: http://localhost:8003
  timeout: 10

output:
  dir: .rebuild
  screenshots: true
  html_report: true

Architecture

rebuild/
โ”œโ”€โ”€ rebuild/
โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ”œโ”€โ”€ cli.py              # Typer CLI: walk, restore, report, version, dashboard
โ”‚   โ”œโ”€โ”€ models.py           # Dataclasses: WalkConfig, DayResult, Endpoint, CommitInfo
โ”‚   โ”œโ”€โ”€ git_walker.py       # Day-by-day git history iteration
โ”‚   โ”œโ”€โ”€ deployer.py         # Deploy method detection + docker-compose/uvicorn lifecycle
โ”‚   โ”œโ”€โ”€ endpoint_scanner.py # deta scan โ†’ OpenAPI โ†’ Traefik labels fallback
โ”‚   โ”œโ”€โ”€ tester.py           # testql runner with HTTP probe fallback
โ”‚   โ”œโ”€โ”€ screenshotter.py    # Playwright screenshots with retry/timeout
โ”‚   โ”œโ”€โ”€ reporter.py         # HTML + JSON report per day + timeline index
โ”‚   โ”œโ”€โ”€ restorer.py         # Extract last working endpoint as isolated project
โ”‚   โ””โ”€โ”€ dashboard.py        # CC (toon) vs health% comparative timeline
โ”œโ”€โ”€ tests/                  # 44 tests (pytest)
โ”œโ”€โ”€ examples/
โ”‚   โ”œโ”€โ”€ 01-dry-run-walk/
โ”‚   โ”œโ”€โ”€ 02-docker-compose-project/
โ”‚   โ””โ”€โ”€ 03-restore-endpoint/
โ”œโ”€โ”€ testql-scenarios/
โ”œโ”€โ”€ pyproject.toml
โ””โ”€โ”€ rebuild.yaml.example

Endpoint scanner โ€” 3-level fallback

Level Source What it returns
1 deta scan services โ†’ ports โ†’ health paths
2 /openapi.json full endpoint list from OpenAPI spec
3 docker-compose Traefik labels PathPrefix rules
4 hardcoded fallback GET /api/health

Tester โ€” 2-level fallback

Level Condition Behaviour
1 testql installed + testql_dir set runs .testql.yaml scenarios
2 fallback HTTP GET probe per endpoint

Module summary

Module CCฬ„ Functions Purpose
cli 6.3 8 CLI entry points
models โ€” โ€” Dataclasses only
git_walker 3.3 6 Git history iteration
deployer 3.5 9 Deploy lifecycle
endpoint_scanner 5.5 6 Endpoint detection
tester 4.3 6 Endpoint testing
screenshotter 3.6 5 Screenshots
reporter 6.0 6 HTML/JSON reports
restorer 5.5 5 Endpoint extraction
dashboard 4.5 4 CC vs health chart

Hotspots (CC โ‰ฅ 9): walk (CC=15), report (CC=13), extract_endpoint (CC=9), save_html (CC=9), _scan_via_compose_labels (CC=9)


Dependencies

Runtime: typer>=0.12, rich>=13, gitpython>=3.1, httpx>=0.27, pyyaml>=6, pydantic>=2, deta>=0.1

Optional: playwright>=1.44 (screenshots)

Dev: pytest>=8, pytest-cov, pytest-asyncio, ruff, mypy


Examples

See examples/ for ready-to-run scenarios:


License

Licensed under Apache-2.0.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rebuild-0.1.7.tar.gz (33.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rebuild-0.1.7-py3-none-any.whl (30.5 kB view details)

Uploaded Python 3

File details

Details for the file rebuild-0.1.7.tar.gz.

File metadata

  • Download URL: rebuild-0.1.7.tar.gz
  • Upload date:
  • Size: 33.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for rebuild-0.1.7.tar.gz
Algorithm Hash digest
SHA256 3000ca8d98dbb58a743b2ecf8abe5916229069d1d8b11f9e017401088e0b5e14
MD5 346fc11b3b1c67b1c2c05a2153dd70a3
BLAKE2b-256 97cae42fc39780a105cc556106653ae4e9d5d02443cc3fd1f4e5d1df2a5dbb33

See more details on using hashes here.

File details

Details for the file rebuild-0.1.7-py3-none-any.whl.

File metadata

  • Download URL: rebuild-0.1.7-py3-none-any.whl
  • Upload date:
  • Size: 30.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for rebuild-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 c6b835026cefa49b54e1355c4094945c660354c378e385a2168aa1b1ab9239fe
MD5 11b1f4f61f0d8a03ba2501471275da88
BLAKE2b-256 905d2cf6b4a1ee4a805ec98017234391fad721653a0775b79a0095e5416a22f6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page