diff --git a/.github/workflows/diagram.yml b/.github/workflows/diagram.yml new file mode 100644 index 00000000..9871979a --- /dev/null +++ b/.github/workflows/diagram.yml @@ -0,0 +1,27 @@ +name: Render Mermaid Diagrams +on: + push: + paths: + - 'docs/*.mmd' # Trigger only when mermaid files change + +jobs: + render: + runs-on: ubuntu-latest + # Grant the action permission to write to the repository + permissions: + contents: write + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install Mermaid CLI + run: npm install -g @mermaid-js/mermaid-cli + + - name: Render Diagram + run: mmdc -p docs/puppeteer-config.json -i docs/architecture.mmd -o docs/images/architecture.svg -t neutral + + - name: Commit and Push + uses: stefanzweifel/git-auto-commit-action@v7 + with: + commit_message: "docs: update rendered mermaid diagram [skip ci]" + file_pattern: 'docs/images/*.svg' diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index fb022d87..b5638516 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -19,6 +19,7 @@ repos: - id: mixed-line-ending - id: check-yaml - id: pretty-format-json + args: [--autofix] - id: detect-private-key - id: debug-statements diff --git a/docs/architecture.mmd b/docs/architecture.mmd new file mode 100644 index 00000000..50c9d61a --- /dev/null +++ b/docs/architecture.mmd @@ -0,0 +1,19 @@ +sequenceDiagram + autonumber + participant Pytest as Pytest runner + participant ProcFactory as postgresql_proc_factory + participant PgServer as PostgreSQL process + participant TemplateDB as Template DB (seeded) + participant TestDB as Per-test DB (clone) + + Pytest->>ProcFactory: request postgresql_proc with load=[load_database] + ProcFactory->>PgServer: start server + ProcFactory->>TemplateDB: invoke load_database (create metadata, seed data) + Note right of TemplateDB: Template is created and seeded once per full run + loop per test + Pytest->>PgServer: request clone of TemplateDB + PgServer->>TestDB: create cloned database for test + Pytest->>TestDB: run test using cloned DB + Pytest->>TestDB: teardown: commit transaction + Pytest->>TestDB: teardown: drop_all metadata (cleanup) + end diff --git a/docs/images/.keep b/docs/images/.keep new file mode 100644 index 00000000..e69de29b diff --git a/docs/images/architecture.svg b/docs/images/architecture.svg new file mode 100644 index 00000000..31c3732b --- /dev/null +++ b/docs/images/architecture.svg @@ -0,0 +1 @@ +Per-test DB (clone)Template DB (seeded)PostgreSQL processpostgresql_proc_factoryPytest runnerPer-test DB (clone)Template DB (seeded)PostgreSQL processpostgresql_proc_factoryPytest runnerTemplate is created and seeded once per full runloop[per test]request postgresql_proc with load=[load_database]1start server2invoke load_database (create metadata, seed data)3request clone of TemplateDB4create cloned database for test5run test using cloned DB6teardown: commit transaction7teardown: drop_all metadata (cleanup)8 diff --git a/docs/puppeteer-config.json b/docs/puppeteer-config.json new file mode 100644 index 00000000..625abff7 --- /dev/null +++ b/docs/puppeteer-config.json @@ -0,0 +1,6 @@ +{ + "args": [ + "--no-sandbox", + "--disable-setuid-sandbox" + ] +} diff --git a/newsfragments/1244.docs.rst b/newsfragments/1244.docs.rst new file mode 100644 index 00000000..38554dfb --- /dev/null +++ b/newsfragments/1244.docs.rst @@ -0,0 +1 @@ +Add plugins' architecture diagram.