From 449657db9c7e25305c6e05a64cac4d06beba8754 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Thu, 30 Oct 2025 12:54:16 +0100 Subject: [PATCH 01/23] adapt branch-is-up-to-date-with-target-pre script to use ivas-codec repo --- .../branch-is-up-to-date-with-target-pre.sh | 30 ++++++++++++++----- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/snippets/basop/branch-is-up-to-date-with-target-pre.sh b/snippets/basop/branch-is-up-to-date-with-target-pre.sh index 08a0b8b..7bda5b7 100644 --- a/snippets/basop/branch-is-up-to-date-with-target-pre.sh +++ b/snippets/basop/branch-is-up-to-date-with-target-pre.sh @@ -30,22 +30,22 @@ set -euxo pipefail -float_ref_branchname="ivas-float-update" +URL_FLOAT_REPO="https://forge.3gpp.org/rep/ivas-codec-pc/ivas-codec.git" +FLOAT_DIR="ivas-codec" + +float_ref_branchname_in_ivas_codec="main" exit_code_follows_naming_conventions=0 # if branch does not follow the convention, there will be a printout which is irrelevant here, so redirect it to null bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/branch-follows-porting-naming-convention.sh $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME >>/dev/null || exit_code_follows_naming_conventions=$? # if this branch follows the naming convetions, we can try to get the corresponding float MR branch # if this branch does NOT follow the porting naming convention, the float ref is just ivas-float-update, so skip everything if [[ "$exit_code_follows_naming_conventions" == "0" ]]; then - float_ref_branchname=$(${CI_PROJECT_DIR}/ivas-codec-ci/snippets/basop/get-float-ref-branch-name.sh $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME) + float_ref_branchname_in_ivas_codec=$(${CI_PROJECT_DIR}/ivas-codec-ci/snippets/basop/get-float-ref-branch-name.sh $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME) fi -# fetch all needed branches +# fetch merge target and check if we are up-to-date git fetch origin "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" -git fetch origin ivas-float-update -git fetch origin "$float_ref_branchname" -# then check if we are behind the merge target commits_behind_count="$(bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/get-commits-behind-count.sh)" if [ $commits_behind_count -ne 0 ]; then echo -e "Your branch is $commits_behind_count commits behind the target branch, run\n\tgit pull origin $CI_MERGE_REQUEST_TARGET_BRANCH_NAME\nto update." @@ -60,11 +60,25 @@ MERGE_TARGET_COMMIT="$(git rev-parse "origin/$CI_MERGE_REQUEST_TARGET_BRANCH_NAM echo "MERGE_TARGET_COMMIT is $MERGE_TARGET_COMMIT" echo "$MERGE_TARGET_COMMIT" >"$MERGE_TARGET_COMMIT_FILE" -MERGE_SOURCE_FLOAT_REF_COMMIT="$(git rev-parse "origin/$float_ref_branchname")" +set -x + +# to get the commit SHAs for the float reference branches, we need to clone the repo here +git clone $URL_FLOAT_REPO $FLOAT_DIR + +# below here we will be in the float repo! +cd $FLOAT_DIR + +# only fetch ref branch, main is the default branch +git fetch origin "$float_ref_branchname_in_ivas_codec" + +# stop echoing from here on, this is anyway only dbg printout +set +x + +MERGE_SOURCE_FLOAT_REF_COMMIT="$(git rev-parse "origin/$float_ref_branchname_in_ivas_codec")" echo "MERGE_SOURCE_FLOAT_REF_COMMIT is $MERGE_SOURCE_FLOAT_REF_COMMIT" echo "$MERGE_SOURCE_FLOAT_REF_COMMIT" >"$MERGE_SOURCE_FLOAT_REF_COMMIT_FILE" -FLOAT_REF_COMMIT="$(git rev-parse "origin/ivas-float-update")" +FLOAT_REF_COMMIT="$(git rev-parse "origin/main")" echo "FLOAT_REF_COMMIT is $FLOAT_REF_COMMIT" echo "$FLOAT_REF_COMMIT" >"$FLOAT_REF_COMMIT_FILE" -- GitLab From cf873d019a8f39ec2f7233a0bd5c95512f32a8f4 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Thu, 30 Oct 2025 13:07:33 +0100 Subject: [PATCH 02/23] do shallow clone for speed up --- snippets/basop/branch-is-up-to-date-with-target-pre.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snippets/basop/branch-is-up-to-date-with-target-pre.sh b/snippets/basop/branch-is-up-to-date-with-target-pre.sh index 7bda5b7..da27711 100644 --- a/snippets/basop/branch-is-up-to-date-with-target-pre.sh +++ b/snippets/basop/branch-is-up-to-date-with-target-pre.sh @@ -63,7 +63,7 @@ echo "$MERGE_TARGET_COMMIT" >"$MERGE_TARGET_COMMIT_FILE" set -x # to get the commit SHAs for the float reference branches, we need to clone the repo here -git clone $URL_FLOAT_REPO $FLOAT_DIR +git clone $URL_FLOAT_REPO $FLOAT_DIR --depth 1 # below here we will be in the float repo! cd $FLOAT_DIR -- GitLab From f935bbdae4285872b4387057a223a64ea4e8c7f9 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Thu, 30 Oct 2025 13:21:12 +0100 Subject: [PATCH 03/23] change float ref branch name in script --- snippets/basop/get-float-ref-branch-name.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/snippets/basop/get-float-ref-branch-name.sh b/snippets/basop/get-float-ref-branch-name.sh index b1c2098..6c1d5d1 100755 --- a/snippets/basop/get-float-ref-branch-name.sh +++ b/snippets/basop/get-float-ref-branch-name.sh @@ -39,7 +39,8 @@ if [ $# -ne 1 ]; then fi branchname_in="$1" -branchname_out="ivas-float-update" +# Note: this is ivas-codec ("float") main +branchname_out="main" # The float ref branch is just the same name, but with basop -> ref replacement # Replace only the first occurrence, as "basop" may be present in the later description -- GitLab From 1d6540058385e5904edc45fd8e48503d95d355ad Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Mon, 17 Nov 2025 14:18:11 +0100 Subject: [PATCH 04/23] use existing cloned dir on runner --- main-basop.yml | 1 + .../basop/branch-is-up-to-date-with-target-pre.sh | 11 ++++------- snippets/basop/update-scripts-repo.sh | 8 +++++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/main-basop.yml b/main-basop.yml index 003f2d5..885de5d 100644 --- a/main-basop.yml +++ b/main-basop.yml @@ -851,6 +851,7 @@ branch-is-up-to-date-with-target-pre: tags: - ivas-basop-linux script: + - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/update-scripts-repo.sh - source "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/branch-is-up-to-date-with-target-pre.sh artifacts: paths: diff --git a/snippets/basop/branch-is-up-to-date-with-target-pre.sh b/snippets/basop/branch-is-up-to-date-with-target-pre.sh index da27711..686668a 100644 --- a/snippets/basop/branch-is-up-to-date-with-target-pre.sh +++ b/snippets/basop/branch-is-up-to-date-with-target-pre.sh @@ -31,7 +31,6 @@ set -euxo pipefail URL_FLOAT_REPO="https://forge.3gpp.org/rep/ivas-codec-pc/ivas-codec.git" -FLOAT_DIR="ivas-codec" float_ref_branchname_in_ivas_codec="main" exit_code_follows_naming_conventions=0 @@ -62,14 +61,12 @@ echo "$MERGE_TARGET_COMMIT" >"$MERGE_TARGET_COMMIT_FILE" set -x -# to get the commit SHAs for the float reference branches, we need to clone the repo here -git clone $URL_FLOAT_REPO $FLOAT_DIR --depth 1 - +# to get the commit SHAs for the float reference branches, we need to get the main branch from float repo # below here we will be in the float repo! -cd $FLOAT_DIR - -# only fetch ref branch, main is the default branch +cd "${SCRIPTS_DIR}" +git remote set-branches --add origin "$float_ref_branchname_in_ivas_codec" git fetch origin "$float_ref_branchname_in_ivas_codec" +git checkout "$float_ref_branchname_in_ivas_codec" # stop echoing from here on, this is anyway only dbg printout set +x diff --git a/snippets/basop/update-scripts-repo.sh b/snippets/basop/update-scripts-repo.sh index 1a4a21d..47a1cb8 100755 --- a/snippets/basop/update-scripts-repo.sh +++ b/snippets/basop/update-scripts-repo.sh @@ -6,11 +6,13 @@ cd "${CI_PROJECT_DIR}" pushd "${SCRIPTS_DIR}" - # Remove all fetch lines to clean out dead links +# Remove all fetch lines to clean out dead links sed -i '/fetch/d' .git/config -# Add currently used branch -git remote set-branches --add origin "$BASOP_CI_BRANCH_PC_REPO" +# Add currently used branches: +# - BASOP_CI_BRANCH_PC_REPO for scripts/tests +# - main for getting the float ref codec +git remote set-branches --add origin "$BASOP_CI_BRANCH_PC_REPO" main git fetch -- GitLab From 9a2522b473c53ffae2c2956d74fd5c9c04d42fbf Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Mon, 17 Nov 2025 14:21:16 +0100 Subject: [PATCH 05/23] use pull to actually get latest commit --- snippets/basop/branch-is-up-to-date-with-target-pre.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snippets/basop/branch-is-up-to-date-with-target-pre.sh b/snippets/basop/branch-is-up-to-date-with-target-pre.sh index 686668a..1bee9fd 100644 --- a/snippets/basop/branch-is-up-to-date-with-target-pre.sh +++ b/snippets/basop/branch-is-up-to-date-with-target-pre.sh @@ -65,7 +65,7 @@ set -x # below here we will be in the float repo! cd "${SCRIPTS_DIR}" git remote set-branches --add origin "$float_ref_branchname_in_ivas_codec" -git fetch origin "$float_ref_branchname_in_ivas_codec" +git pull "$float_ref_branchname_in_ivas_codec" git checkout "$float_ref_branchname_in_ivas_codec" # stop echoing from here on, this is anyway only dbg printout -- GitLab From 21eccfb6b77cf0f3193caa358061c864226393fe Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Mon, 17 Nov 2025 14:22:37 +0100 Subject: [PATCH 06/23] fix commands --- snippets/basop/branch-is-up-to-date-with-target-pre.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/snippets/basop/branch-is-up-to-date-with-target-pre.sh b/snippets/basop/branch-is-up-to-date-with-target-pre.sh index 1bee9fd..fd9907a 100644 --- a/snippets/basop/branch-is-up-to-date-with-target-pre.sh +++ b/snippets/basop/branch-is-up-to-date-with-target-pre.sh @@ -65,8 +65,9 @@ set -x # below here we will be in the float repo! cd "${SCRIPTS_DIR}" git remote set-branches --add origin "$float_ref_branchname_in_ivas_codec" -git pull "$float_ref_branchname_in_ivas_codec" +git fetch origin "$float_ref_branchname_in_ivas_codec" git checkout "$float_ref_branchname_in_ivas_codec" +git pull # stop echoing from here on, this is anyway only dbg printout set +x -- GitLab From b907638f6240bbe5a5ba949faa576f3af9c74df2 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Mon, 17 Nov 2025 14:29:14 +0100 Subject: [PATCH 07/23] consolidate git SHA printouts --- .../branch-is-up-to-date-with-target-pre.sh | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/snippets/basop/branch-is-up-to-date-with-target-pre.sh b/snippets/basop/branch-is-up-to-date-with-target-pre.sh index fd9907a..eb6eecf 100644 --- a/snippets/basop/branch-is-up-to-date-with-target-pre.sh +++ b/snippets/basop/branch-is-up-to-date-with-target-pre.sh @@ -51,16 +51,9 @@ if [ $commits_behind_count -ne 0 ]; then exit 1 fi -# stop echoing from here on, this is anyway only dbg printout -set +x +# if we are up-to-date, store the commit SHA for all branches -# if we are up-to-date, store the commit SHA's for all branches MERGE_TARGET_COMMIT="$(git rev-parse "origin/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME")" -echo "MERGE_TARGET_COMMIT is $MERGE_TARGET_COMMIT" -echo "$MERGE_TARGET_COMMIT" >"$MERGE_TARGET_COMMIT_FILE" - -set -x - # to get the commit SHAs for the float reference branches, we need to get the main branch from float repo # below here we will be in the float repo! cd "${SCRIPTS_DIR}" @@ -69,14 +62,18 @@ git fetch origin "$float_ref_branchname_in_ivas_codec" git checkout "$float_ref_branchname_in_ivas_codec" git pull +MERGE_SOURCE_FLOAT_REF_COMMIT="$(git rev-parse "origin/$float_ref_branchname_in_ivas_codec")" +FLOAT_REF_COMMIT="$(git rev-parse "origin/main")" + # stop echoing from here on, this is anyway only dbg printout -set +x +#set +x + +echo "MERGE_TARGET_COMMIT is $MERGE_TARGET_COMMIT" +echo "$MERGE_TARGET_COMMIT" >"$MERGE_TARGET_COMMIT_FILE" -MERGE_SOURCE_FLOAT_REF_COMMIT="$(git rev-parse "origin/$float_ref_branchname_in_ivas_codec")" echo "MERGE_SOURCE_FLOAT_REF_COMMIT is $MERGE_SOURCE_FLOAT_REF_COMMIT" echo "$MERGE_SOURCE_FLOAT_REF_COMMIT" >"$MERGE_SOURCE_FLOAT_REF_COMMIT_FILE" -FLOAT_REF_COMMIT="$(git rev-parse "origin/main")" echo "FLOAT_REF_COMMIT is $FLOAT_REF_COMMIT" echo "$FLOAT_REF_COMMIT" >"$FLOAT_REF_COMMIT_FILE" -- GitLab From 930d529f0c8fe0e8ce2d18c8cbd1d5c59de2bbd4 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Mon, 17 Nov 2025 14:35:41 +0100 Subject: [PATCH 08/23] fix artifact creation in correct directory improver commit printouts --- .../basop/branch-is-up-to-date-with-target-pre.sh | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/snippets/basop/branch-is-up-to-date-with-target-pre.sh b/snippets/basop/branch-is-up-to-date-with-target-pre.sh index eb6eecf..02cb14d 100644 --- a/snippets/basop/branch-is-up-to-date-with-target-pre.sh +++ b/snippets/basop/branch-is-up-to-date-with-target-pre.sh @@ -56,7 +56,7 @@ fi MERGE_TARGET_COMMIT="$(git rev-parse "origin/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME")" # to get the commit SHAs for the float reference branches, we need to get the main branch from float repo # below here we will be in the float repo! -cd "${SCRIPTS_DIR}" +pushd "${SCRIPTS_DIR}" git remote set-branches --add origin "$float_ref_branchname_in_ivas_codec" git fetch origin "$float_ref_branchname_in_ivas_codec" git checkout "$float_ref_branchname_in_ivas_codec" @@ -64,17 +64,20 @@ git pull MERGE_SOURCE_FLOAT_REF_COMMIT="$(git rev-parse "origin/$float_ref_branchname_in_ivas_codec")" FLOAT_REF_COMMIT="$(git rev-parse "origin/main")" +popd # stop echoing from here on, this is anyway only dbg printout -#set +x +set +x -echo "MERGE_TARGET_COMMIT is $MERGE_TARGET_COMMIT" +echo "CI_COMMIT_SHA (this branch) is $CI_COMMIT_SHA" + +echo "MERGE_TARGET_COMMIT (on branch $CI_MERGE_REQUEST_TARGET_BRANCH_NAME) is $MERGE_TARGET_COMMIT" echo "$MERGE_TARGET_COMMIT" >"$MERGE_TARGET_COMMIT_FILE" -echo "MERGE_SOURCE_FLOAT_REF_COMMIT is $MERGE_SOURCE_FLOAT_REF_COMMIT" +echo "MERGE_SOURCE_FLOAT_REF_COMMIT (on branch $float_ref_branchname_in_ivas_codec in ivas-codec repo) is $MERGE_SOURCE_FLOAT_REF_COMMIT" echo "$MERGE_SOURCE_FLOAT_REF_COMMIT" >"$MERGE_SOURCE_FLOAT_REF_COMMIT_FILE" -echo "FLOAT_REF_COMMIT is $FLOAT_REF_COMMIT" +echo "FLOAT_REF_COMMIT (on branch main in ivas-codec repo) is $FLOAT_REF_COMMIT" echo "$FLOAT_REF_COMMIT" >"$FLOAT_REF_COMMIT_FILE" # create commits.env file for passing the variables to other jobs -- GitLab From 6eb6b216c929521b010f034e422d454f56978dec Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Mon, 17 Nov 2025 14:43:21 +0100 Subject: [PATCH 09/23] refine printout --- snippets/basop/branch-is-up-to-date-with-target-pre.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snippets/basop/branch-is-up-to-date-with-target-pre.sh b/snippets/basop/branch-is-up-to-date-with-target-pre.sh index 02cb14d..7d8b352 100644 --- a/snippets/basop/branch-is-up-to-date-with-target-pre.sh +++ b/snippets/basop/branch-is-up-to-date-with-target-pre.sh @@ -69,7 +69,7 @@ popd # stop echoing from here on, this is anyway only dbg printout set +x -echo "CI_COMMIT_SHA (this branch) is $CI_COMMIT_SHA" +echo "CI_COMMIT_SHA (on this branch $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME) is $CI_COMMIT_SHA" echo "MERGE_TARGET_COMMIT (on branch $CI_MERGE_REQUEST_TARGET_BRANCH_NAME) is $MERGE_TARGET_COMMIT" echo "$MERGE_TARGET_COMMIT" >"$MERGE_TARGET_COMMIT_FILE" -- GitLab From 1949b7d6cb90507b58cd7eb35dfc4d1596977748 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Mon, 17 Nov 2025 14:51:17 +0100 Subject: [PATCH 10/23] check for float companion branch in float repo --- snippets/basop/get-float-ref-branch-name.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/snippets/basop/get-float-ref-branch-name.sh b/snippets/basop/get-float-ref-branch-name.sh index 6c1d5d1..fed4300 100755 --- a/snippets/basop/get-float-ref-branch-name.sh +++ b/snippets/basop/get-float-ref-branch-name.sh @@ -46,10 +46,17 @@ branchname_out="main" # Replace only the first occurrence, as "basop" may be present in the later description # If the format is correct, then before "_basop", only numbers can occur float_ref_branchname="${branchname_in/basop/ref}" -git_result=$(git branch -a) + +# now check in ivas-codec repository if a branch with this name exits +exit_code_ls_remote=0 +pushd "${SCRIPTS_DIR}" +git fetch origin +git ls-remote --exit-code --heads origin res/heads/$float_ref_branchname || exit_code_ls_remote=$? +popd # If the branch does not exist, default to "ivas-float-update" -if [[ "$git_result" =~ "$float_ref_branchname" ]]; then +# NOTE: "git ls-remote --exit-code" returns 2 if the given ref was not found +if [ "$exit_code_ls_remote" -eq "2" ]; then branchname_out="${float_ref_branchname}" fi -- GitLab From 0db3f3c93b2004d07bc20998d2b91d558261090e Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Mon, 17 Nov 2025 14:52:52 +0100 Subject: [PATCH 11/23] fix typo --- snippets/basop/get-float-ref-branch-name.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snippets/basop/get-float-ref-branch-name.sh b/snippets/basop/get-float-ref-branch-name.sh index fed4300..f1b403e 100755 --- a/snippets/basop/get-float-ref-branch-name.sh +++ b/snippets/basop/get-float-ref-branch-name.sh @@ -51,7 +51,7 @@ float_ref_branchname="${branchname_in/basop/ref}" exit_code_ls_remote=0 pushd "${SCRIPTS_DIR}" git fetch origin -git ls-remote --exit-code --heads origin res/heads/$float_ref_branchname || exit_code_ls_remote=$? +git ls-remote --exit-code --heads origin refs/heads/$float_ref_branchname || exit_code_ls_remote=$? popd # If the branch does not exist, default to "ivas-float-update" -- GitLab From f750c29b3369a49a7fc60c13571584efea12cdf0 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Mon, 17 Nov 2025 15:06:06 +0100 Subject: [PATCH 12/23] fix ref name in check-float-ref-companion-branch-exits... --- ...-companion-branch-exists-for-porting-merge-requests.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/snippets/basop/check-float-ref-companion-branch-exists-for-porting-merge-requests.sh b/snippets/basop/check-float-ref-companion-branch-exists-for-porting-merge-requests.sh index 9ed3ae8..5f72ab8 100644 --- a/snippets/basop/check-float-ref-companion-branch-exists-for-porting-merge-requests.sh +++ b/snippets/basop/check-float-ref-companion-branch-exists-for-porting-merge-requests.sh @@ -28,13 +28,13 @@ # accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and # the United Nations Convention on Contracts on the International Sales of Goods. -set -euo pipefail - MSG_NO_FLOAT_REF_BRANCH_FOUND="Your branch name %s looks like it is a porting MR, but there is no corresponding float merge request (%s). If this is intended (nothing to port to ivas-float-update), simply ignore this warning. If there should be a float ref branch for this MR, please check your spelling on your other branch and make sure that you pushed it.\n " +set -euxo pipefail + exit_code_is_porting_mr=0 bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/branch-follows-porting-naming-convention.sh "$CI_COMMIT_REF_NAME" || exit_code_is_porting_mr=$? @@ -43,9 +43,9 @@ if [ "$exit_code_is_porting_mr" == "1" ]; then exit 0 fi -# if this does indeed look like a porting branch, get the float companion branch - if that is ivas-float-update, then warn about possible typo/missing branch +# if this does indeed look like a porting branch, get the float companion branch - if that is the default, then warn about possible typo/missing branch float_ref_branchname=$(${CI_PROJECT_DIR}/ivas-codec-ci/snippets/basop/get-float-ref-branch-name.sh $CI_COMMIT_REF_NAME) -if [ "$float_ref_branchname" == "ivas-float-update" ]; then +if [ "$float_ref_branchname" == "main" ]; then expected_float_ref_branch="${CI_COMMIT_REF_NAME/basop/ref}" printf "$MSG_NO_FLOAT_REF_BRANCH_FOUND" "$CI_COMMIT_REF_NAME" "$expected_float_ref_branch" exit 123 -- GitLab From 029abfefcc99fcc79ff88f4d196fc414a8d3092b Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Mon, 17 Nov 2025 15:09:43 +0100 Subject: [PATCH 13/23] redirect printouts --- snippets/basop/get-float-ref-branch-name.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/snippets/basop/get-float-ref-branch-name.sh b/snippets/basop/get-float-ref-branch-name.sh index f1b403e..7acf63f 100755 --- a/snippets/basop/get-float-ref-branch-name.sh +++ b/snippets/basop/get-float-ref-branch-name.sh @@ -50,8 +50,8 @@ float_ref_branchname="${branchname_in/basop/ref}" # now check in ivas-codec repository if a branch with this name exits exit_code_ls_remote=0 pushd "${SCRIPTS_DIR}" -git fetch origin -git ls-remote --exit-code --heads origin refs/heads/$float_ref_branchname || exit_code_ls_remote=$? +git fetch origin >>/dev/null +git ls-remote --exit-code --heads origin refs/heads/$float_ref_branchname >>/dev/null || exit_code_ls_remote=$? popd # If the branch does not exist, default to "ivas-float-update" -- GitLab From 0bfb48a1c06e534fcb80f63fe15991660b6be49f Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Mon, 17 Nov 2025 15:25:52 +0100 Subject: [PATCH 14/23] fix printout redirection in script --- snippets/basop/get-float-ref-branch-name.sh | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/snippets/basop/get-float-ref-branch-name.sh b/snippets/basop/get-float-ref-branch-name.sh index 7acf63f..1896997 100755 --- a/snippets/basop/get-float-ref-branch-name.sh +++ b/snippets/basop/get-float-ref-branch-name.sh @@ -28,11 +28,12 @@ # accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and # the United Nations Convention on Contracts on the International Sales of Goods. -# NOTE: this does not check e.g. for float_ref_branchname actually existing and will silently return ivas-float-update if not -# Use branch-follows-porting-naming-convention.sh for that - set -euo pipefail +# in this snippet, always print stuff to stderr and ONLY the final echo with of branchname_out should go to stdout +exec 3>&1 # save stdout on file desc 3 +exec 1>&2 # send all stdout to stderr + if [ $# -ne 1 ]; then echo "Usage: $0 " exit 1 @@ -50,8 +51,8 @@ float_ref_branchname="${branchname_in/basop/ref}" # now check in ivas-codec repository if a branch with this name exits exit_code_ls_remote=0 pushd "${SCRIPTS_DIR}" -git fetch origin >>/dev/null -git ls-remote --exit-code --heads origin refs/heads/$float_ref_branchname >>/dev/null || exit_code_ls_remote=$? +git fetch origin +git ls-remote --exit-code --heads origin refs/heads/$float_ref_branchname || exit_code_ls_remote=$? popd # If the branch does not exist, default to "ivas-float-update" @@ -60,5 +61,5 @@ if [ "$exit_code_ls_remote" -eq "2" ]; then branchname_out="${float_ref_branchname}" fi -echo "$branchname_out" +printf '%s\n' "$branchname_out" >&3 exit 0 -- GitLab From 3b114fa4ef28713c3cc1d72c96dce4fbbb25704d Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Mon, 17 Nov 2025 15:27:59 +0100 Subject: [PATCH 15/23] fix logic of conditional --- snippets/basop/get-float-ref-branch-name.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snippets/basop/get-float-ref-branch-name.sh b/snippets/basop/get-float-ref-branch-name.sh index 1896997..19b92dd 100755 --- a/snippets/basop/get-float-ref-branch-name.sh +++ b/snippets/basop/get-float-ref-branch-name.sh @@ -57,7 +57,7 @@ popd # If the branch does not exist, default to "ivas-float-update" # NOTE: "git ls-remote --exit-code" returns 2 if the given ref was not found -if [ "$exit_code_ls_remote" -eq "2" ]; then +if [ "$exit_code_ls_remote" -eq "0" ]; then branchname_out="${float_ref_branchname}" fi -- GitLab From 2cf3496f934a7871dc2a2cc597ecf5be062ef27a Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Mon, 17 Nov 2025 15:29:18 +0100 Subject: [PATCH 16/23] un-double final printout --- ...oat-ref-companion-branch-exists-for-porting-merge-requests.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/snippets/basop/check-float-ref-companion-branch-exists-for-porting-merge-requests.sh b/snippets/basop/check-float-ref-companion-branch-exists-for-porting-merge-requests.sh index 5f72ab8..2af0033 100644 --- a/snippets/basop/check-float-ref-companion-branch-exists-for-porting-merge-requests.sh +++ b/snippets/basop/check-float-ref-companion-branch-exists-for-porting-merge-requests.sh @@ -47,6 +47,7 @@ fi float_ref_branchname=$(${CI_PROJECT_DIR}/ivas-codec-ci/snippets/basop/get-float-ref-branch-name.sh $CI_COMMIT_REF_NAME) if [ "$float_ref_branchname" == "main" ]; then expected_float_ref_branch="${CI_COMMIT_REF_NAME/basop/ref}" + set +x printf "$MSG_NO_FLOAT_REF_BRANCH_FOUND" "$CI_COMMIT_REF_NAME" "$expected_float_ref_branch" exit 123 fi -- GitLab From 4a4f9bb0ba4215adf2410d3806be95be712debfe Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Mon, 17 Nov 2025 15:46:58 +0100 Subject: [PATCH 17/23] build reference codec from ivas-codec repo --- .../basop/activate-debug-mode-info-if-set.sh | 2 -- snippets/basop/build-binaries.sh | 34 ++++++++++++------- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/snippets/basop/activate-debug-mode-info-if-set.sh b/snippets/basop/activate-debug-mode-info-if-set.sh index 589d8e4..261dbc0 100755 --- a/snippets/basop/activate-debug-mode-info-if-set.sh +++ b/snippets/basop/activate-debug-mode-info-if-set.sh @@ -2,8 +2,6 @@ set -euxo pipefail -cd "${CI_PROJECT_DIR}" - if [ "$BUILD_WITH_DEBUG_MODE_INFO" = "true" ]; then sed -i.bak -e "s/\/\*\ *\(#define\ *DEBUGGING\ *\)\*\//\1/g" lib_com/options.h sed -i.bak -e "s/\/\*\ *\(#define\ *DEBUG_MODE_INFO\ *\)\*\//\1/g" lib_com/options.h diff --git a/snippets/basop/build-binaries.sh b/snippets/basop/build-binaries.sh index d1eb687..f19ca38 100755 --- a/snippets/basop/build-binaries.sh +++ b/snippets/basop/build-binaries.sh @@ -2,13 +2,12 @@ set -euxo pipefail -cd "${CI_PROJECT_DIR}" - mode="${1:-}" case "$mode" in float-ref) ref_to_check_out="$FLOAT_REF_COMMIT" + working_dir="$SCRIPTS_DIR" ivas_cod_filename="./$REF_ENCODER_PATH_FOR_BUILD_DO_NOT_MODIFY" ivas_dec_filename="./$REF_DECODER_PATH_FOR_BUILD_DO_NOT_MODIFY" ivas_rend_filename="./$REF_RENDERER_PATH_FOR_BUILD_DO_NOT_MODIFY" @@ -17,6 +16,7 @@ float-ref) ;; float-ref-merge-source) ref_to_check_out="$MERGE_SOURCE_FLOAT_REF_COMMIT" + working_dir="$SCRIPTS_DIR" ivas_cod_filename="./$MERGE_SOURCE_FLOAT_REF_ENCODER_PATH_FOR_BUILD_DO_NOT_MODIFY" ivas_dec_filename="./$MERGE_SOURCE_FLOAT_REF_DECODER_PATH_FOR_BUILD_DO_NOT_MODIFY" ivas_rend_filename="./$MERGE_SOURCE_FLOAT_REF_RENDERER_PATH_FOR_BUILD_DO_NOT_MODIFY" @@ -25,6 +25,7 @@ float-ref-merge-source) ;; merge-target) ref_to_check_out="$MERGE_TARGET_COMMIT" + working_dir="$CI_PROJECT_DIR" ivas_cod_filename="./$MERGE_TARGET_ENCODER_PATH_FOR_BUILD_DO_NOT_MODIFY" ivas_dec_filename="./$MERGE_TARGET_DECODER_PATH_FOR_BUILD_DO_NOT_MODIFY" ivas_rend_filename="./$MERGE_TARGET_RENDERER_PATH_FOR_BUILD_DO_NOT_MODIFY" @@ -33,6 +34,7 @@ merge-target) ;; dut) ref_to_check_out="$CI_COMMIT_SHA" + working_dir="$CI_PROJECT_DIR" ivas_cod_filename="./$DUT_ENCODER_PATH_FOR_BUILD_DO_NOT_MODIFY" ivas_dec_filename="./$DUT_DECODER_PATH_FOR_BUILD_DO_NOT_MODIFY" ivas_rend_filename="./$DUT_RENDERER_PATH_FOR_BUILD_DO_NOT_MODIFY" @@ -47,14 +49,12 @@ esac echo "Building $mode binaries from branch $ref_to_check_out" -current_commit_sha="$(git rev-parse HEAD)" +# for float ref stuff, we need the ivas-codec repo which is persistently stored on the runners +# working_dir is set as per input argument +pushd "$working_dir" -restore_stash() { - if [[ "$(git stash list)" != "" ]]; then - git stash pop - fi -} -trap restore_stash EXIT +# the git SHA and stash restoring mechanisms is not really necessary for float-ref branches, but also should not harm, so no if here +current_commit_sha="$(git rev-parse HEAD)" # store potential changes # should never fail, even if there is nothing to be stored @@ -68,12 +68,20 @@ make clean make -j "$(nproc)" # avoid errors in mv when renaming to same file -mv IVAS_cod "$ivas_cod_filename" -mv IVAS_dec "$ivas_dec_filename" -mv IVAS_rend "$ivas_rend_filename" -if [ -f ISAR_post_rend ]; then mv ISAR_post_rend "$isar_post_rend_filename"; fi +mv IVAS_cod "${CI_PROJECT_DIR}/${ivas_cod_filename}" +mv IVAS_dec "${CI_PROJECT_DIR}/${ivas_dec_filename}" +mv IVAS_rend "${CI_PROJECT_DIR}/${ivas_rend_filename}" +mv ISAR_post_rend "${CI_PROJECT_DIR}/${isar_post_rend_filename}" # return to current branch git restore . git rev-parse HEAD >"$commit_file" git checkout "$current_commit_sha" + +# this used to be a TRAP for EXIT before, but now with the popd at the end, we might not be in the corresponding git repo anymore at EXIT +# instead, this is called manually here now +if [[ "$(git stash list)" != "" ]]; then + git stash pop +fi + +popd -- GitLab From ae5bdd9bf0dd83dae4dfa1813e263de6dcf28dcc Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Mon, 17 Nov 2025 17:28:02 +0100 Subject: [PATCH 18/23] remove unnecessary pull commit is checked on the remote ref anyway --- snippets/basop/branch-is-up-to-date-with-target-pre.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/snippets/basop/branch-is-up-to-date-with-target-pre.sh b/snippets/basop/branch-is-up-to-date-with-target-pre.sh index 7d8b352..4a29190 100644 --- a/snippets/basop/branch-is-up-to-date-with-target-pre.sh +++ b/snippets/basop/branch-is-up-to-date-with-target-pre.sh @@ -60,7 +60,6 @@ pushd "${SCRIPTS_DIR}" git remote set-branches --add origin "$float_ref_branchname_in_ivas_codec" git fetch origin "$float_ref_branchname_in_ivas_codec" git checkout "$float_ref_branchname_in_ivas_codec" -git pull MERGE_SOURCE_FLOAT_REF_COMMIT="$(git rev-parse "origin/$float_ref_branchname_in_ivas_codec")" FLOAT_REF_COMMIT="$(git rev-parse "origin/main")" -- GitLab From f6788b23c2890beefe4ab3280a44b3d233f11942 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Mon, 17 Nov 2025 17:56:49 +0100 Subject: [PATCH 19/23] cleanup --- snippets/basop/branch-is-up-to-date-with-target-pre.sh | 3 --- snippets/basop/get-float-ref-branch-name.sh | 4 ++-- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/snippets/basop/branch-is-up-to-date-with-target-pre.sh b/snippets/basop/branch-is-up-to-date-with-target-pre.sh index 4a29190..8ec1d8c 100644 --- a/snippets/basop/branch-is-up-to-date-with-target-pre.sh +++ b/snippets/basop/branch-is-up-to-date-with-target-pre.sh @@ -30,8 +30,6 @@ set -euxo pipefail -URL_FLOAT_REPO="https://forge.3gpp.org/rep/ivas-codec-pc/ivas-codec.git" - float_ref_branchname_in_ivas_codec="main" exit_code_follows_naming_conventions=0 # if branch does not follow the convention, there will be a printout which is irrelevant here, so redirect it to null @@ -59,7 +57,6 @@ MERGE_TARGET_COMMIT="$(git rev-parse "origin/$CI_MERGE_REQUEST_TARGET_BRANCH_NAM pushd "${SCRIPTS_DIR}" git remote set-branches --add origin "$float_ref_branchname_in_ivas_codec" git fetch origin "$float_ref_branchname_in_ivas_codec" -git checkout "$float_ref_branchname_in_ivas_codec" MERGE_SOURCE_FLOAT_REF_COMMIT="$(git rev-parse "origin/$float_ref_branchname_in_ivas_codec")" FLOAT_REF_COMMIT="$(git rev-parse "origin/main")" diff --git a/snippets/basop/get-float-ref-branch-name.sh b/snippets/basop/get-float-ref-branch-name.sh index 19b92dd..6ba19f9 100755 --- a/snippets/basop/get-float-ref-branch-name.sh +++ b/snippets/basop/get-float-ref-branch-name.sh @@ -48,14 +48,14 @@ branchname_out="main" # If the format is correct, then before "_basop", only numbers can occur float_ref_branchname="${branchname_in/basop/ref}" -# now check in ivas-codec repository if a branch with this name exits +# now check in ivas-codec repository if a branch with this name exists exit_code_ls_remote=0 pushd "${SCRIPTS_DIR}" git fetch origin git ls-remote --exit-code --heads origin refs/heads/$float_ref_branchname || exit_code_ls_remote=$? popd -# If the branch does not exist, default to "ivas-float-update" +# If the branch exists, we use it as ref name instead of main # NOTE: "git ls-remote --exit-code" returns 2 if the given ref was not found if [ "$exit_code_ls_remote" -eq "0" ]; then branchname_out="${float_ref_branchname}" -- GitLab From b55b5510e9f6792bf9a842e53ab7ea909996108f Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Mon, 17 Nov 2025 18:02:56 +0100 Subject: [PATCH 20/23] add fetch command in build script --- snippets/basop/build-binaries.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/snippets/basop/build-binaries.sh b/snippets/basop/build-binaries.sh index f19ca38..99e72b5 100755 --- a/snippets/basop/build-binaries.sh +++ b/snippets/basop/build-binaries.sh @@ -60,6 +60,7 @@ current_commit_sha="$(git rev-parse HEAD)" # should never fail, even if there is nothing to be stored git stash +git fetch origin git checkout "$ref_to_check_out" bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/activate-debug-mode-info-if-set.sh -- GitLab From 40bb59bec5adff55275ef4ef5cbbf1b893030e45 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Mon, 17 Nov 2025 18:09:51 +0100 Subject: [PATCH 21/23] try different fetch --- snippets/basop/build-binaries.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snippets/basop/build-binaries.sh b/snippets/basop/build-binaries.sh index 99e72b5..f1e0ef3 100755 --- a/snippets/basop/build-binaries.sh +++ b/snippets/basop/build-binaries.sh @@ -60,7 +60,7 @@ current_commit_sha="$(git rev-parse HEAD)" # should never fail, even if there is nothing to be stored git stash -git fetch origin +git fetch origin "$ref_to_check_out" git checkout "$ref_to_check_out" bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/activate-debug-mode-info-if-set.sh -- GitLab From 3b640bed2156c27c73c967d4a994c6535534dbe2 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Mon, 17 Nov 2025 18:17:46 +0100 Subject: [PATCH 22/23] remove obsolete printout we use commits now, no branches --- main-basop.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/main-basop.yml b/main-basop.yml index 885de5d..25eda08 100644 --- a/main-basop.yml +++ b/main-basop.yml @@ -428,11 +428,9 @@ workflow: - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/apply-testv-scaling.sh - fi - - echo "$FLOAT_REF_BRANCH - $FLOAT_REF_BRANCH_MERGE_SOURCE - $CI_MERGE_REQUEST_TARGET_BRANCH_NAME - $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME" # build merge target branch and correpsonding float reference - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/build-binaries.sh float-ref - source "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/build-merge-target-binaries.sh - - echo "$FLOAT_REF_BRANCH - $FLOAT_REF_BRANCH_MERGE_SOURCE - $CI_MERGE_REQUEST_TARGET_BRANCH_NAME - $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME" # build to-be-merged branch and corresponding float ref branch - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/build-binaries.sh dut - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/build-binaries.sh float-ref-merge-source -- GitLab From 8dc612b3b9065bf61cb535266bb0b30a3000578e Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Tue, 18 Nov 2025 13:43:06 +0100 Subject: [PATCH 23/23] remove obsolete variable + add trap for git stash back --- includes/default-variables.yml | 1 - snippets/basop/build-binaries.sh | 13 +++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/includes/default-variables.yml b/includes/default-variables.yml index 2774c57..6329664 100644 --- a/includes/default-variables.yml +++ b/includes/default-variables.yml @@ -9,7 +9,6 @@ variables: GIT_CLEAN_FLAGS: -ffdxq TESTCASE_TIMEOUT_STV_SANITIZERS: 240 TESTCASE_TIMEOUT_LTV_SANITIZERS: 2400 - BASOP_REFERENCE_BRANCH: "ivas-float-update" SCALE_FACTOR: "3.162" BASOP_CI_BRANCH_PC_REPO: "basop-ci-branch" PYTEST_ADDOPTS: "" diff --git a/snippets/basop/build-binaries.sh b/snippets/basop/build-binaries.sh index f1e0ef3..7a0f23b 100755 --- a/snippets/basop/build-binaries.sh +++ b/snippets/basop/build-binaries.sh @@ -53,6 +53,13 @@ echo "Building $mode binaries from branch $ref_to_check_out" # working_dir is set as per input argument pushd "$working_dir" +restore_stash() { + if [[ "$(git stash list)" != "" ]]; then + git stash pop + fi +} +trap restore_stash EXIT + # the git SHA and stash restoring mechanisms is not really necessary for float-ref branches, but also should not harm, so no if here current_commit_sha="$(git rev-parse HEAD)" @@ -80,9 +87,7 @@ git rev-parse HEAD >"$commit_file" git checkout "$current_commit_sha" # this used to be a TRAP for EXIT before, but now with the popd at the end, we might not be in the corresponding git repo anymore at EXIT -# instead, this is called manually here now -if [[ "$(git stash list)" != "" ]]; then - git stash pop -fi +# we keep the trap to clean up incase of some error and additionally this is called manually here now +restore_stash popd -- GitLab