Skip to content

Commit b8bad33

Browse files
authored
Merge branch 'main' into patch-1
2 parents c37d493 + 0b18104 commit b8bad33

File tree

9 files changed

+126
-90
lines changed

9 files changed

+126
-90
lines changed

.github/workflows/on_pr.yml

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,40 +19,24 @@ concurrency:
1919
cancel-in-progress: true
2020

2121
jobs:
22-
ensure_submodule_sanity:
23-
name: Make sure we're not building with a fork
24-
runs-on: ubuntu-latest
25-
steps:
26-
- name: Checkout DuckDB Python
27-
uses: actions/checkout@v4
28-
29-
- shell: bash
30-
run: |
31-
submodule_url=$(git config --file .gitmodules --get submodule.external/duckdb.url || true)
32-
expected="github.com/duckdb/duckdb"
33-
if [[ -z "$submodule_url" ]]; then
34-
echo "::error::DuckDB submodule not found in .gitmodules"
35-
exit 1
36-
fi
37-
if [[ "$submodule_url" != *"$expected"* ]]; then
38-
echo "::error::DuckDB submodule must point to $expected, found: $submodule_url"
39-
exit 1
40-
fi
22+
submodule_sanity_guard:
23+
name: Make sure submodule is in a sane state
24+
uses: ./.github/workflows/submodule_sanity.yml
4125

4226
packaging_test:
4327
name: Build a minimal set of packages and run all tests on them
44-
needs: ensure_submodule_sanity
28+
needs: submodule_sanity_guard
4529
# Skip packaging tests for draft PRs
4630
if: ${{ github.event_name != 'pull_request' || github.event.pull_request.draft == false }}
4731
uses: ./.github/workflows/packaging.yml
4832
with:
4933
minimal: true
5034
testsuite: all
51-
duckdb-git-ref: ${{ github.base_ref }}
35+
duckdb-sha: ${{ github.base_ref }}
5236

5337
coverage_test:
5438
name: Run coverage tests
55-
needs: ensure_submodule_sanity
39+
needs: submodule_sanity_guard
5640
# Only run coverage test for draft PRs
5741
if: ${{ github.event_name == 'pull_request' && github.event.pull_request.draft == true }}
5842
uses: ./.github/workflows/coverage.yml

.github/workflows/packaging.yml

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,14 @@ on:
1616
- none
1717
- fast
1818
- all
19-
git-ref:
19+
duckdb-python-sha:
2020
type: string
21-
description: Git ref of the DuckDB python package
21+
description: The commit to build against (defaults to latest commit of current ref)
2222
required: false
23-
duckdb-git-ref:
23+
duckdb-sha:
2424
type: string
25-
description: Git ref of DuckDB
26-
required: true
27-
default: refs/heads/main
25+
description: Override the DuckDB submodule commit or ref to build against
26+
required: false
2827
set-version:
2928
type: string
3029
description: Force version (vX.Y.Z-((rc|post)N))
@@ -40,13 +39,13 @@ on:
4039
description: Testsuite to run (none, fast, all)
4140
required: true
4241
default: all
43-
git-ref:
42+
duckdb-python-sha:
4443
type: string
45-
description: Git ref of the DuckDB python package
44+
description: The commit or ref to build against (defaults to latest commit of current ref)
4645
required: false
47-
duckdb-git-ref:
46+
duckdb-sha:
4847
type: string
49-
description: Git ref of DuckDB
48+
description: Override the DuckDB submodule commit or ref to build against
5049
required: false
5150
set-version:
5251
description: Force version (vX.Y.Z-((rc|post)N))
@@ -67,8 +66,8 @@ jobs:
6766
uses: ./.github/workflows/packaging_sdist.yml
6867
with:
6968
testsuite: all
70-
git-ref: ${{ github.ref }}
71-
duckdb-git-ref: ${{ inputs.duckdb-sha }}
69+
duckdb-python-sha: ${{ inputs.duckdb-python-sha != '' && inputs.duckdb-python-sha || github.sha }}
70+
duckdb-sha: ${{ inputs.duckdb-sha }}
7271
set-version: ${{ inputs.stable-version }}
7372

7473
build_wheels:
@@ -77,6 +76,6 @@ jobs:
7776
with:
7877
minimal: false
7978
testsuite: all
80-
git-ref: ${{ github.ref }}
81-
duckdb-git-ref: ${{ inputs.duckdb-sha }}
79+
duckdb-python-sha: ${{ inputs.duckdb-python-sha != '' && inputs.duckdb-python-sha || github.sha }}
80+
duckdb-sha: ${{ inputs.duckdb-sha }}
8281
set-version: ${{ inputs.stable-version }}

