Skip to content

Commit

Permalink
Implement a test script for release.py
Browse files Browse the repository at this point in the history
Signed-off-by: Jose Luis Rivero <[email protected]>
  • Loading branch information
j-rivero committed Oct 26, 2023
1 parent a870d8c commit 4791392
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 19 deletions.
10 changes: 5 additions & 5 deletions check_releasepy.bash
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ 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}""
}

expect_job_run()
{
output="${1}" job="${2}"

if ! $(grep -q "job/${job}/buildWith" <<< "${output}"); then
if ! grep -q "job/${job}/buildWith" <<< "${output}"; then
echo "${job} not found in test output"
exit 1
fi
Expand All @@ -28,7 +28,7 @@ expect_job_not_run()
{
output="${1}" job="${2}"

if $(grep -q "job/${job}/buildWith" <<< "${output}"); then
if grep -q "job/${job}/buildWith" <<< "${output}"; then
echo "${job} found in test output. Should not appear."
exit 1
fi
Expand All @@ -38,7 +38,7 @@ expect_number_of_jobs()
{
output=${1} njobs=${2}

if [[ `grep "job/.*/buildWithParameters" <<< "${output}" | wc -l` != "${njobs}" ]]; then
if [[ $(grep -c "job/.*/buildWithParameters" <<< "${output}") != "${njobs}" ]]; then
echo "Number of jobs caled is not the expected ${njobs}"
exit 1
fi
Expand All @@ -48,7 +48,7 @@ expect_param()
{
output="${1}" param="${2}"

if ! $(grep -q "[&\?]${param}" <<< "${output}"); then
if ! grep -q "[&\?]${param}" <<< "${output}"; then
echo "${param} not found in test output"
exit 1
fi
Expand Down
32 changes: 18 additions & 14 deletions release.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,21 +181,25 @@ def get_release_repository_info(package):

error("release repository not found in github.com/gazebo-release")

def download_release_repository(package, release_branch):
vcs, url = get_release_repository_info(package)
release_tmp_dir = tempfile.mkdtemp()

if vcs == "git" and release_branch == "default":
release_branch = "master"

# If main branch exists, prefer it over master
if release_branch == "master":
if exists_main_branch(url):
release_branch = 'main'

cmd = [vcs, "clone", "-b", release_branch, url, release_tmp_dir]
check_call(cmd, IGNORE_DRY_RUN)
return release_tmp_dir, release_branch
def download_release_repository(package, release_branch):
try:
return os.environ['_RELEASEPY_TEST_RELEASE_REPO'], 'main'
except KeyError:
vcs, url = get_release_repository_info(package)
release_tmp_dir = tempfile.mkdtemp()

if vcs == "git" and release_branch == "default":
release_branch = "master"

# If main branch exists, prefer it over master
if release_branch == "master":
if exists_main_branch(url):
release_branch = 'main'

cmd = [vcs, "clone", "-b", release_branch, url, release_tmp_dir]
check_call(cmd, IGNORE_DRY_RUN)
return release_tmp_dir, release_branch


def sanity_package_name_underscore(package, package_alias):
Expand Down

0 comments on commit 4791392

Please sign in to comment.