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
10 changes: 7 additions & 3 deletions adbc_drivers_dev/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ class LangBuildConfig(BaseModel):
description="A list of additional arguments to pass to adbc-make.",
)

go_mod_path: str = Field(
default="go",
go_mod_path: str | None = Field(
default=None,
alias="go-mod-path",
description="Path containing the go.mod file for Go drivers. Used to cache dependencies in CI.",
description="Path containing the go.mod file for Go drivers. Used to cache dependencies in CI. Defaults to the language subdir.",
)

lang_tools: list[str] = Field(
Expand All @@ -94,6 +94,10 @@ class LangConfig(BaseModel):
default_factory=LangBuildConfig,
description="Configuration for building the driver.",
)
subdir: str | None = Field(
default=None,
description="Override the default subdirectory for this language. Use '.' to place files at the repository root.",
)
skip_test: bool = Field(
default=False,
alias="skip-test",
Expand Down
26 changes: 13 additions & 13 deletions adbc_drivers_dev/templates/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,20 @@ on:
branches:
- main
paths:
- "<{lang_subdir}>/**"
- "<{lang_path_glob}>"
<% for path in pull_request_trigger_paths %>
- <{path}>
<% endfor %>
<% endif %>
push:
<% if release %>
tags:
- "<{lang_subdir}>/v**"
- "<{lang_tag_prefix}>v**"
<% else %>
branches:
- main
paths:
- "<{lang_subdir}>/**"
- "<{lang_path_glob}>"
<% for path in pull_request_trigger_paths %>
- <{path}>
<% endfor %>
Expand Down Expand Up @@ -143,9 +143,9 @@ jobs:
<% if "go" in lang_tools %>
- uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
with:
cache-dependency-path: <{lang_config.build.go_mod_path}>/go.sum
cache-dependency-path: <{go_mod_path}>/go.sum
check-latest: true
go-version-file: <{lang_config.build.go_mod_path}>/go.mod
go-version-file: <{go_mod_path}>/go.mod
<% endif %>
<% if "rust" in lang_tools %>
- uses: actions-rust-lang/setup-rust-toolchain@150fca883cd4034361b621bd4e6a9d34e5143606 # v1.15.4
Expand Down Expand Up @@ -323,9 +323,9 @@ jobs:
<% if "go" in lang_tools %>
- uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
with:
cache-dependency-path: <{lang_config.build.go_mod_path}>/go.sum
cache-dependency-path: <{go_mod_path}>/go.sum
check-latest: true
go-version-file: <{lang_config.build.go_mod_path}>/go.mod
go-version-file: <{go_mod_path}>/go.mod
<% endif %>
<% if "rust" in lang_tools %>
- uses: actions-rust-lang/setup-rust-toolchain@150fca883cd4034361b621bd4e6a9d34e5143606 # v1.15.4
Expand Down Expand Up @@ -504,9 +504,9 @@ jobs:
<% if "go" in lang_tools %>
- uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
with:
cache-dependency-path: <{lang_config.build.go_mod_path}>/go.sum
cache-dependency-path: <{go_mod_path}>/go.sum
check-latest: true
go-version-file: <{lang_config.build.go_mod_path}>/go.mod
go-version-file: <{go_mod_path}>/go.mod
<% endif %>
<% if "rust" in lang_tools %>
- uses: actions-rust-lang/setup-rust-toolchain@150fca883cd4034361b621bd4e6a9d34e5143606 # v1.15.4
Expand Down Expand Up @@ -836,8 +836,8 @@ jobs:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
working-directory: <{ lang_subdir }>
run: |
git tag <{ lang_subdir }>/v1000.0.0
tag=<{ lang_subdir }>/v1000.0.0
git tag <{lang_tag_prefix}>v1000.0.0
tag=<{lang_tag_prefix}>v1000.0.0

pixi run release --dry-run $(pwd) $tag
echo gh release upload $tag $(find ~/packages -name '*.tar.gz') $(find ~/packages -name 'manifest.yaml') $(find ~/packages -name '*.md')
Expand All @@ -847,8 +847,8 @@ jobs:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
working-directory: <{ lang_subdir }>
run: |
git tag <{ lang_subdir }>/v1000.0.0
tag=<{ lang_subdir }>/v1000.0.0
git tag <{lang_tag_prefix}>v1000.0.0
tag=<{lang_tag_prefix}>v1000.0.0

pixi run release --dry-run $(pwd) $tag
echo gh release upload $tag $(find ~/packages -name '*.tar.gz') $(find ~/packages -name 'manifest.yaml') $(find ~/packages -name '*.md')
Expand Down
38 changes: 23 additions & 15 deletions adbc_drivers_dev/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,31 +109,46 @@ def generate_workflows(args) -> int:
}

retcode = 0
for lang, (lang_human, lang_subdir) in langs.items():
for lang, (lang_human, lang_subdir_default) in langs.items():
lang_config = params.lang.get(lang)
if not lang_config:
continue

lang_subdir = (
lang_config.subdir
if lang_config.subdir is not None
else lang_subdir_default
)
lang_tag_prefix = "" if lang_subdir == "." else f"{lang_subdir}/"
lang_path_glob = "**" if lang_subdir == "." else f"{lang_subdir}/**"

(args.repository / lang_subdir).mkdir(parents=True, exist_ok=True)

lang_tools = {lang}
lang_tools.update(lang_config.build.lang_tools)

template = env.get_template("test.yaml")
go_mod_path = lang_config.build.go_mod_path or lang_subdir
lang_ctx = {
"lang": lang,
"lang_human": lang_human,
"lang_subdir": lang_subdir,
"lang_tag_prefix": lang_tag_prefix,
"lang_path_glob": lang_path_glob,
"go_mod_path": go_mod_path,
"lang_config": lang_config,
"lang_tools": lang_tools,
}
write_workflow(
workflows,
template,
f"{lang}_test.yaml",
{
**params.to_dict(),
**lang_ctx,
"pull_request_trigger_paths": [f".github/workflows/{lang}_test.yaml"],
"release": False,
"workflow_name": "Test",
"lang": lang,
"lang_human": lang_human,
"lang_subdir": lang_subdir,
"lang_config": lang_config,
"lang_tools": lang_tools,
},
)
write_workflow(
Expand All @@ -142,13 +157,9 @@ def generate_workflows(args) -> int:
f"{lang}_release.yaml",
{
**params.to_dict(),
**lang_ctx,
"release": True,
"workflow_name": "Release",
"lang": lang,
"lang_human": lang_human,
"lang_subdir": lang_subdir,
"lang_config": lang_config,
"lang_tools": lang_tools,
},
)
template = env.get_template("go_test_pr.yaml")
Expand All @@ -169,10 +180,7 @@ def generate_workflows(args) -> int:
"pixi.toml",
{
**params.to_dict(),
"lang": lang,
"lang_human": lang_human,
"lang_subdir": lang_subdir,
"lang_config": lang_config,
**lang_ctx,
},
)

