From 9522729809b79f1d64e41bc1d2c6958a25bf50bf Mon Sep 17 00:00:00 2001 From: Tony Breeds Date: Thu, 15 Jun 2023 13:17:02 -0700 Subject: [PATCH] Add the branch to the release metadata In [1] we saw that releases on antelope are proposed as constraint updates on master. This is another case where series != release-id. Add meta:branch to the release metadata and use that when updating constraints [1] https://review.opendev.org/q/I369b2140ff3203d069530dcbabffb79cd29d859b Change-Id: Ic4ea185d54a7e82bcb9fae3c1291a4c3bb456f22 --- .../release-tools/process_release_requests.py | 19 ++++++++++++++++--- .../files/release-tools/release.sh | 2 ++ .../files/release-tools/update_constraints.sh | 6 +++--- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/roles/copy-release-tools-scripts/files/release-tools/process_release_requests.py b/roles/copy-release-tools-scripts/files/release-tools/process_release_requests.py index df60cfeb0e..0b039e1d9b 100755 --- a/roles/copy-release-tools-scripts/files/release-tools/process_release_requests.py +++ b/roles/copy-release-tools-scripts/files/release-tools/process_release_requests.py @@ -61,13 +61,13 @@ def find_modified_deliverable_files(reporoot): def tag_release(repo, series_name, version, diff_start, hash, - include_pypi_link, first_full_release, meta_data): + include_pypi_link, first_full_release, meta_data, branch_name): print('Tagging {} in {}'.format(version, repo)) try: subprocess.check_call( [RELEASE_SCRIPT, repo, series_name, version, diff_start, hash, include_pypi_link, - first_full_release, meta_data] + first_full_release, meta_data, branch_name] ) except subprocess.CalledProcessError: # The error output from the script will be printed to @@ -106,6 +106,17 @@ def load_series_status(reporoot): return series_status +def get_branch(series_status, series_name): + branch = None + for series in series_status: + if series.get("status") == "development": + branch = "master" + elif series.get("name") == series_name: + # Grab the release-id; then fall back to the supplied name + branch = "stable/" + series.get("release-id", series_name) + return branch + + def process_release_requests(reporoot, filenames, meta_data): """Return a sequence of tuples containing the new versions. @@ -147,6 +158,8 @@ def process_release_requests(reporoot, filenames, meta_data): os.path.dirname(os.path.abspath(filename)) ).lstrip('_') + branch_name = get_branch(series_status, series_name) + # If the series is closed, do not process the file. We're # likely updating old data in the releases repo and we do not # want to reprocess any old branches or tags. @@ -204,7 +217,7 @@ def process_release_requests(reporoot, filenames, meta_data): error_count += tag_release( project['repo'], series_name, version, diff_start, project['hash'], include_pypi_link, - first_full_release, meta_data, + first_full_release, meta_data, branch_name, ) # Create branches and adapt master diff --git a/roles/copy-release-tools-scripts/files/release-tools/release.sh b/roles/copy-release-tools-scripts/files/release-tools/release.sh index 019693c881..131d566385 100755 --- a/roles/copy-release-tools-scripts/files/release-tools/release.sh +++ b/roles/copy-release-tools-scripts/files/release-tools/release.sh @@ -42,6 +42,7 @@ SHA=$5 INCLUDE_PYPI=${6:-no} FIRST_FULL=${7:-no} EXTRA_METADATA="$8" +BRANCH="${9:-master}" SHORTNAME=`basename $REPO` @@ -77,6 +78,7 @@ else meta:version: $VERSION meta:diff-start: $DIFF_START meta:series: $SERIES +meta:branch: $BRANCH meta:release-type: $RELEASETYPE meta:pypi: $INCLUDE_PYPI meta:first: $FIRST_FULL diff --git a/roles/copy-release-tools-scripts/files/release-tools/update_constraints.sh b/roles/copy-release-tools-scripts/files/release-tools/update_constraints.sh index 2eeec80bfe..648e7abc77 100755 --- a/roles/copy-release-tools-scripts/files/release-tools/update_constraints.sh +++ b/roles/copy-release-tools-scripts/files/release-tools/update_constraints.sh @@ -68,8 +68,8 @@ function get_tag_meta { echo "$TAG_META" | grep "^meta:$fieldname:" | cut -f2 -d' ' } -# Find the series information from the tag metadata in the comment. -SERIES=$(get_tag_meta series) +# Find the branch information from the tag metadata in the comment. +BRANCH=$(get_tag_meta branch) # Pick up the repository name from the git URL. SHORTNAME=$(basename $(git config --local remote.origin.url)) @@ -105,7 +105,7 @@ else setup_temp_space update-constraints-$SHORTNAME # NOTE(dhellmann): clone_repo defaults to checking out master if # the named branch doesn't exist. - clone_repo openstack/requirements stable/$SERIES + clone_repo openstack/requirements $BRANCH cd openstack/requirements git checkout -b "$dist_name-$VERSION" # First try to update specific python_version entries