Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .github/workflows/uigraph-sync.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: UIGraph sync

# Pushes this repository's .uigraph.yaml and .uigraph/ artifacts to UIGraph Cloud on every
# merge to main. Needs the repository secret UIGRAPH_TOKEN (a service account token).
# Organization secrets do not reach private repositories on our plan, so it is set per repo.

on:
push:
branches: [main]
workflow_dispatch: {}

concurrency:
group: uigraph-sync
cancel-in-progress: false

jobs:
sync:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Sync to UIGraph Cloud
env:
UIGRAPH_TOKEN: ${{ secrets.UIGRAPH_TOKEN }}
run: |
docker run --rm -v "$PWD:/workspace" -w /workspace \
-e UIGRAPH_TOKEN \
uigraph/uigraph-cli:1.0.10 sync --enterprise
Comment on lines +18 to +27
63 changes: 63 additions & 0 deletions .uigraph.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
version: 1

service:
name: uigraph-cli
category: CLI
description: Go CLI that reads a repository's .uigraph.yaml and syncs service metadata, API specs, dependencies, diagrams, databases, tests, docs, videos, timeline, maps, and MLflow projects to UIGraph through uigraph-gateway. Also records releases on the service timeline. Runs in CI from the uigraph/uigraph-cli Docker image or via go install.
repository:
provider: github
url: https://github.com/uigraph-oss/uigraph-cli
ownership:
team: Engineering
labels:
- cli
- go
- ci

dependencies:
- name: gateway-sync-api
service: uigraph-gateway
direction: downstream
criticality: hard
type: http
description: Every sync and release call goes to the gateway's /v1/sync routes with X-API-Token. --enterprise targets https://console.uigraph.app/gateway, --enterprise=DEV the dev console, --api-url or UIGRAPH_GATEWAY_URL a self-hosted gateway.
apiGroupName: gateway-api
- name: object-storage-uploads
service: Object Storage
direction: downstream
criticality: soft
type: http
description: Docs, frames, and test screenshots are PUT straight to presigned URLs that the gateway hands out.
- name: mlflow
service: MLflow
direction: downstream
criticality: soft
type: http
description: The ml section pulls models, experiments, and runs from an MLflow server before syncing them.
- name: api-onboarding-workflows
service: uigraph-api
direction: upstream
criticality: soft
description: The GitHub App's onboarding and sync workflows that uigraph-api commits into repositories run go install uigraph-cli@main and then uigraph-cli sync.

architectureDiagrams:
- name: uigraph-cli system context
path: .uigraph/diagrams/system-context/system-context.mmd
contextPath: .uigraph/diagrams/system-context/context.json
- name: Sync pipeline order
path: .uigraph/diagrams/sync-pipeline/sync-pipeline.mmd
contextPath: .uigraph/diagrams/sync-pipeline/context.json

docs:
- name: How uigraph-cli works
path: .uigraph/docs/overview.md
fileType: markdown
description: Commands, targets, the sync order, upload protocol, and how it is released.
- name: README
path: README.md
fileType: markdown
description: Installation with Go or Docker, and pointers to the hosted docs.
- name: Examples
path: examples/README.md
fileType: markdown
description: Example configs, specs, and CI/CD pipelines.
26 changes: 26 additions & 0 deletions .uigraph/AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# UIGraph artifacts

This repository describes its architecture in UIGraph artifacts: `.uigraph.yaml`, `.uigraph/services/*.yaml`, and the files under `.uigraph/`. The UIGraph viewer reads them, so keep them true to the code.

## When to update

Update artifacts only when your change does one of these. For any other change, do nothing here.

| Your change | Update |
|---|---|
| Adds, removes, or changes an HTTP, GraphQL, or gRPC endpoint, or its request or response fields | The spec listed under `apis` |
| Adds or changes a migration, ORM model, or DDL | The schema listed under `databases`, and each entry under `queries` that uses the changed tables |
| Starts or stops calling another service, datastore, or third-party API | `dependencies` in that service's config |
| Changes a flow that a diagram shows | That diagram's `.mmd` file |
| Adds a deployable service | A new config at `.uigraph/services/<service-name>.yaml` |
| Makes a doc listed under `docs` wrong | That doc |

## How to update

1. Read `.uigraph.yaml`, and `.uigraph/services/*.yaml` when the change is in another service. They list every artifact and its file. Open only the files your change affects, and do not explore the rest of `.uigraph/`.
2. Change only what your code change made wrong. Keep the existing structure, names, and order.
3. Base every change on code you read. Never invent endpoints, dependencies, tables, or flows.
4. In diagrams, never write `style`, `classDef`, `class`, `linkStyle`, or colors.
5. Run `npx --yes uigraph sync` and fix every problem it reports.

