Skip to content
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

ci(scripts): Add a script to generate version list #4827

Merged
merged 2 commits into from
Jun 30, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
9 changes: 1 addition & 8 deletions scripts/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def get_rust_package_version(path):
#
# For examples:
# core: `0.45.0`
# packages depends on core: `0.1.0+core.0.45.0`
# packages depends on core: `0.1.0`
def get_package_version(package):
if package == "core":
return get_rust_package_version("core")
Expand All @@ -78,10 +78,3 @@ def get_package_version(package):
#
# However, those packages are not mature enough, it's much easier for us to always return `0.0.0` instead.
return f"0.0.0"


if __name__ == "__main__":
for v in PACKAGES:
print(
f"{v}: version={get_package_version(v)}"
)
13 changes: 6 additions & 7 deletions scripts/dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import subprocess
from constants import PACKAGES


def check_deps():
cargo_dirs = PACKAGES
for root in cargo_dirs:
Expand Down Expand Up @@ -50,18 +51,16 @@ def generate_deps():
subparsers = parser.add_subparsers()

parser_check = subparsers.add_parser(
'check',
description="Check dependencies",
help="Check dependencies")
"check", description="Check dependencies", help="Check dependencies"
)
parser_check.set_defaults(func=check_deps)

parser_generate = subparsers.add_parser(
'generate',
description="Generate dependencies",
help="Generate dependencies")
"generate", description="Generate dependencies", help="Generate dependencies"
)
parser_generate.set_defaults(func=generate_deps)

args = parser.parse_args()
arg_dict = dict(vars(args))
del arg_dict['func']
del arg_dict["func"]
args.func(**arg_dict)
2 changes: 1 addition & 1 deletion scripts/merge_local_staging.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def print_directory_contents(directory, prefix=""):


def print_index_contents(directory):
for sub_dir in directory.rglob('.index'):
for sub_dir in directory.rglob(".index"):
with sub_dir.open("r") as file:
print(file.read())

Expand Down
8 changes: 7 additions & 1 deletion scripts/release.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,13 @@ def generate_checksum():
for i in Path(ROOT_DIR / "dist").glob("*.tar.gz"):
print(f"Check checksum for {i}")
subprocess.run(
["shasum", "-a", "512", "-c", f"{str(i.relative_to(ROOT_DIR / 'dist'))}.sha512"],
[
"shasum",
"-a",
"512",
"-c",
f"{str(i.relative_to(ROOT_DIR / 'dist'))}.sha512",
],
cwd=ROOT_DIR / "dist",
check=True,
)
Expand Down
4 changes: 3 additions & 1 deletion scripts/verify.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,9 @@ def build_java_binding(dir):
print(
"Cargo is not found, please check if rust development has been setup correctly"
)
print("Visit https://www.rust-lang.org/tools/install for more information")
print(
"Visit https://www.rust-lang.org/tools/install for more information"
)
sys.exit(1)

if "java" in dir.name:
Expand Down
35 changes: 35 additions & 0 deletions scripts/version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env python3
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

from constants import PACKAGES, get_package_version


def increment_patch_version(version):
parts = version.split(".")
parts[-1] = str(int(parts[-1]) + 1)
return ".".join(parts)


if __name__ == "__main__":
print(f"| {'Name':<25} | {'Version':<7} | {'Next':<7} |")
print(f"| {'-':<25} | {'-':<7} | {'-':<7} |")
for v in PACKAGES:
cur = get_package_version(v)
next = increment_patch_version(cur)

print(f"| {str(v):<25} | {cur:<7} | {next:<7} |")