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

Add support to report issue to ROS gz_*_vendor repositories in release.py #1150

Closed
wants to merge 8 commits into from
Closed
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
46 changes: 43 additions & 3 deletions check_releasepy.bash
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ exec_releasepy_test()
./release.py \
--dry-run \
--no-sanity-checks \
gz-foo 1.2.3 token ${test_params}""
gz-foo 1.2.3 token ${test_params}
}

exec_ignition_releasepy_test()
Expand All @@ -22,7 +22,7 @@ exec_ignition_releasepy_test()
./release.py \
--dry-run \
--no-sanity-checks \
ign-foo 1.2.3 token ${test_params}""
ign-foo 1.2.3 token ${test_params}
}

exec_ignition_gazebo_releasepy_test()
Expand All @@ -32,7 +32,18 @@ exec_ignition_gazebo_releasepy_test()
./release.py \
--dry-run \
--no-sanity-checks \
ign-gazebo 1.2.3 token ${test_params}""
ign-gazebo 1.2.3 token ${test_params}
}

exec_releasepy_with_real_gz()
{
gz_pkg=${1} major_version=${2}
./release.py \
--dry-run \
--no-sanity-checks \
--source-repo-uri http://github.com/gazebosim/gz-common \
--source-repo-existing-ref http://github.com/gazebosim/gz-common/foo-tag \
"${gz_pkg}" "${major_version}.x.y" token
}

expect_job_run()
Expand Down Expand Up @@ -73,35 +84,58 @@ expect_param()
echo "${param} not found in test output"
exit 1
fi
}

expect_vendor_repo()
{
output="${1}" repo="${2}"

if ! grep "Github ${repo}" <<< "${output}"; then
echo "${repo} not found in test output"
exit 1
fi
}

expect_no_vendor()
{
output="${1}"

if grep -q 'in ROS 2' <<< "${output}"; then
echo "ROS 2 string found in output"
exit 1
fi
}

source_repo_uri_test=$(exec_releasepy_test "--source-repo-uri https://github.com/gazebosim/gz-foo.git")
expect_job_run "${source_repo_uri_test}" "gz-foo-source"
expect_job_not_run "${source_repo_uri_test}" "gz-foo-debbuilder"
expect_number_of_jobs "${source_repo_uri_test}" "1"
expect_param "${source_repo_uri_test}" "SOURCE_REPO_URI=https%3A%2F%2Fgithub.com%2Fgazebosim%2Fgz-foo.git"
expect_no_vendor "${source_repo_uri_test}" # non existing package

source_tarball_uri_test=$(exec_releasepy_test "--source-tarball-uri https://gazebosim/gz-foo-1.2.3.tar.gz")
expect_job_run "${source_tarball_uri_test}" "gz-foo-debbuilder"
expect_job_run "${source_tarball_uri_test}" "generic-release-homebrew_pull_request_updater"
expect_job_not_run "${source_tarball_uri_test}" "gz-foo-source"
expect_number_of_jobs "${source_tarball_uri_test}" "7"
expect_param "${source_tarball_uri_test}" "SOURCE_TARBALL_URI=https%3A%2F%2Fgazebosim%2Fgz-foo-1.2.3.tar.gz"
expect_no_vendor "${source_tarball_uri_test}"

nightly_test=$(exec_releasepy_test "--nightly-src-branch my-nightly-branch3 --upload-to-repo nightly")
expect_job_run "${nightly_test}" "gz-foo-debbuilder"
expect_job_not_run "${nightly_test}" "generic-release-homebrew_pull_request_updater"
expect_job_not_run "${nightly_test}" "gz-foo-source"
expect_number_of_jobs "${nightly_test}" "2"
expect_param "${nightly_test}" "SOURCE_TARBALL_URI=my-nightly-branch3"
expect_no_vendor "${nightly_test}"

bump_linux_test=$(exec_releasepy_test "--source-tarball-uri https://gazebosim/gz-foo-1.2.3.tar.gz --only-bump-revision-linux -r 2")
expect_job_run "${bump_linux_test}" "gz-foo-debbuilder"
expect_job_not_run "${bump_linux_test}" "generic-release-homebrew_pull_request_updater"
expect_job_not_run "${bump_linux_test}" "gz-foo-source"
expect_number_of_jobs "${bump_linux_test}" "6"
expect_param "${bump_linux_test}" "RELEASE_VERSION=2"
expect_no_vendor "${bump_linux_test}"

ignition_test=$(exec_ignition_releasepy_test "--source-repo-uri https://github.com/gazebosim/gz-foo.git")
expect_job_run "${ignition_test}" "gz-foo-source"
Expand All @@ -128,3 +162,9 @@ expect_number_of_jobs "${ign_gazebo_source_tarball_uri_test}" "7"
expect_param "${ign_gazebo_source_tarball_uri_test}" "SOURCE_TARBALL_URI=https%3A%2F%2Fgazebosim%2Fign-gazebo-1.2.3.tar.gz"
expect_param "${ign_gazebo_source_tarball_uri_test}" "PACKAGE=ign-gazebo"
expect_param "${ign_gazebo_source_tarball_uri_test}" "PACKAGE_ALIAS=ignition-gazebo"

ros_vendor_test=$(exec_releasepy_with_real_gz gz-fuel-tools 9)
expect_vendor_repo "${ros_vendor_test}" gazebo-release/gz_fuel_tools_vendor