.github/workflows/packaging_sdist.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ on:
77
description: Testsuite to run (none, fast, all)
88
required: true
99
default: all
10-
git-ref:
10+
duckdb-python-sha:
1111
type: string
12-
description: Git ref of the DuckDB python package
12+
description: The commit or ref to build against (defaults to current ref)
1313
required: false
14-
duckdb-git-ref:
14+
duckdb-sha:
1515
type: string
16-
description: Git ref of DuckDB
16+
description: Override the DuckDB submodule commit or ref to build against
1717
required: false
1818
set-version:
1919
description: Force version (vX.Y.Z-((rc|post)N))
@@ -39,16 +39,17 @@ jobs:
3939
- name: Checkout DuckDB Python
4040
uses: actions/checkout@v4
4141
with:
42-
ref: ${{ inputs.git-ref }}
42+
ref: ${{ inputs.duckdb-python-sha }}
4343
fetch-depth: 0
4444
submodules: true
4545

4646
- name: Checkout DuckDB
4747
shell: bash
48+
if: ${{ inputs.duckdb-sha }}
4849
run: |
4950
cd external/duckdb
5051
git fetch origin
51-
git checkout ${{ inputs.duckdb-git-ref }}
52+
git checkout ${{ inputs.duckdb-sha }}
5253
5354
- name: Set OVERRIDE_GIT_DESCRIBE
5455
if: ${{ inputs.set-version != '' }}

.github/workflows/packaging_wheels.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ on:
1111
description: Testsuite to run (none, fast, all)
1212
required: true
1313
default: all
14-
git-ref:
14+
duckdb-python-sha:
1515
type: string
16-
description: Git ref of the DuckDB python package
16+
description: The commit or ref to build against (defaults to latest commit of current ref)
1717
required: false
18-
duckdb-git-ref:
18+
duckdb-sha:
1919
type: string
20-
description: Git ref of DuckDB
20+
description: Override the DuckDB submodule commit or ref to build against
2121
required: false
2222
set-version:
2323
description: Force version (vX.Y.Z-((rc|post)N))
@@ -59,16 +59,17 @@ jobs:
5959
- name: Checkout DuckDB Python
6060
uses: actions/checkout@v4
6161
with:
62-
ref: ${{ inputs.git-ref }}
62+
ref: ${{ inputs.duckdb-python-sha }}
6363
fetch-depth: 0
6464
submodules: true
6565

6666
- name: Checkout DuckDB
6767
shell: bash
68+
if: ${{ inputs.duckdb-sha }}
6869
run: |
6970
cd external/duckdb
7071
git fetch origin
71-
git checkout ${{ inputs.duckdb-git-ref }}
72+
git checkout ${{ inputs.duckdb-sha }}
7273
7374
# Make sure that OVERRIDE_GIT_DESCRIBE is propagated to cibuildwhel's env, also when it's running linux builds
7475
- name: Set OVERRIDE_GIT_DESCRIBE

.github/workflows/release.yml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,13 @@ name: Release
33
on:
44
workflow_dispatch:
55
inputs:
6+
duckdb-python-sha:
7+
type: string
8+
description: The commit to build against (defaults to latest commit of current ref)
9+
required: false
610
duckdb-sha:
711
type: string
8-
description: The DuckDB submodule commit to build against
12+
description: The DuckDB submodule commit or ref to build against
913
required: true
1014
stable-version:
1115
type: string
@@ -33,8 +37,8 @@ jobs:
3337
uses: ./.github/workflows/packaging_sdist.yml
3438
with:
3539
testsuite: all
36-
git-ref: ${{ github.ref }}
37-
duckdb-git-ref: ${{ inputs.duckdb-sha }}
40+
duckdb-python-sha: ${{ inputs.duckdb-python-sha != '' && inputs.duckdb-python-sha || github.sha }}
41+
duckdb-sha: ${{ inputs.duckdb-sha }}
3842
set-version: ${{ inputs.stable-version }}
3943

4044
workflow_state:
@@ -111,8 +115,8 @@ jobs:
111115
with:
112116
minimal: false
113117
testsuite: all
114-
git-ref: ${{ github.ref }}
115-
duckdb-git-ref: ${{ inputs.duckdb-sha }}
118+
duckdb-python-sha: ${{ inputs.duckdb-python-sha != '' && inputs.duckdb-python-sha || github.sha }}
119+
duckdb-sha: ${{ inputs.duckdb-sha }}
116120
set-version: ${{ inputs.stable-version }}
117121

118122
upload_s3:
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Check DuckDB submodule sanity
2+
on:
3+
workflow_call:
4+
workflow_dispatch:
5+
jobs:
6+
submodule_sanity:
7+
name: Make sure submodule is in a sane state
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Checkout DuckDB Python
11+
uses: actions/checkout@v4
12+
with:
13+
fetch-depth: 0
14+
15+
- name: Verify submodule origin
16+
shell: bash
17+
run: |
18+
set -eux
19+
git submodule update --init
20+
cd external/duckdb
21+
remote_count=$(git remote | wc -l)
22+
if [[ $remote_count -gt 1 ]]; then
23+
echo "::error::Multiple remotes found - only origin allowed"
24+
git remote -v
25+
fi
26+
origin_url=$(git remote get-url origin)
27+
if [[ "$origin_url" != "https://github.com/duckdb/duckdb"* ]]; then
28+
echo "::error::Submodule origin has been tampered with: $origin_url"
29+
exit 1
30+
fi
31+
32+
- name: Disallow changes to .gitmodules in PRs and pushes
33+
if: ${{ github.event_name == 'pull_request' || github.event_name == 'push' }}
34+
shell: bash
35+
run: |
36+
set -eux
37+
before=${{ github.event_name == 'push' && github.event.before || format('origin/{0}', github.base_ref) }}
38+
after=${{ github.event_name == 'push' && github.event.after || github.head_ref }}
39+
if git diff --name-only $before...$after | grep -q "^\.gitmodules$"; then
40+
echo "::error::.gitmodules may not be modified. If you see a reason to update, please discuss with the maintainers."
41+
exit 1
42+
fi

