Skip to content

Open-MBEE/flexo-pr-manager

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Flexo PR Manager

Minimal web service for tracking model-based pull requests against Flexo/OpenMBEE MMS projects.

What it does

  • Lists MMS projects and branches using the same basic selection flow already used in sysmlv2viz
  • Stores pull requests and reviews in SQLite
  • Tracks per-project pull requests with source and target branches, commit snapshots, status, and review history
  • Supports review decisions: COMMENTED, APPROVED, and CHANGES_REQUESTED
  • Generates source, target, and base commit URLs for LemonTree handoff
  • Runs as a single Dockerized web service

Stack

  • FastAPI backend
  • Static HTML/CSS/JS frontend
  • SQLite for PR metadata

Run locally

python -m venv .venv
. .venv/Scripts/activate
pip install -r requirements.txt
uvicorn app.main:app --reload

Open http://localhost:8080.

Run with Docker

docker compose up --build

Open http://localhost:8080.

Run tests

Use unittest discovery:

python -m unittest discover -s tests

The repository currently has a single smoke-style test module, tests/test_smoke.py, which covers:

  • GET /api/health
  • Creating a pull request
  • Adding one approval review and observing the resulting APPROVED status
  • Generating one source commit URL

python -m unittest by itself does not discover this suite in the current layout, so the discovery command above should be used in local development and CI.

Configuration

Environment variables:

  • DATABASE_PATH: SQLite database location. Default /data/flexo-prs.db
  • DEFAULT_MMS_BASE_URL: Optional default MMS API base URL prefilled in the UI
  • DEFAULT_BEARER_TOKEN: Optional default bearer token prefilled in the UI
  • LEMMONTREE_DIFF_URL_TEMPLATE: Optional 2-way LemonTree URL template
  • LEMMONTREE_MERGE_URL_TEMPLATE: Optional 3-way LemonTree URL template

Template placeholders:

  • {source}, {target}, {base} for raw commit URLs
  • {sourceEncoded}, {targetEncoded}, {baseEncoded} for URL-encoded commit URLs

Example:

LEMMONTREE_DIFF_URL_TEMPLATE=https://lemmontree.example/diff?left={sourceEncoded}&right={targetEncoded}
LEMMONTREE_MERGE_URL_TEMPLATE=https://lemmontree.example/merge?base={baseEncoded}&source={sourceEncoded}&target={targetEncoded}

Notes

  • The PR manager stores metadata only. It does not execute model diffs or merges itself.
  • The base_commit_id currently defaults to the target branch head at PR creation time so a 3-way tool can be handed a stable baseline snapshot.

Missing Unit Tests

The implemented functionality is broader than the current automated coverage. The highest-value missing tests are:

  • API validation and error paths in app/main.py: missing coverage for blank apiBase, identical source and target branches, unknown pull request IDs, and invalid status or review payloads rejected by FastAPI/Pydantic.
  • Pull request query behavior in app/main.py: missing tests for project and status filtering, ordering by updated_at, and the detail endpoint returning review history.
  • Review aggregation logic in app/main.py: missing tests for summarize_reviews() and compute_pr_status() across mixed reviewer states, duplicate reviews from the same reviewer, comment-only reviews, CHANGES_REQUESTED precedence, and preserving CLOSED or MERGED.
  • MMS client helpers in app/mms.py: missing unit tests for bearer token normalization, HTTP error translation, empty JSON responses, project normalization, branch commit resolution from both referencedCommit and head, branch sorting, and the 500-status fallback that reads defaultBranch from the project record.
  • Database initialization in app/db.py: missing tests that init_db() creates the parent directory, applies the schema successfully, and enables foreign-key behavior through connect().
  • Settings and config exposure in app/settings.py and /api/config: missing tests that environment variables are trimmed and surfaced correctly to the frontend.
  • Static page routes in app/main.py: missing tests for / and /pulls/new returning the expected HTML files.
  • Frontend behavior in app/static/index.html and app/static/new-pr.html: there are no automated tests for project loading, branch selection, URL generation, LemonTree template interpolation, copy actions, status transitions, or pull-request creation flows.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors