schemabrain 0.1.0a1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- schemabrain-0.1.0a1/.env.example +18 -0
- schemabrain-0.1.0a1/.github/CODEOWNERS +12 -0
- schemabrain-0.1.0a1/.github/ISSUE_TEMPLATE/bug_report.yml +91 -0
- schemabrain-0.1.0a1/.github/ISSUE_TEMPLATE/config.yml +7 -0
- schemabrain-0.1.0a1/.github/ISSUE_TEMPLATE/feature_request.yml +65 -0
- schemabrain-0.1.0a1/.github/PULL_REQUEST_TEMPLATE.md +43 -0
- schemabrain-0.1.0a1/.github/workflows/ci.yml +107 -0
- schemabrain-0.1.0a1/.github/workflows/publish.yml +94 -0
- schemabrain-0.1.0a1/.gitignore +89 -0
- schemabrain-0.1.0a1/.python-version +1 -0
- schemabrain-0.1.0a1/CONTRIBUTING.md +173 -0
- schemabrain-0.1.0a1/LICENSE +21 -0
- schemabrain-0.1.0a1/PKG-INFO +217 -0
- schemabrain-0.1.0a1/README.md +185 -0
- schemabrain-0.1.0a1/docs/architecture.md +202 -0
- schemabrain-0.1.0a1/docs/mcp-tools.md +88 -0
- schemabrain-0.1.0a1/docs/setup.md +215 -0
- schemabrain-0.1.0a1/examples/anthropic_demo.py +232 -0
- schemabrain-0.1.0a1/examples/claude_desktop_config.example.json +14 -0
- schemabrain-0.1.0a1/pyproject.toml +111 -0
- schemabrain-0.1.0a1/schemabrain/__init__.py +3 -0
- schemabrain-0.1.0a1/schemabrain/cli.py +401 -0
- schemabrain-0.1.0a1/schemabrain/connectors/__init__.py +0 -0
- schemabrain-0.1.0a1/schemabrain/connectors/base.py +38 -0
- schemabrain-0.1.0a1/schemabrain/connectors/errors.py +9 -0
- schemabrain-0.1.0a1/schemabrain/connectors/postgres.py +154 -0
- schemabrain-0.1.0a1/schemabrain/core/__init__.py +0 -0
- schemabrain-0.1.0a1/schemabrain/core/description.py +29 -0
- schemabrain-0.1.0a1/schemabrain/core/embedding.py +40 -0
- schemabrain-0.1.0a1/schemabrain/core/fingerprint.py +166 -0
- schemabrain-0.1.0a1/schemabrain/core/models.py +208 -0
- schemabrain-0.1.0a1/schemabrain/core/store.py +670 -0
- schemabrain-0.1.0a1/schemabrain/enrichment/__init__.py +16 -0
- schemabrain-0.1.0a1/schemabrain/enrichment/anthropic_client.py +175 -0
- schemabrain-0.1.0a1/schemabrain/enrichment/embeddings.py +173 -0
- schemabrain-0.1.0a1/schemabrain/enrichment/llm.py +187 -0
- schemabrain-0.1.0a1/schemabrain/enrichment/pipeline.py +145 -0
- schemabrain-0.1.0a1/schemabrain/enrichment/prompts.py +107 -0
- schemabrain-0.1.0a1/schemabrain/enrichment/routing.py +59 -0
- schemabrain-0.1.0a1/schemabrain/eval/__init__.py +42 -0
- schemabrain-0.1.0a1/schemabrain/eval/fixtures/ecommerce.sql +78 -0
- schemabrain-0.1.0a1/schemabrain/eval/golden.py +104 -0
- schemabrain-0.1.0a1/schemabrain/eval/golden_sets/ecommerce.json +56 -0
- schemabrain-0.1.0a1/schemabrain/eval/retriever.py +257 -0
- schemabrain-0.1.0a1/schemabrain/eval/runner.py +117 -0
- schemabrain-0.1.0a1/schemabrain/indexer.py +273 -0
- schemabrain-0.1.0a1/schemabrain/mcp/__init__.py +69 -0
- schemabrain-0.1.0a1/schemabrain/mcp/server.py +157 -0
- schemabrain-0.1.0a1/schemabrain/mcp/tools.py +805 -0
- schemabrain-0.1.0a1/schemabrain/profiler/__init__.py +16 -0
- schemabrain-0.1.0a1/schemabrain/profiler/base.py +22 -0
- schemabrain-0.1.0a1/schemabrain/profiler/postgres.py +187 -0
- schemabrain-0.1.0a1/schemabrain/profiler/stats.py +136 -0
- schemabrain-0.1.0a1/tests/__init__.py +0 -0
- schemabrain-0.1.0a1/tests/conftest.py +197 -0
- schemabrain-0.1.0a1/tests/test_cli.py +1245 -0
- schemabrain-0.1.0a1/tests/test_connectors_base.py +34 -0
- schemabrain-0.1.0a1/tests/test_connectors_postgres.py +158 -0
- schemabrain-0.1.0a1/tests/test_core_embedding.py +42 -0
- schemabrain-0.1.0a1/tests/test_core_fingerprint.py +613 -0
- schemabrain-0.1.0a1/tests/test_core_store.py +1199 -0
- schemabrain-0.1.0a1/tests/test_enrichment_anthropic.py +322 -0
- schemabrain-0.1.0a1/tests/test_enrichment_embeddings.py +223 -0
- schemabrain-0.1.0a1/tests/test_enrichment_llm.py +253 -0
- schemabrain-0.1.0a1/tests/test_enrichment_pipeline.py +379 -0
- schemabrain-0.1.0a1/tests/test_enrichment_prompts.py +449 -0
- schemabrain-0.1.0a1/tests/test_enrichment_routing.py +136 -0
- schemabrain-0.1.0a1/tests/test_eval_golden.py +174 -0
- schemabrain-0.1.0a1/tests/test_eval_retriever.py +513 -0
- schemabrain-0.1.0a1/tests/test_eval_runner.py +272 -0
- schemabrain-0.1.0a1/tests/test_examples.py +137 -0
- schemabrain-0.1.0a1/tests/test_indexer.py +934 -0
- schemabrain-0.1.0a1/tests/test_mcp_server.py +298 -0
- schemabrain-0.1.0a1/tests/test_mcp_tools.py +1364 -0
- schemabrain-0.1.0a1/tests/test_models.py +500 -0
- schemabrain-0.1.0a1/tests/test_profiler_base.py +30 -0
- schemabrain-0.1.0a1/tests/test_profiler_postgres.py +281 -0
- schemabrain-0.1.0a1/tests/test_profiler_stats.py +258 -0
- schemabrain-0.1.0a1/uv.lock +2141 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Postgres connection string for the database to index
|
|
2
|
+
# Example: postgresql://user:password@localhost:5432/mydb
|
|
3
|
+
SCHEMABRAIN_DATABASE_URL=
|
|
4
|
+
|
|
5
|
+
# Anthropic API key for LLM-powered semantic enrichment
|
|
6
|
+
# Get one at https://console.anthropic.com/
|
|
7
|
+
ANTHROPIC_API_KEY=
|
|
8
|
+
|
|
9
|
+
# Path to the local Schema Brain SQLite store
|
|
10
|
+
# Defaults to ./schemabrain.db if unset
|
|
11
|
+
SCHEMABRAIN_STORE_PATH=./schemabrain.db
|
|
12
|
+
|
|
13
|
+
# Hard cap on LLM spend per `index` run, in USD.
|
|
14
|
+
# The run aborts if estimated cost exceeds this. Default 10.
|
|
15
|
+
SCHEMABRAIN_MAX_COST_USD=10
|
|
16
|
+
|
|
17
|
+
# Logging level: DEBUG, INFO, WARNING, ERROR
|
|
18
|
+
SCHEMABRAIN_LOG_LEVEL=INFO
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# Schema Brain code owners.
|
|
2
|
+
#
|
|
3
|
+
# GitHub uses this file to auto-request review from the listed owners on
|
|
4
|
+
# every PR that touches matching paths. Keep the list small and current —
|
|
5
|
+
# stale owners create noise; missing owners create silent gaps.
|
|
6
|
+
#
|
|
7
|
+
# Today the project is single-maintainer (pre-alpha). When new maintainers
|
|
8
|
+
# join, add them here per-area rather than as a global owner so review
|
|
9
|
+
# load can be shared rather than bottlenecked.
|
|
10
|
+
|
|
11
|
+
# Catch-all: every PR auto-requests Arun until subject-matter owners exist.
|
|
12
|
+
* @Arun-kc
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
name: Bug report
|
|
2
|
+
description: Something is broken or behaves unexpectedly.
|
|
3
|
+
title: "[bug] "
|
|
4
|
+
labels: ["bug", "triage"]
|
|
5
|
+
body:
|
|
6
|
+
- type: markdown
|
|
7
|
+
attributes:
|
|
8
|
+
value: |
|
|
9
|
+
Thanks for taking the time to file a bug report. The fields below
|
|
10
|
+
are required so we can reproduce and triage. Please don't strip
|
|
11
|
+
them — incomplete reports get closed with a request to re-open.
|
|
12
|
+
|
|
13
|
+
- type: textarea
|
|
14
|
+
id: what-happened
|
|
15
|
+
attributes:
|
|
16
|
+
label: What happened?
|
|
17
|
+
description: A clear description of what you saw vs what you expected.
|
|
18
|
+
placeholder: |
|
|
19
|
+
Ran `schemabrain index $POSTGRES_URL` and got X. Expected Y.
|
|
20
|
+
validations:
|
|
21
|
+
required: true
|
|
22
|
+
|
|
23
|
+
- type: textarea
|
|
24
|
+
id: reproduction
|
|
25
|
+
attributes:
|
|
26
|
+
label: Minimal reproduction
|
|
27
|
+
description: |
|
|
28
|
+
Exact commands and inputs we can run to see the bug ourselves.
|
|
29
|
+
For schema-related bugs, the output of `pg_dump --schema-only`
|
|
30
|
+
for the affected tables is usually enough. Strip secrets first.
|
|
31
|
+
render: shell
|
|
32
|
+
validations:
|
|
33
|
+
required: true
|
|
34
|
+
|
|
35
|
+
- type: textarea
|
|
36
|
+
id: traceback
|
|
37
|
+
attributes:
|
|
38
|
+
label: Full traceback (if applicable)
|
|
39
|
+
description: Paste the full error output, not just the last line.
|
|
40
|
+
render: shell
|
|
41
|
+
validations:
|
|
42
|
+
required: false
|
|
43
|
+
|
|
44
|
+
- type: input
|
|
45
|
+
id: schemabrain-version
|
|
46
|
+
attributes:
|
|
47
|
+
label: Schema Brain version
|
|
48
|
+
description: Output of `pip show schemabrain | grep -i version` or the commit SHA.
|
|
49
|
+
placeholder: "0.0.0 / commit ee9e357"
|
|
50
|
+
validations:
|
|
51
|
+
required: true
|
|
52
|
+
|
|
53
|
+
- type: input
|
|
54
|
+
id: python-version
|
|
55
|
+
attributes:
|
|
56
|
+
label: Python version
|
|
57
|
+
description: Output of `python --version`.
|
|
58
|
+
placeholder: "3.11.15"
|
|
59
|
+
validations:
|
|
60
|
+
required: true
|
|
61
|
+
|
|
62
|
+
- type: dropdown
|
|
63
|
+
id: os
|
|
64
|
+
attributes:
|
|
65
|
+
label: Operating system
|
|
66
|
+
options:
|
|
67
|
+
- Linux x86_64
|
|
68
|
+
- Linux aarch64
|
|
69
|
+
- macOS arm64 (Apple Silicon)
|
|
70
|
+
- macOS x86_64 (Intel)
|
|
71
|
+
- Windows
|
|
72
|
+
- Other (specify in "What happened?")
|
|
73
|
+
validations:
|
|
74
|
+
required: true
|
|
75
|
+
|
|
76
|
+
- type: input
|
|
77
|
+
id: database
|
|
78
|
+
attributes:
|
|
79
|
+
label: Database engine and version
|
|
80
|
+
description: e.g. `Postgres 16.2`, `SQLite 3.45.0`. Output of `SELECT version();` is fine.
|
|
81
|
+
placeholder: "Postgres 16.2"
|
|
82
|
+
validations:
|
|
83
|
+
required: true
|
|
84
|
+
|
|
85
|
+
- type: textarea
|
|
86
|
+
id: extra
|
|
87
|
+
attributes:
|
|
88
|
+
label: Anything else?
|
|
89
|
+
description: Workarounds you tried, related issues, anything that helps triage.
|
|
90
|
+
validations:
|
|
91
|
+
required: false
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# Disable blank issues — every issue must use a structured template so
|
|
2
|
+
# triage gets the info it needs without a back-and-forth round trip.
|
|
3
|
+
blank_issues_enabled: false
|
|
4
|
+
|
|
5
|
+
# No external contact links yet (no Discord, no community forum). Add
|
|
6
|
+
# them here once they exist; until then, the issue templates are the
|
|
7
|
+
# only entry points.
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
name: Feature request
|
|
2
|
+
description: Suggest something Schema Brain should do that it doesn't.
|
|
3
|
+
title: "[feat] "
|
|
4
|
+
labels: ["enhancement", "triage"]
|
|
5
|
+
body:
|
|
6
|
+
- type: markdown
|
|
7
|
+
attributes:
|
|
8
|
+
value: |
|
|
9
|
+
Schema Brain has a deliberately small surface — most "missing"
|
|
10
|
+
features are deferred on purpose, not forgotten. Please describe
|
|
11
|
+
the underlying problem first; the maintainer will propose the
|
|
12
|
+
smallest fix rather than implementing the requested change verbatim.
|
|
13
|
+
|
|
14
|
+
- type: textarea
|
|
15
|
+
id: problem
|
|
16
|
+
attributes:
|
|
17
|
+
label: What problem are you trying to solve?
|
|
18
|
+
description: |
|
|
19
|
+
Describe the situation, not the solution. "I can't write SQL
|
|
20
|
+
against my warehouse without knowing which tables to JOIN" is
|
|
21
|
+
better than "Add a `suggest_joins` MCP tool" — the second
|
|
22
|
+
forecloses on alternative fixes.
|
|
23
|
+
validations:
|
|
24
|
+
required: true
|
|
25
|
+
|
|
26
|
+
- type: textarea
|
|
27
|
+
id: workaround
|
|
28
|
+
attributes:
|
|
29
|
+
label: Current workaround (if any)
|
|
30
|
+
description: How are you working around the limitation today?
|
|
31
|
+
validations:
|
|
32
|
+
required: false
|
|
33
|
+
|
|
34
|
+
- type: textarea
|
|
35
|
+
id: proposal
|
|
36
|
+
attributes:
|
|
37
|
+
label: Proposed change
|
|
38
|
+
description: |
|
|
39
|
+
Optional. If you have a specific design in mind, describe it.
|
|
40
|
+
Treat this as a starting point for discussion, not a spec.
|
|
41
|
+
validations:
|
|
42
|
+
required: false
|
|
43
|
+
|
|
44
|
+
- type: dropdown
|
|
45
|
+
id: who-uses-it
|
|
46
|
+
attributes:
|
|
47
|
+
label: Who would use this?
|
|
48
|
+
options:
|
|
49
|
+
- Just me
|
|
50
|
+
- My team / organization
|
|
51
|
+
- I think it's broadly useful
|
|
52
|
+
- Not sure
|
|
53
|
+
validations:
|
|
54
|
+
required: true
|
|
55
|
+
|
|
56
|
+
- type: checkboxes
|
|
57
|
+
id: scope
|
|
58
|
+
attributes:
|
|
59
|
+
label: Scope check
|
|
60
|
+
description: "Schema Brain v0 stays small on purpose. Please confirm:"
|
|
61
|
+
options:
|
|
62
|
+
- label: I've checked the README's "Roadmap" section to see if this is already planned.
|
|
63
|
+
required: true
|
|
64
|
+
- label: I've checked open and closed issues for similar requests.
|
|
65
|
+
required: true
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
Thanks for sending a PR. Please fill in the sections below — the bullets
|
|
3
|
+
are optional removable scaffolding, not required boilerplate. The goal
|
|
4
|
+
is a description that makes review fast and a permanent record that
|
|
5
|
+
makes the commit history readable a year from now.
|
|
6
|
+
-->
|
|
7
|
+
|
|
8
|
+
## Summary
|
|
9
|
+
|
|
10
|
+
<!-- One or two sentences: what does this change do, and why now? -->
|
|
11
|
+
|
|
12
|
+
## Context
|
|
13
|
+
|
|
14
|
+
<!--
|
|
15
|
+
What problem does this solve? What was the old behavior?
|
|
16
|
+
Link related issues with `Closes #N` or `Refs #N`.
|
|
17
|
+
-->
|
|
18
|
+
|
|
19
|
+
## Changes
|
|
20
|
+
|
|
21
|
+
<!--
|
|
22
|
+
Bullet list of the meaningful changes (not every file touched). For
|
|
23
|
+
larger PRs, group by area (`mcp/`, `core/`, `eval/`, etc).
|
|
24
|
+
-->
|
|
25
|
+
|
|
26
|
+
-
|
|
27
|
+
|
|
28
|
+
## Test plan
|
|
29
|
+
|
|
30
|
+
<!--
|
|
31
|
+
- [ ] Unit tests added/updated and passing
|
|
32
|
+
- [ ] Integration tests added/updated and passing (if behavior changed)
|
|
33
|
+
- [ ] Coverage holds (`uv run pytest --cov=schemabrain --cov-branch`)
|
|
34
|
+
- [ ] Lint and format clean (`uv run ruff check && uv run ruff format --check`)
|
|
35
|
+
- [ ] Manual verification (commands run, screenshots, etc) if applicable
|
|
36
|
+
-->
|
|
37
|
+
|
|
38
|
+
## Tradeoffs / open questions
|
|
39
|
+
|
|
40
|
+
<!--
|
|
41
|
+
What did you consider and reject? What's deferred? What should the
|
|
42
|
+
reviewer push back on if they disagree?
|
|
43
|
+
-->
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
# GitHub Actions CI for Schema Brain.
|
|
2
|
+
#
|
|
3
|
+
# Two jobs run on every push to `main` and every pull request:
|
|
4
|
+
# - lint-and-unit: ruff + pytest unit tests across Python 3.11 + 3.12.
|
|
5
|
+
# Fast (target: under 60s warm cache); blocks merge.
|
|
6
|
+
# - integration: pytest integration tests (Docker / testcontainers
|
|
7
|
+
# Postgres). Single Python (3.11) since the integration
|
|
8
|
+
# surface is dialect-driven, not interpreter-driven.
|
|
9
|
+
# Slower (~2-3 min, dominated by container boot); also
|
|
10
|
+
# blocks merge so we don't ship regressions in the
|
|
11
|
+
# Postgres connector or profiler.
|
|
12
|
+
#
|
|
13
|
+
# Both jobs use `uv` for env management — same tool the dev workflow uses,
|
|
14
|
+
# so CI failures reproduce locally with `uv sync --extra dev && uv run pytest`.
|
|
15
|
+
#
|
|
16
|
+
# OS matrix: ubuntu-latest only at v0. macOS is documented as supported
|
|
17
|
+
# for local dev on Python 3.11, but `onnxruntime` (a fastembed transitive
|
|
18
|
+
# dep) has no wheel for macOS arm64 + Python 3.12 today, so adding macOS
|
|
19
|
+
# to CI would either drop a Python version or fail the macOS+3.12 cell.
|
|
20
|
+
# Revisit when onnxruntime ships the missing wheel.
|
|
21
|
+
|
|
22
|
+
name: CI
|
|
23
|
+
|
|
24
|
+
on:
|
|
25
|
+
push:
|
|
26
|
+
branches: [main]
|
|
27
|
+
pull_request:
|
|
28
|
+
branches: [main]
|
|
29
|
+
|
|
30
|
+
# Cancel in-flight runs for the same PR / branch when a new push lands —
|
|
31
|
+
# saves CI minutes on rapid iteration without losing any signal.
|
|
32
|
+
concurrency:
|
|
33
|
+
group: ${{ github.workflow }}-${{ github.ref }}
|
|
34
|
+
cancel-in-progress: true
|
|
35
|
+
|
|
36
|
+
jobs:
|
|
37
|
+
lint-and-unit:
|
|
38
|
+
name: Lint + unit (Python ${{ matrix.python-version }})
|
|
39
|
+
runs-on: ubuntu-latest
|
|
40
|
+
strategy:
|
|
41
|
+
fail-fast: false
|
|
42
|
+
matrix:
|
|
43
|
+
python-version: ["3.11", "3.12"]
|
|
44
|
+
steps:
|
|
45
|
+
- uses: actions/checkout@v4
|
|
46
|
+
|
|
47
|
+
- name: Install uv
|
|
48
|
+
uses: astral-sh/setup-uv@v3
|
|
49
|
+
with:
|
|
50
|
+
enable-cache: true
|
|
51
|
+
cache-dependency-glob: "uv.lock"
|
|
52
|
+
|
|
53
|
+
- name: Set up Python ${{ matrix.python-version }}
|
|
54
|
+
run: uv python install ${{ matrix.python-version }}
|
|
55
|
+
|
|
56
|
+
- name: Install dependencies
|
|
57
|
+
run: uv sync --extra dev --python ${{ matrix.python-version }}
|
|
58
|
+
|
|
59
|
+
- name: Lint (ruff check)
|
|
60
|
+
run: uv run --python ${{ matrix.python-version }} ruff check schemabrain tests
|
|
61
|
+
|
|
62
|
+
- name: Format check (ruff format --check)
|
|
63
|
+
run: uv run --python ${{ matrix.python-version }} ruff format --check schemabrain tests
|
|
64
|
+
|
|
65
|
+
- name: Unit tests
|
|
66
|
+
# No coverage gate here — unit-only runs miss code paths
|
|
67
|
+
# exercised by integration tests (Postgres connector, profiler).
|
|
68
|
+
# The 99% line+branch gate runs in the `integration` job, which
|
|
69
|
+
# sees the full suite. This job is the fast PR-feedback signal.
|
|
70
|
+
run: uv run --python ${{ matrix.python-version }} pytest -m "not integration"
|
|
71
|
+
|
|
72
|
+
integration:
|
|
73
|
+
name: Integration (Docker / Postgres)
|
|
74
|
+
runs-on: ubuntu-latest
|
|
75
|
+
# Run after lint-and-unit so a syntax error doesn't waste 3 min on
|
|
76
|
+
# container boot. Either lint-and-unit cell green is enough — we don't
|
|
77
|
+
# need both Python versions to pass before integration starts.
|
|
78
|
+
needs: lint-and-unit
|
|
79
|
+
steps:
|
|
80
|
+
- uses: actions/checkout@v4
|
|
81
|
+
|
|
82
|
+
- name: Install uv
|
|
83
|
+
uses: astral-sh/setup-uv@v3
|
|
84
|
+
with:
|
|
85
|
+
enable-cache: true
|
|
86
|
+
cache-dependency-glob: "uv.lock"
|
|
87
|
+
|
|
88
|
+
- name: Set up Python 3.11
|
|
89
|
+
run: uv python install 3.11
|
|
90
|
+
|
|
91
|
+
- name: Install dependencies
|
|
92
|
+
run: uv sync --extra dev --python 3.11
|
|
93
|
+
|
|
94
|
+
- name: Pre-pull Postgres image (warm testcontainers cache)
|
|
95
|
+
run: docker pull postgres:16-alpine
|
|
96
|
+
|
|
97
|
+
- name: Full suite with coverage gate
|
|
98
|
+
# Runs BOTH unit and integration tests together so the coverage
|
|
99
|
+
# report sees every path. The 99% gate is a one-percentage-point
|
|
100
|
+
# buffer below the project's 100% line+branch target — flags
|
|
101
|
+
# genuine regressions without thrashing on minor edge cases.
|
|
102
|
+
run: |
|
|
103
|
+
uv run --python 3.11 pytest \
|
|
104
|
+
--cov=schemabrain \
|
|
105
|
+
--cov-branch \
|
|
106
|
+
--cov-report=term-missing \
|
|
107
|
+
--cov-fail-under=99
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
# Publishes Schema Brain to TestPyPI or PyPI via Trusted Publishers (OIDC).
|
|
2
|
+
#
|
|
3
|
+
# No long-lived API tokens. PyPI/TestPyPI verify the workflow's OIDC token
|
|
4
|
+
# against a pending-or-existing Trusted Publisher configured on each index.
|
|
5
|
+
#
|
|
6
|
+
# Manual-dispatch only for v0.1.0a1: every publish requires going to the
|
|
7
|
+
# GitHub Actions UI and explicitly picking `testpypi` or `pypi`. No tag
|
|
8
|
+
# push auto-triggers a release. Trade-off: more clicks per release. Why:
|
|
9
|
+
#
|
|
10
|
+
# 1. Free-plan private repos cannot set Required-Reviewer protection on
|
|
11
|
+
# GitHub Environments, so a tag-triggered chain has no human gate
|
|
12
|
+
# between TestPyPI and PyPI.
|
|
13
|
+
# 2. First publishes are the highest-risk moment — once a version like
|
|
14
|
+
# `0.1.0a1` is on PyPI it is immutable forever. Manual dispatch makes
|
|
15
|
+
# every publish an intentional act.
|
|
16
|
+
#
|
|
17
|
+
# Once the package is established and the pipeline is proven, this can
|
|
18
|
+
# convert to a tag-triggered or release-triggered design.
|
|
19
|
+
|
|
20
|
+
name: Publish
|
|
21
|
+
|
|
22
|
+
on:
|
|
23
|
+
workflow_dispatch:
|
|
24
|
+
inputs:
|
|
25
|
+
target:
|
|
26
|
+
description: "Where to publish"
|
|
27
|
+
required: true
|
|
28
|
+
type: choice
|
|
29
|
+
options:
|
|
30
|
+
- testpypi
|
|
31
|
+
- pypi
|
|
32
|
+
default: testpypi
|
|
33
|
+
|
|
34
|
+
permissions:
|
|
35
|
+
contents: read
|
|
36
|
+
|
|
37
|
+
jobs:
|
|
38
|
+
build:
|
|
39
|
+
name: Build sdist + wheel
|
|
40
|
+
runs-on: ubuntu-latest
|
|
41
|
+
steps:
|
|
42
|
+
- uses: actions/checkout@v4
|
|
43
|
+
|
|
44
|
+
- name: Install uv
|
|
45
|
+
uses: astral-sh/setup-uv@v3
|
|
46
|
+
with:
|
|
47
|
+
enable-cache: true
|
|
48
|
+
cache-dependency-glob: "uv.lock"
|
|
49
|
+
|
|
50
|
+
- name: Set up Python 3.11
|
|
51
|
+
run: uv python install 3.11
|
|
52
|
+
|
|
53
|
+
- name: Build distributions
|
|
54
|
+
run: uv build
|
|
55
|
+
|
|
56
|
+
- name: Show built artifacts
|
|
57
|
+
run: ls -la dist/
|
|
58
|
+
|
|
59
|
+
- name: Upload artifacts
|
|
60
|
+
uses: actions/upload-artifact@v4
|
|
61
|
+
with:
|
|
62
|
+
name: dist
|
|
63
|
+
path: dist/
|
|
64
|
+
if-no-files-found: error
|
|
65
|
+
|
|
66
|
+
publish:
|
|
67
|
+
name: Publish to ${{ inputs.target }}
|
|
68
|
+
needs: build
|
|
69
|
+
runs-on: ubuntu-latest
|
|
70
|
+
environment:
|
|
71
|
+
# Environment binding is what scopes the OIDC token claim that
|
|
72
|
+
# PyPI/TestPyPI verify against their Trusted Publisher config.
|
|
73
|
+
# The environment names must match what was registered on each
|
|
74
|
+
# index: `testpypi` on test.pypi.org, `pypi` on pypi.org.
|
|
75
|
+
name: ${{ inputs.target }}
|
|
76
|
+
url: ${{ inputs.target == 'pypi' && 'https://pypi.org/p/schemabrain' || 'https://test.pypi.org/p/schemabrain' }}
|
|
77
|
+
permissions:
|
|
78
|
+
id-token: write
|
|
79
|
+
steps:
|
|
80
|
+
- name: Download artifacts
|
|
81
|
+
uses: actions/download-artifact@v4
|
|
82
|
+
with:
|
|
83
|
+
name: dist
|
|
84
|
+
path: dist/
|
|
85
|
+
|
|
86
|
+
- name: Publish to TestPyPI
|
|
87
|
+
if: inputs.target == 'testpypi'
|
|
88
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
89
|
+
with:
|
|
90
|
+
repository-url: https://test.pypi.org/legacy/
|
|
91
|
+
|
|
92
|
+
- name: Publish to PyPI
|
|
93
|
+
if: inputs.target == 'pypi'
|
|
94
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
*.so
|
|
6
|
+
|
|
7
|
+
# Distribution / packaging
|
|
8
|
+
.Python
|
|
9
|
+
build/
|
|
10
|
+
develop-eggs/
|
|
11
|
+
dist/
|
|
12
|
+
downloads/
|
|
13
|
+
eggs/
|
|
14
|
+
.eggs/
|
|
15
|
+
lib/
|
|
16
|
+
lib64/
|
|
17
|
+
parts/
|
|
18
|
+
sdist/
|
|
19
|
+
var/
|
|
20
|
+
wheels/
|
|
21
|
+
share/python-wheels/
|
|
22
|
+
*.egg-info/
|
|
23
|
+
.installed.cfg
|
|
24
|
+
*.egg
|
|
25
|
+
MANIFEST
|
|
26
|
+
|
|
27
|
+
# Installer logs
|
|
28
|
+
pip-log.txt
|
|
29
|
+
pip-delete-this-directory.txt
|
|
30
|
+
|
|
31
|
+
# Unit test / coverage
|
|
32
|
+
htmlcov/
|
|
33
|
+
.tox/
|
|
34
|
+
.nox/
|
|
35
|
+
.coverage
|
|
36
|
+
.coverage.*
|
|
37
|
+
.cache
|
|
38
|
+
nosetests.xml
|
|
39
|
+
coverage.xml
|
|
40
|
+
*.cover
|
|
41
|
+
*.py,cover
|
|
42
|
+
.hypothesis/
|
|
43
|
+
.pytest_cache/
|
|
44
|
+
cover/
|
|
45
|
+
|
|
46
|
+
# Environments
|
|
47
|
+
.env
|
|
48
|
+
.env.*
|
|
49
|
+
!.env.example
|
|
50
|
+
.venv
|
|
51
|
+
env/
|
|
52
|
+
venv/
|
|
53
|
+
ENV/
|
|
54
|
+
env.bak/
|
|
55
|
+
venv.bak/
|
|
56
|
+
|
|
57
|
+
# Editors / IDEs
|
|
58
|
+
.idea/
|
|
59
|
+
.vscode/
|
|
60
|
+
*.swp
|
|
61
|
+
*.swo
|
|
62
|
+
*~
|
|
63
|
+
.DS_Store
|
|
64
|
+
|
|
65
|
+
# Type checking
|
|
66
|
+
.mypy_cache/
|
|
67
|
+
.dmypy.json
|
|
68
|
+
dmypy.json
|
|
69
|
+
.pyre/
|
|
70
|
+
.pytype/
|
|
71
|
+
|
|
72
|
+
# Ruff
|
|
73
|
+
.ruff_cache/
|
|
74
|
+
|
|
75
|
+
# Schema Brain local artifacts
|
|
76
|
+
schemabrain.db
|
|
77
|
+
schemabrain.db-journal
|
|
78
|
+
schemabrain.db-wal
|
|
79
|
+
schemabrain.db-shm
|
|
80
|
+
*.schemabrain.db
|
|
81
|
+
.schemabrain/
|
|
82
|
+
.fastembed_cache/
|
|
83
|
+
|
|
84
|
+
# Logs
|
|
85
|
+
*.log
|
|
86
|
+
logs/
|
|
87
|
+
|
|
88
|
+
# Claude
|
|
89
|
+
.claude/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.11
|