Expand Down
119 changes: 113 additions & 6 deletions schema/generate-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,86 @@
"title": "AwsConfig",
"type": "object"
},
"LangBuildConfig": {
"additionalProperties": false,
"properties": {
"additional-make-args": {
"description": "A list of additional arguments to pass to adbc-make.",
"items": {
"type": "string"
},
"title": "Additional-Make-Args",
"type": "array"
},
"go-mod-path": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Path containing the go.mod file for Go drivers. Used to cache dependencies in CI. Defaults to the language subdir.",
"title": "Go-Mod-Path"
},
"lang-tools": {
"description": "Install tools for these languages to use in the build.",
"items": {
"type": "string"
},
"title": "Lang-Tools",
"type": "array"
},
"environment-contexts": {
"description": "What parts of the build require the environment.",
"items": {
"type": "string"
},
"title": "Environment-Contexts",
"type": "array"
}
},
"title": "LangBuildConfig",
"type": "object"
},
"LangConfig": {
"additionalProperties": false,
"properties": {
"build": {
"$ref": "#/$defs/LangBuildConfig",
"description": "Configuration for building the driver."
},
"subdir": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Override the default subdirectory for this language. Use '.' to place files at the repository root.",
"title": "Subdir"
},
"skip-test": {
"default": false,
"description": "Whether to skip test workflows (primarily useful for build-only drivers)",
"title": "Skip-Test",
"type": "boolean"
},
"skip-validate": {
"default": false,
"description": "Whether to skip the validation suite in CI (this should only be used temporarily while setting up a driver)",
"title": "Skip-Validate",
"type": "boolean"
}
},
"title": "LangConfig",
"type": "object"
},
"SecretConfigDict": {
"additionalProperties": false,
"description": "Secret configuration with explicit secret name and contexts.",
Expand All @@ -29,6 +109,7 @@
"description": "Workflow contexts where this secret should be available",
"items": {
"enum": [
"build:test",
"build:release",
"test",
"validate"
Expand All @@ -51,9 +132,15 @@
"properties": {
"extra-dependencies": {
"additionalProperties": true,
"description": "Additional dependencies to install for validation workflows. Specify as key-value pairs. Example:\n\n[validation.extra-dependencies]\npytest = \"^7.0\"\nblack = \"*\"",
"description": "Additional dependencies to install for validation workflows. Specify as key-value pairs. Example:\n\n[validation.extra-dependencies]\npytest = \">=7,<8\"\nblack = \"*\"",
"title": "Extra-Dependencies",
"type": "object"
},
"extra-pypi-dependencies": {
"additionalProperties": true,
"description": "Additional dependencies to install for validation workflows. Specify as key-value pairs. Example:\n\n[validation.extra-pypi-dependencies]\npytest = \">=7,<8\"\nblack = \"*\"",
"title": "Extra-Pypi-Dependencies",
"type": "object"
}
},
"title": "ValidationConfig",
Expand All @@ -64,6 +151,19 @@
"additionalProperties": false,
"description": "You can validate your generate.toml against this schema with tools like tombi (https://tombi-toml.github.io/tombi/docs/linter). Requires placing a `#:schema` directive at the top of your generate.toml file.",
"properties": {
"repository": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "GitHub repository name (if different from driver name)",
"title": "Repository"
},
"driver": {
"default": "(unknown)",
"description": "Driver name. Should be lowercase (e.g., postgresql, sqlite)",
Expand All @@ -85,15 +185,22 @@
},
"private": {
"default": false,
"description": "Whether the driver is private. Most drivers will be non-private.",
"description": "Whether the driver is private. Most drivers will be not be private so you can omit this.",
"title": "Private",
"type": "boolean"
},
"lang": {
"additionalProperties": {
"type": "boolean"
"anyOf": [
{
"$ref": "#/$defs/LangConfig"
},
{
"type": "null"
}
]
},
"description": "Programming languages to enable workflows for. Only go is really supported right now. Keys should be lowercase. Set to true to enable, false to disable. Example:\n\n[lang]\ngo = true\npython = false",
"description": "Programming language(s) to enable workflows for. Only go and rust are supported. Keys should be lowercase. Set to true to enable with default config, or false (the default) to disable. Example:\n\n[lang]\ngo = true\n\n[lang.rust.build]\nadditional-make-args = [\"example\"]",
"title": "Lang",
"type": "object"
},
Expand All @@ -108,7 +215,7 @@
}
]
},
"description": "Secrets to enable in workflows. By default, no secrets are available in your generated workflows unless you specify them here.\n\nFor a secret available in all workflows, use simple syntax:\n\n[secrets]\nMY_TOKEN = \"GITHUB_SECRET_NAME\"\n\nTo restrict secrets to specific workflows, use contexts (valid values: 'build:release', 'test', 'validate'):\n\n[secrets.DB_PASSWORD]\nsecret = \"TEST_DB_SECRET\"\ncontexts = [\"test\", \"validate\"]",
"description": "Secrets to enable in workflows. By default, no secrets are available in your generated workflows unless you specify them here.\n\nTo make a secret available in all workflows, use the simple syntax:\n\n[secrets]\nMY_TOKEN = \"GITHUB_SECRET_NAME\"\n\nIf you want more fine-grained control, you can restrict secrets to specific workflows. To do this, specify contexts contexts ('build:release', 'test', 'validate') like this:\n\n[secrets.DB_PASSWORD]\nsecret = \"TEST_DB_SECRET\"\ncontexts = [\"test\", \"validate\"]",
"title": "Secrets",
"type": "object"
},
Expand All @@ -122,7 +229,7 @@
}
],
"default": null,
"description": "Enables AWS authentication in workflows. Automatically adds AWS_ROLE and AWS_ROLE_SESSION_NAME secrets, and sets id_token permissions. Example:\n\naws.region = \"us-west-2\"\n\nOr:\n\n[aws]\nregion = \"us-west-2\""
"description": "Enables AWS authentication in workflows. Automatically adds AWS_ROLE and AWS_ROLE_SESSION_NAME secrets, and sets id_token permissions. Example:\n\n[aws]\nregion = \"us-west-2\""
},
"gcloud": {
"default": false,
Expand Down