ros_vendor_test=$(exec_releasepy_with_real_gz gz-cmake 2)
expect_no_vendor "${bump_linux_test}"
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/python3

import sys
import yaml


# Function to find the collection name based on lib name and major version
def find_collection(data, lib_name, major_version):
instances = []

for collection in data['collections']:
for lib in collection['libs']:
if lib['name'] == lib_name and lib['major_version'] == major_version:
instances.append(collection['name'])
return instances


def get_major_version(version):
elements = version.split('.')
return int(elements[0])


if len(sys.argv) < 3:
print(f"Usage: {sys.argv[0]} <lib_name> <major_version> <collection-yaml-file>")
sys.exit(1)

lib_name = sys.argv[1]
version = sys.argv[2]
yaml_file = sys.argv[3]

with open(yaml_file, 'r') as file:
data = yaml.safe_load(file)

collection_names = find_collection(data, lib_name, get_major_version(version))
print(f"{' '.join(collection_names)}")
85 changes: 85 additions & 0 deletions release.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

from __future__ import print_function
from argparse import RawTextHelpFormatter
from tempfile import NamedTemporaryFile
from tempfile import TemporaryDirectory
import subprocess
import sys
import tempfile
Expand All @@ -22,6 +24,7 @@
LINUX_DISTROS = ['ubuntu', 'debian']
SUPPORTED_ARCHS = ['amd64', 'armhf', 'arm64']
RELEASEPY_NO_ARCH_PREFIX = '.releasepy_NO_ARCH_'
ROS_VENDOR = {'harmonic': 'rolling'}

OSRF_REPOS_SUPPORTED = "stable prerelease nightly testing none"

Expand Down Expand Up @@ -515,9 +518,82 @@ def display_help_job_chain_for_source_calls(args):
f'{releasepy_check_url}')


def get_collections_for_package(package_name, version):
script_directory = os.path.dirname(os.path.abspath(sys.argv[0]))
helper_script = f'{script_directory}/jenkins-scripts/dsl/tools/get_collections_from_package_and_version.py'
collection_yaml = f'{script_directory}/jenkins-scripts/dsl/gz-collections.yaml'
cmd = [helper_script,
get_canonical_package_name(package_name),
version,
collection_yaml]
_out, _err = check_call(cmd, IGNORE_DRY_RUN)
if _err:
print(f"An error happened running get_collections_from_package_and_version: {_err}")
sys.exit(1)
collection_list = _out.decode().strip().split(' ')
return collection_list


def get_vendor_github_repo(package_name):
canonical_name = get_canonical_package_name(package_name)
return f"gazebo-release/{canonical_name.replace('-', '_')}_vendor"


def get_vendor_repo_url(package_name):
return f"https://github.com/{get_vendor_github_repo(package_name)}"


def prepare_vendor_pr_temp_workspace(package_name):
pr_ws_dir = tempfile.mkdtemp()
gz_vendor_tool = os.path.join(pr_ws_dir, "gz_vendor")
cmd = ['git', 'clone', '-q',
'https://github.com/gazebo-tooling/gz_vendor/',
gz_vendor_tool]
_, _err_tool = check_call(cmd)
gz_vendor_repo = os.path.join(pr_ws_dir, 'gz_vendor_repo')
cmd = ['git', 'clone', '-q',
get_vendor_repo_url(package_name),
gz_vendor_repo]
_, _err_repo = check_call(cmd)
if _err_tool or _err_repo:
print("Problems with cloning vendor and tool repos:")
print(f"{_err_tool} {_err_repo}")
sys.exit(1)

return gz_vendor_tool, gz_vendor_repo


def execute_update_vendor_package_tool(vendor_tool_path, vendor_repo_path):
run_cmd = ['python3',
f"{vendor_tool_path}/create_gz_vendor_pkg/create_vendor_package.py",
'package.xml',
'--output_dir', vendor_repo_path]
_, _err_run = check_call(run_cmd)
if _err_run:
print("Problems running the create_vendor_package.py script:")
sys.exit(1)


def create_pr_in_gz_vendor_repo(args):
vendor_tool_path, vendor_repo_path = \
prepare_vendor_pr_temp_workspace(args.package)
execute_update_vendor_package_tool(
vendor_tool_path, vendor_repo_path)

cmd_diff = ['git', "-C", vendor_repo_path, 'diff']
_out, _ = check_call(cmd_diff)
print(vendor_repo_path)
print(_out.decode())




def go(argv):
args = parse_args(argv)

create_pr_in_gz_vendor_repo(args)
sys.exit(0)

# Default to release 1 if not present
if not args.release_version:
args.release_version = 1
Expand Down Expand Up @@ -641,6 +717,15 @@ def go(argv):
args.version)
display_help_job_chain_for_source_calls(args)

print("ROS vendor packages that can be updated:")
for collection in get_collections_for_package(args.package, args.version):
if collection in ROS_VENDOR:
ros_distro = ROS_VENDOR[collection]
print(f" * Github {get_vendor_github_repo(args.package)} "
f"part of {collection} in ROS 2 {ros_distro}")
issue_url = create_issue_in_gz_vendor_repo(args, ros_distro)
print(f" + Issue created: {issue_url}")


if __name__ == '__main__':
go(sys.argv)
Loading