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 6 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)}")
69 changes: 69 additions & 0 deletions release.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from __future__ import print_function
from argparse import RawTextHelpFormatter
from tempfile import NamedTemporaryFile
import subprocess
import sys
import tempfile
Expand All @@ -22,6 +23,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,6 +517,64 @@ 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 create_issue_in_repo(github_repo, title, body):
_out = b""
# For parsing the \n correctly we need to store the content in a temp
# file and pass it as --body-file
with NamedTemporaryFile("w", delete=True) as f:
f.write(body)
f.flush()
cmd = ['ghxx', 'issue', 'create',
'--repo', github_repo,
'--title', title,
'--body-file', f.name]
try:
_out, _err = check_call(cmd)
except Exception as e:
_err = str(e)
if DRY_RUN:
return f"http://github.com/{github_repo}/issues/#dry-run-no-number", ""
return _out.decode().replace('\n', ''), _err


def create_issue_in_gz_vendor_repo(args, ros_distro):
gz_vendor_repo = get_vendor_github_repo(args.package)
title = f'Update version for {ros_distro} to the latest tag of {args.package}: {args.version}'
body = f'The {get_canonical_package_name(args.package)} repository tagged a new: {args.version} '\
'This repository needs to be updated accordingly for the branch {ros_distro}:\n'\
' * Sync to the new version in CMakelists.txt \n'\
' * Bump the patch version in package.xml \n'\
' * Run the release process for this ROS package'
_out, _err = create_issue_in_repo(gz_vendor_repo, title, body)
if _err:
print(' !! An error happened running the "gh issue" cmd. Do not run this script again.\n'
' Please create the issue manually. The error reported was:\n'
f' {_err}')
sys.exit(1)
return _out
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to create a pull request instead? All we have to do is run https://github.com/gazebo-tooling/gz_vendor/blob/main/create_gz_vendor_pkg/create_vendor_package.py and give it the up-to-date package.xml from the upstream Gazebo library.



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

Expand Down Expand Up @@ -641,6 +701,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