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
66 changes: 61 additions & 5 deletions adbc_drivers_dev/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,13 @@
from pydantic import BaseModel, Field, PrivateAttr, field_validator, model_validator

# Define workflow contexts in a single location
WorkflowContext = typing.Literal["build:release", "test", "validate"]
WORKFLOW_CONTEXTS: tuple[WorkflowContext, ...] = ("build:release", "test", "validate")
WorkflowContext = typing.Literal["build:test", "build:release", "test", "validate"]
WORKFLOW_CONTEXTS: tuple[WorkflowContext, ...] = (
"build:test",
"build:release",
"test",
"validate",
)


class SecretConfigDict(BaseModel):
Expand All @@ -45,6 +50,46 @@ class AwsConfig(BaseModel):
)


class LangBuildConfig(BaseModel):
# validate_by_{name,alias} are to let us map "additional-make-args" to "additional_make_args"
model_config = {
"extra": "forbid",
"validate_by_name": True,
"validate_by_alias": True,
}

additional_make_args: list[str] = Field(
default_factory=list,
alias="additional-make-args",
description="A list of additional arguments to pass to adbc-make.",
)


class LangConfig(BaseModel):
model_config = {
"extra": "forbid",
"validate_by_name": True,
"validate_by_alias": True,
}

build: LangBuildConfig = Field(
default_factory=LangBuildConfig,
description="Configuration for building the driver.",
)
skip_validate: bool = Field(
default=False,
alias="skip-validate",
description="Whether to skip the validation suite in CI (this should only be used temporarily while setting up a driver)",
)

@model_validator(mode="before")
@classmethod
def true_is_enabled(cls, data: typing.Any) -> typing.Any:
if isinstance(data, bool):
return {}
return data


class ValidationConfig(BaseModel):
"""Configuration for validation workflows."""

Expand Down Expand Up @@ -92,14 +137,16 @@ class GenerateConfig(BaseModel):
default=False,
description="Whether the driver is private. Most drivers will be not be private so you can omit this.",
)
lang: dict[str, bool] = Field(
lang: dict[str, LangConfig | None] = Field(
default_factory=dict,
json_schema_extra={
"description": """Programming language(s) to enable workflows for. Only go is really supported right now. Keys should be lowercase. Set to true to enable, false to disable. Example:
"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:

[lang]
go = true
python = false"""

[lang.rust.build]
additional-make-args = ["example"]"""
},
)
secrets: dict[str, str | SecretConfigDict] = Field(
Expand Down Expand Up @@ -155,6 +202,15 @@ def validate_environment(cls, v: str | None) -> str | None:
raise ValueError("environment must be non-empty if provided")
return v

@field_validator("lang", mode="before")
@classmethod
def lang_boolean(cls, value: typing.Any) -> typing.Any:
value = value or {}
return {
k: LangConfig() if v is True else None if v is False else v
for k, v in value.items()
}

@model_validator(mode="after")
def process_secrets_and_permissions(self) -> "GenerateConfig":
"""Process secrets configuration and set up permissions."""
Expand Down
2 changes: 1 addition & 1 deletion adbc_drivers_dev/templates/dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
go-version-file: go/go.mod
<% endif %>

- uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: "3.x"

Expand Down
4 changes: 2 additions & 2 deletions adbc_drivers_dev/templates/dev_daily.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ jobs:
pull-requests: write

steps:
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 1
persist-credentials: true # for git operations below

- name: Install uv
uses: astral-sh/setup-uv@61cb8a9741eeb8a550a1b8544337180c0fc8476b # 7.2.0.
uses: astral-sh/setup-uv@61cb8a9741eeb8a550a1b8544337180c0fc8476b # v7.2.0

- name: Re-generate workflows
run: |
Expand Down
Loading