Repository navigation
dev: Allow new release version to be automatically updated #26007
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,29 +26,6 @@ | |
| from pathlib import Path | ||
| import tomlkit | ||
|
|
||
| crates = { | ||
| 'datafusion-common': 'datafusion/common/Cargo.toml', | ||
| 'datafusion-common-runtime': 'datafusion/common-runtime/Cargo.toml', | ||
| 'datafusion': 'datafusion/core/Cargo.toml', | ||
| 'datafusion-execution': 'datafusion/execution/Cargo.toml', | ||
| 'datafusion-expr': 'datafusion/expr/Cargo.toml', | ||
| 'datafusion-ffi': 'datafusion/ffi/Cargo.toml', | ||
| 'datafusion-functions': 'datafusion/functions/Cargo.toml', | ||
| 'datafusion-functions-aggregate': 'datafusion/functions-aggregate/Cargo.toml', | ||
| 'datafusion-functions-nested': 'datafusion/functions-nested/Cargo.toml', | ||
| 'datafusion-optimizer': 'datafusion/optimizer/Cargo.toml', | ||
| 'datafusion-physical-expr': 'datafusion/physical-expr/Cargo.toml', | ||
| 'datafusion-physical-expr-common': 'datafusion/physical-expr-common/Cargo.toml', | ||
| 'datafusion-physical-plan': 'datafusion/physical-plan/Cargo.toml', | ||
| 'datafusion-proto': 'datafusion/proto/Cargo.toml', | ||
| 'datafusion-sql': 'datafusion/sql/Cargo.toml', | ||
| 'datafusion-sqllogictest': 'datafusion/sqllogictest/Cargo.toml', | ||
| 'datafusion-substrait': 'datafusion/substrait/Cargo.toml', | ||
| 'datafusion-wasmtest': 'datafusion/wasmtest/Cargo.toml', | ||
| 'datafusion-benchmarks': 'benchmarks/Cargo.toml', | ||
| 'datafusion-cli': 'datafusion-cli/Cargo.toml', | ||
| 'datafusion-examples': 'datafusion-examples/Cargo.toml', | ||
| } | ||
|
Comment on lines
-29
to
-51
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was not catching everything, and is also not needed since all crates start with "datafusion". |
||
|
|
||
| def update_workspace_version(new_version: str): | ||
| cargo_toml = 'Cargo.toml' | ||
|
|
@@ -64,47 +41,15 @@ def update_workspace_version(new_version: str): | |
|
|
||
| doc = tomlkit.parse(data) | ||
|
|
||
| for crate in crates.keys(): | ||
| df_dep = doc.get('workspace').get('dependencies', {}).get(crate) | ||
| for crate, df_dep in doc['workspace']['dependencies'].items(): | ||
| if not crate.startswith('datafusion'): | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Per your above comment, this seems like a reasonable way to enumerate all crates now - but I don't know if that will always be the case. Would love one of the committers to opine whether we can expect all crate names to start with
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe so, all DataFusion subcrates get updated when a new version is released, and they should always have the same prefix. |
||
| continue | ||
| # skip crates that pin datafusion using git hash | ||
| if df_dep is not None and df_dep.get('version') is not None: | ||
| print(f'updating {crate} dependency in {cargo_toml}') | ||
| df_dep['version'] = new_version | ||
|
|
||
| with open(cargo_toml, 'w') as f: | ||
| f.write(tomlkit.dumps(doc)) | ||
|
|
||
|
|
||
| def update_datafusion_version(cargo_toml: str, new_version: str): | ||
| print(f'updating {cargo_toml}') | ||
| with open(cargo_toml) as f: | ||
| data = f.read() | ||
|
|
||
| doc = tomlkit.parse(data) | ||
| pkg = doc.get('package') | ||
| if 'workspace' not in pkg['version']: | ||
| pkg['version'] = new_version | ||
|
|
||
| with open(cargo_toml, 'w') as f: | ||
| f.write(tomlkit.dumps(doc)) | ||
|
|
||
| def update_downstream_versions(cargo_toml: str, new_version: str): | ||
| with open(cargo_toml) as f: | ||
| data = f.read() | ||
|
|
||
| doc = tomlkit.parse(data) | ||
|
|
||
| for crate in crates.keys(): | ||
| df_dep = doc.get('dependencies', {}).get(crate) | ||
| # skip crates that pin datafusion using git hash | ||
| if df_dep is not None and df_dep.get('version') is not None: | ||
| print(f'updating {crate} dependency in {cargo_toml}') | ||
| df_dep['version'] = new_version | ||
|
|
||
| df_dep = doc.get('dev-dependencies', {}).get(crate) | ||
| if df_dep is not None and df_dep.get('version') is not None: | ||
| print(f'updating {crate} dev-dependency in {cargo_toml}') | ||
| df_dep['version'] = new_version | ||
|
Comment on lines
-78
to
-107
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The subcrates use the workspace version directly, so this is not needed anymore. |
||
| doc['workspace']['package']['version'] = new_version | ||
|
|
||
| with open(cargo_toml, 'w') as f: | ||
| f.write(tomlkit.dumps(doc)) | ||
|
|
@@ -117,6 +62,7 @@ def update_docs(path: str, new_version: str): | |
| fd.seek(0) | ||
| content = re.sub(r'datafusion\s*=\s*"(.+?)"', f'datafusion = "{new_version}"', content) | ||
| content = re.sub(r'datafusion\s*=\s*\{\s*version\s*=\s*"(.+?)"', f'datafusion = {{ version = "{new_version}"', content) | ||
| content = re.sub(r'datafusion version \d+\.\d+\.\d+', f'datafusion version {new_version}', content) | ||
| fd.truncate() | ||
| fd.write(content) | ||
|
|
||
|
|
@@ -151,18 +97,11 @@ def main(): | |
| print(f'Updating workspace in {repo_root} to {new_version}') | ||
| update_workspace_version(new_version) | ||
|
|
||
| print(f'Updating datafusion crate versions in {repo_root} to {new_version}') | ||
| for cargo_toml in crates.values(): | ||
| update_datafusion_version(cargo_toml, new_version) | ||
|
|
||
| print(f'Updating datafusion dependency versions in {repo_root} to {new_version}') | ||
| for cargo_toml in crates.values(): | ||
| update_downstream_versions(cargo_toml, new_version) | ||
|
|
||
| update_docs("README.md", new_version) | ||
| update_docs("docs/source/download.md", new_version) | ||
| update_docs("docs/source/user-guide/example-usage.md", new_version) | ||
| update_docs("docs/source/user-guide/crate-configuration.md", new_version) | ||
| update_docs("docs/source/user-guide/configs.md", new_version) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. see my top-level comment -
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure what the issue is, the diff looks ok to me.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm still not sure what the issue is, the
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah I see, my initial interpretation of this row in the table was
whereas it actually means
All good here. |
||
|
|
||
| update_ci(new_version) | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does sound like the manual
cargo checkis actually needed? For me, the script is updating Cargo.lock automatically, andcargo check -p datafusionproduces no new diffThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Cargo.lock is not updated by the script. Are you maybe running rust-analyzer in the background (e.g., in vscode)? I tested again and these are the files that changed for me:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, that's exactly what it was -- background rust-analyzer process updating the Cargo.lock!