duckdb_packaging/_versioning.py

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,34 +16,34 @@
1616

1717
def parse_version(version: str) -> tuple[int, int, int, int, int]:
1818
"""Parse a version string into its components.
19-
19+
2020
Args:
2121
version: Version string (e.g., "1.3.1", "1.3.2.rc3" or "1.3.1.post2")
22-
22+
2323
Returns:
2424
Tuple of (major, minor, patch, post, rc)
25-
25+
2626
Raises:
2727
ValueError: If version format is invalid
2828
"""
2929
match = VERSION_RE.match(version)
3030
if not match:
3131
raise ValueError(f"Invalid version format: {version} (expected X.Y.Z, X.Y.Z.rcM or X.Y.Z.postN)")
32-
32+
3333
major, minor, patch, rc, post = match.groups()
3434
return int(major), int(minor), int(patch), int(post or 0), int(rc or 0)
3535

3636

3737
def format_version(major: int, minor: int, patch: int, post: int = 0, rc: int = 0) -> str:
3838
"""Format version components into a version string.
39-
39+
4040
Args:
4141
major: Major version number
42-
minor: Minor version number
42+
minor: Minor version number
4343
patch: Patch version number
4444
post: Post-release number
4545
rc: RC number
46-
46+
4747
Returns:
4848
Formatted version string
4949
"""
@@ -59,31 +59,31 @@ def format_version(major: int, minor: int, patch: int, post: int = 0, rc: int =
5959

6060
def git_tag_to_pep440(git_tag: str) -> str:
6161
"""Convert git tag format to PEP440 format.
62-
62+
6363
Args:
6464
git_tag: Git tag (e.g., "v1.3.1", "v1.3.1-post1")
65-
65+
6666
Returns:
6767
PEP440 version string (e.g., "1.3.1", "1.3.1.post1")
6868
"""
6969
# Remove 'v' prefix if present
7070
version = git_tag[1:] if git_tag.startswith('v') else git_tag
71-
71+
7272
if "-post" in version:
7373
assert 'rc' not in version
7474
version = version.replace("-post", ".post")
7575
elif '-rc' in version:
7676
version = version.replace("-rc", "rc")
77-
77+
7878
return version
7979

8080

8181
def pep440_to_git_tag(version: str) -> str:
8282
"""Convert PEP440 version to git tag format.
83-
83+
8484
Args:
8585
version: PEP440 version string (e.g., "1.3.1.post1" or "1.3.1rc2")
86-
86+
8787
Returns:
8888
Git tag format (e.g., "v1.3.1-post1")
8989
"""
@@ -98,7 +98,7 @@ def pep440_to_git_tag(version: str) -> str:
9898

9999
def get_current_version() -> Optional[str]:
100100
"""Get the current version from git tags.
101-
101+
102102
Returns:
103103
Current version string or None if no tags exist
104104
"""
@@ -149,16 +149,21 @@ def strip_post_from_version(version: str) -> str:
149149
return re.sub(r"[\.-]post[0-9]+", "", version)
150150

151151

152-
def get_git_describe(repo_path: Optional[pathlib.Path] = None) -> Optional[str]:
152+
def get_git_describe(repo_path: Optional[pathlib.Path] = None, since_major=False, since_minor=False) -> Optional[str]:
153153
"""Get git describe output for version determination.
154-
154+
155155
Returns:
156156
Git describe output or None if no tags exist
157157
"""
158158
cwd = repo_path if repo_path is not None else None
159+
pattern="v*.*.*"
160+
if since_major:
161+
pattern="v*.0.0"
162+
elif since_minor:
163+
pattern="v*.*.0"
159164
try:
160165
result = subprocess.run(
161-
["git", "describe", "--tags", "--long", "--match", "v*.*.*"],
166+
["git", "describe", "--tags", "--long", "--match", pattern],
162167
capture_output=True,
163168
text=True,
164169
check=True,
@@ -167,4 +172,4 @@ def get_git_describe(repo_path: Optional[pathlib.Path] = None) -> Optional[str]:
167172
result.check_returncode()
168173
return result.stdout.strip()
169174
except FileNotFoundError:
170-
raise RuntimeError("git executable can't be found")
175+
raise RuntimeError("git executable can't be found")

0 commit comments

Comments
 (0)