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
49 changes: 40 additions & 9 deletions adbc_drivers_dev/make.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,17 +179,45 @@ def detect_version(
# use a version that dbc will still accept, not "unknown" like we used to
version = "v0.0.1-dev"
else:
tag = tags[0]
version = tag[len(prefix) - 1 :]
# If we are not on the tag, append the commit count and hash
count = int(
check_output(["git", "rev-list", f"{tag}..HEAD", "--count"], cwd=repo_root)
)
# sort tags, then find distance from all tags to HEAD
# the assumption is that this is monotonically increasing, else we have a problem
versions = []
for tag in tags:
version_str = tag[len(prefix) - 1 :]
version = packaging.version.parse(version_str)
distance = int(
check_output(
["git", "rev-list", f"{tag}..HEAD", "--count"], cwd=repo_root
)
)
versions.append((version_str, version, distance, tag))

versions.sort(key=lambda v: v[1], reverse=True)
for v, prev in zip(versions, versions[1:]):
if v[2] > prev[2]:
raise ValueError(
f"Tag {v[0]} is further from HEAD than {prev[0]}, but has a newer version"
)

version, parsed_version, count, tag = versions[0]
if count > 0:
if strict:
raise ValueError(
f"Driver {driver_root} is not on tag {tag}, but has {count} commits since"
)
if parsed_version.is_prerelease or parsed_version.is_devrelease:
# This is a weird edge case, but just use the previous version (or dev version)
for v in versions:
if not (v[1].is_prerelease or v[1].is_devrelease):
version, parsed_version, count, tag = v
break
else:
version = "v0.0.1"
count = int(
check_output(
["git", "rev-list", "HEAD", "--count"], cwd=repo_root
)
)
rev = check_output(["git", "rev-parse", "--short", "HEAD"], cwd=repo_root)
version += f"-dev.{count}.{rev}"

Expand Down Expand Up @@ -276,7 +304,8 @@ def build_go(
*,
ci: bool = False,
) -> None:
version = detect_version(driver_root)
strict = to_bool(get_var("RELEASE", "false"))
version = detect_version(driver_root, strict=strict)
(repo_root / "build").mkdir(exist_ok=True)

# Embed the version in the library
Expand Down Expand Up @@ -371,7 +400,8 @@ def build_rust(
*,
ci: bool = False,
) -> None:
version = detect_version(driver_root)
strict = to_bool(get_var("RELEASE", "false"))
version = detect_version(driver_root, strict=strict)
(repo_root / "build").mkdir(exist_ok=True)

debug = to_bool(get_var("DEBUG", "False"))
Expand Down Expand Up @@ -439,7 +469,8 @@ def build_script(
*,
ci: bool = False,
) -> None:
version = detect_version(driver_root)
strict = to_bool(get_var("RELEASE", "false"))
version = detect_version(driver_root, strict=strict)
(repo_root / "build").mkdir(exist_ok=True)

debug = to_bool(get_var("DEBUG", "False"))
Expand Down
4 changes: 2 additions & 2 deletions adbc_drivers_dev/templates/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ jobs:
source .env.release
fi
set +a
pixi run adbc-make check CI=true VERBOSE=true DRIVER=<{driver}> IMPL_LANG=<{lang}> <{' '.join(lang_config.build.additional_make_args) }>
pixi run adbc-make check CI=true VERBOSE=true DRIVER=<{driver}> IMPL_LANG=<{lang}> <{' '.join(lang_config.build.additional_make_args) }><% if release %>RELEASE=true<% endif %>

- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
Expand Down Expand Up @@ -657,7 +657,7 @@ jobs:
--name <{driver}> \
--root $(pwd) \
--manifest-template $(pwd)/manifest.toml \
${{ (inputs.release && '--release') || '' }}\
<% if release %>--release<% endif %> \
-o ~/packages \
~/drivers/drivers-*-*/

Expand Down