When you are not sure whether your change affects an artifact, leave the artifact as it is and say so in your summary.
6 changes: 6 additions & 0 deletions .uigraph/diagrams/sync-pipeline/context.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"nodes": {
"docs": { "name": "11. Docs and videos, two-step upload", "data": { "Protocol": { "type": "Text Input", "value": "prepare (hash) -> skip, or presigned PUT -> complete. Videos are turned into docs by pkg/config/videos.go" } } },
"deps": { "name": "8. Dependencies and cost tags", "data": { "Note": { "type": "Text Input", "value": "costTags is declarative: listing it deletes any rule not listed" } } }
}
}
31 changes: 31 additions & 0 deletions .uigraph/diagrams/sync-pipeline/sync-pipeline.mmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
flowchart TB
token[1. Read UIGRAPH_TOKEN and gateway URL]
config[2. Load and validate .uigraph.yaml]
git[3. Capture git metadata]
service[5. Service]
no_service[Maps and frames only]
databases[6. Database schemas and saved queries]
apis[7. API groups from spec files]
deps[8. Dependencies and cost tags]
diagrams[9. Architecture diagrams]
tests[10. Test packs, cases, screenshots]
docs[11. Docs and videos, two-step upload]
timeline[11b. Timeline from repo files]
maps[12. Maps, frames, focal points, publish]
ml[13. MLflow projects]
summary[14. Summary]
token --> config
config --> git
git -->|service block present| service
git -->|no service block| no_service
service --> databases
databases --> apis
apis --> deps
deps --> diagrams
diagrams --> tests
tests --> docs
docs --> timeline
timeline --> maps
no_service --> maps
maps --> ml
ml --> summary
6 changes: 6 additions & 0 deletions .uigraph/diagrams/system-context/context.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"nodes": {
"cli": { "name": "uigraph-cli", "data": { "Commands": { "type": "Text Input", "value": "sync, release" }, "Code": { "type": "Text Input", "value": "cmd/sync.go, cmd/release.go, pkg/gateway/client.go" } } },
"gateway": { "name": "uigraph-gateway", "data": { "Targets": { "type": "Text Input", "value": "--enterprise (console.uigraph.app/gateway), --enterprise=DEV, --api-url or UIGRAPH_GATEWAY_URL" } } }
}
}
15 changes: 15 additions & 0 deletions .uigraph/diagrams/system-context/system-context.mmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
flowchart LR
repo[Repository with .uigraph.yaml]
ci[CI job or developer]
cli[uigraph-cli]
mlflow[MLflow]
gateway[uigraph-gateway]
storage[(Object Storage)]
api[uigraph-api]
ci -->|UIGRAPH_TOKEN| cli
repo -->|config and files| cli
cli -->|ml section| mlflow
cli -->|/v1/sync X-API-Token| gateway
cli -->|PUT presigned| storage
gateway --> api
gateway --> storage
43 changes: 43 additions & 0 deletions .uigraph/docs/overview.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# How uigraph-cli works

uigraph-cli is how repositories get into UIGraph. A repository describes itself in
`.uigraph.yaml` and files under `.uigraph/`. CI runs `uigraph-cli sync`, which pushes
everything through uigraph-gateway into uigraph-api.

## Commands

- `uigraph-cli sync [--config .uigraph.yaml] [--dry-run] [--verbose]` upserts the whole
config. `--dry-run` prints the payloads without sending them.
- `uigraph-cli release [--version] [--notes | --notes-file]` records one release on the
service timeline. It reads the tag at `HEAD`, so it needs full history. Notes come from
`--notes`, then `--notes-file`, then the annotated tag body, then the matching changelog
section, then up to 50 commit subjects since the previous tag.

## Target and credentials

`UIGRAPH_TOKEN` is a service account token (`uig_…`), sent as `X-API-Token`. The gateway is
chosen by exactly one of:

| Flag | Gateway |
|---|---|
| `--enterprise` | `https://console.uigraph.app/gateway` (UIGraph Cloud) |
| `--api-url` or `UIGRAPH_GATEWAY_URL` | A self-hosted gateway |

## Order of a sync

Service, then databases and saved queries, API groups, dependencies and cost tags,
diagrams, test packs, docs and videos, timeline, maps, and MLflow projects. Every call is an
idempotent upsert keyed by name, so a sync can be rerun safely. Without a `service` block
only maps and frames sync.

Files (docs, frames, test screenshots) use prepare and complete. The gateway answers `skip`
when the hash matches, or hands back a presigned URL the CLI uploads to directly. Videos
are listed under `videos:` and are turned into docs before they sync.

## Where it runs

- In CI from the `uigraph/uigraph-cli` Docker image, which `release.yml` publishes to
Docker Hub.
- In repositories onboarded through the UIGraph GitHub App: the workflows that uigraph-api
commits run `go install github.com/uigraph-oss/uigraph-cli@main` and then sync.
- Locally with `go install`.
5 changes: 4 additions & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
- DO not run `go build`; use `make build` instead.
- DO not run `go build`; use `make build` instead.
## UIGraph

If your change adds or changes API endpoints, database schemas, calls to other services, or a flow shown in a diagram, read `.uigraph/AGENTS.md` and follow it.
Loading