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

lang_tools: list[str] = Field(
default_factory=list,
alias="lang-tools",
description="Install tools for these languages to use in the build.",
)


class LangConfig(BaseModel):
model_config = {
Expand Down
14 changes: 11 additions & 3 deletions adbc_drivers_dev/make.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,19 @@ def detect_version(
raise ValueError(f"{driver_root} is not in a git repository")
repo_root = repo_root.parent

prefix = str(driver_root.relative_to(repo_root))
if prefix == ".":
is_script_build = not any(
(driver_root / name).is_file() for name in ("Cargo.toml", "go.mod")
)
if is_script_build:
# We're going to assume custom builds like this are effectively the
# entire repo, and use just plain tags "v1.0.0".
prefix = "v"
else:
prefix = f"{prefix}/v"
prefix = str(driver_root.relative_to(repo_root))
if prefix == ".":
prefix = "v"
else:
prefix = f"{prefix}/v"

tags = check_output(
[
Expand Down
33 changes: 32 additions & 1 deletion adbc_drivers_dev/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import enum
import io
import itertools
import os
import subprocess
import sys
import tarfile
Expand Down Expand Up @@ -151,6 +152,33 @@ def generate_rust_license(license_template: Path) -> str:
return license_data


def generate_custom_license(license_script: Path) -> str:
import platform

args = [str(license_script.absolute())]
if (
platform.system() == "Windows"
and os.environ.get("CI", "").lower().strip() == "true"
):
# Force use of Git Bash on GitHub Actions
args = [r"C:\Program Files\Git\bin\bash.EXE", *args]
license_proc = subprocess.run(
args,
cwd=license_script.parent.parent.parent,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
)
if license_proc.returncode != 0:
print("Failed to generate license", file=sys.stderr)
print("Stdout:", file=sys.stderr)
print(license_proc.stdout, file=sys.stderr)
print("Stderr:", file=sys.stderr)
print(license_proc.stderr, file=sys.stderr)
license_proc.check_returncode()
license_data = license_proc.stdout
return license_data


def generate_packages(
manifest: dict[str, typing.Any],
driver_name: str,
Expand Down Expand Up @@ -272,8 +300,11 @@ def main():
if not notice_file.is_file():
raise RuntimeError(f"NOTICE.txt ({notice_file}) is missing")

license_script = args.manifest_template.parent / "ci/scripts/generate_license.sh"
license_template = args.manifest_template.with_name("license.tpl")
if license_template.is_file():
if license_script.is_file():
license_data = generate_custom_license(license_script)
elif license_template.is_file():
if (gomod := args.manifest_template.with_name("go.mod")).is_file():
license_data = generate_go_license(license_template, gomod)
elif args.manifest_template.with_name("Cargo.toml").is_file():
Expand Down
30 changes: 15 additions & 15 deletions adbc_drivers_dev/templates/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,14 @@ jobs:
submodules: 'recursive'
<% endif %>

<% if lang == "go" %>
<% if "go" in lang_tools %>
- uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # v6.2.0
with:
cache-dependency-path: go/go.sum
check-latest: true
go-version-file: go/go.mod
<% elif lang == "rust" %>
<% endif %>
<% if "rust" in lang_tools %>
- uses: actions-rust-lang/setup-rust-toolchain@1780873c7b576612439a134613cc4cc74ce5538c # v1.15.2
with:
components: "clippy"
Expand Down Expand Up @@ -317,13 +318,14 @@ jobs:
submodules: 'recursive'
<% endif %>

<% if lang == "go" %>
<% if "go" in lang_tools %>
- uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # v6.2.0
with:
cache-dependency-path: go/go.sum
check-latest: true
go-version-file: go/go.mod
<% elif lang == "rust" %>
<% endif %>
<% if "rust" in lang_tools %>
- uses: actions-rust-lang/setup-rust-toolchain@1780873c7b576612439a134613cc4cc74ce5538c # v1.15.2
with:
components: "clippy"
Expand Down Expand Up @@ -493,13 +495,14 @@ jobs:
submodules: 'recursive'
<% endif %>

<% if lang == "go" %>
<% if "go" in lang_tools %>
- uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # v6.2.0
with:
cache-dependency-path: go/go.sum
check-latest: true
go-version-file: go/go.mod
<% elif lang == "rust" %>
<% endif %>
<% if "rust" in lang_tools %>
- uses: actions-rust-lang/setup-rust-toolchain@1780873c7b576612439a134613cc4cc74ce5538c # v1.15.2
with:
components: "clippy"
Expand Down Expand Up @@ -582,12 +585,13 @@ jobs:
submodules: 'recursive'
<% endif %>

<% if lang == "go" %>
<% if "go" in lang_tools %>
- uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # v6.2.0
with:
check-latest: true
go-version: "stable"
<% elif lang == "rust" %>
<% endif %>
<% if "rust" in lang_tools %>
- uses: actions-rust-lang/setup-rust-toolchain@1780873c7b576612439a134613cc4cc74ce5538c # v1.15.2
with:
components: "clippy"
Expand All @@ -606,7 +610,7 @@ jobs:
- name: Install tools
working-directory: <{ lang_subdir }>
run: |
<% if lang == "go" %>
<% if "go" in lang_tools %>
# XXX: can't install go-licenses under go 1.25
# https://github.com/google/go-licenses/issues/312
git clone --depth=1 https://github.com/google/go-licenses
Expand All @@ -619,7 +623,8 @@ jobs:
go mod tidy
go install .
popd
<% elif lang == "rust" %>
<% endif %>
<% if "rust" in lang_tools %>
cargo install cargo-about
<% endif %>

Expand Down Expand Up @@ -786,11 +791,6 @@ jobs:
submodules: 'recursive'
<% endif %>

- uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # v6.2.0
with:
check-latest: true
go-version: "stable"

- uses: prefix-dev/setup-pixi@a0af7a228712d6121d37aba47adf55c1332c9c2e # v0.9.4
with:
pixi-version: v0.63.2
Expand Down
5 changes: 5 additions & 0 deletions adbc_drivers_dev/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ def generate_workflows(args) -> int:

(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")
write_workflow(
workflows,
Expand All @@ -130,6 +133,7 @@ def generate_workflows(args) -> int:
"lang_human": lang_human,
"lang_subdir": lang_subdir,
"lang_config": lang_config,
"lang_tools": lang_tools,
},
)
write_workflow(
Expand All @@ -144,6 +148,7 @@ def generate_workflows(args) -> int:
"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 Down