Commit 8c0f552a authored by Jan Kiene's avatar Jan Kiene
Browse files

rework branch-is-up-to-date-with-target-pre job

- unshallow repo to always allow commits behind count to work
- store not only target commit, but also float ref branches
parent dc159dde
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
  FLOAT_REF_COMMIT_FILE: "float-ref-git-sha.txt"
  MERGE_SOURCE_FLOAT_REF_COMMIT_FILE: "merge-source-float-ref-git-sha.txt"
  MERGE_TARGET_COMMIT_FILE: "merge-target-git-sha.txt"
+9 −10
Original line number Diff line number Diff line
include:
  - local: main.yml
  - local: includes/basop-default-variables.yml

stages:
  - .pre
@@ -835,6 +836,11 @@ fail-pipeline-if-in-draft:
    -   bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/get-float-ref-branch-name.sh $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME
    - fi

# This job runs in MR pipelines and checks if your branch is up-to-date with your target
# If it is not, it fails the whole pipeline early (this should be the first job to run)
# It also stores the target branch's current commit as well as the float_ref branch's current commit
# to ensure that later jobs that need access to these branches all run on the same commit - which is
# important in case the branch is updated during the runtime of the pipeline
branch-is-up-to-date-with-target-pre:
  extends:
    - .job-linux
@@ -844,19 +850,12 @@ branch-is-up-to-date-with-target-pre:
  tags:
    - ivas-basop-linux
  script:
    - |
      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."
        exit 1
      fi
    - git fetch origin "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME"
    - TARGET_COMMIT="$(git rev-parse "origin/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME")"
    - echo "TARGET_COMMIT is $TARGET_COMMIT"
    - echo "$TARGET_COMMIT" > "$MERGE_TARGET_COMMIT_FILE"
    - source "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/branch-is-up-to-date-with-target-pre.sh
  artifacts:
    paths:
      - $MERGE_TARGET_COMMIT_FILE
      - $FLOAT_REF_COMMIT_FILE
      - $MERGE_SOURCE_FLOAT_REF_COMMIT_FILE

branch-is-up-to-date-with-target-post:
  extends:
+51 −0
Original line number Diff line number Diff line
#!/bin/bash

# (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
# Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
# Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
# Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
# contributors to this repository. All Rights Reserved.
#
# This software is protected by copyright law and by international treaties.
# The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
# Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
# Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
# Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
# contributors to this repository retain full ownership rights in their respective contributions in
# the software. This notice grants no license of any kind, including but not limited to patent
# license, nor is any license granted by implication, estoppel or otherwise.
#
# Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
# contributions.
#
# This software is provided "AS IS", without any express or implied warranties. The software is in the
# development stage. It is intended exclusively for experts who have experience with such software and
# solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
# and fitness for a particular purpose are hereby disclaimed and excluded.
#
# Any dispute, controversy or claim arising under or in relation to providing this software shall be
# submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
# 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.

BASOP_PATTERN="^[0-9]+[_-]basop[_-].*"
MSG_DOES_NOT_MATCH="Your branch name %s does not match the template '<issue_number>_basop_<description>', e.g. '123_basop_fix_this_one_bug-2'.
If this branch is porting a float MR with a corresponding float part, then
ticking to this branch is needed for the testing system to match this branch with its float-reference counterpart.
Please rename your branch. You can easily do this by creating a new branch from this branch:
  - git checkout -b <new branch name here>
You then also need to create a new merge request and update the links in your issue.
See here for details on the porting work process: https://forge.3gpp.org/rep/sa4/audio/ivas-basop/-/wikis/Porting-MRs-from-floating-point-codec#workflow-for-porting-a-merge-request-from-floating-point-codec-to-basop-codec

If this is not a porting branch, ignore above message.
"

if [ $# -ne 1 ]; then
  echo "Usage: $0 <branchname>"
  exit 1
fi

if ! [[ "$1" =~ $BASOP_PATTERN ]]; then
  printf "$MSG_DOES_NOT_MATCH" "$1"
  exit 1
fi
+57 −0
Original line number Diff line number Diff line
#!/bin/bash

# (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
# Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
# Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
# Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
# contributors to this repository. All Rights Reserved.
#
# This software is protected by copyright law and by international treaties.
# The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
# Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
# Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
# Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
# contributors to this repository retain full ownership rights in their respective contributions in
# the software. This notice grants no license of any kind, including but not limited to patent
# license, nor is any license granted by implication, estoppel or otherwise.
#
# Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
# contributions.
#
# This software is provided "AS IS", without any express or implied warranties. The software is in the
# development stage. It is intended exclusively for experts who have experience with such software and
# solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
# and fitness for a particular purpose are hereby disclaimed and excluded.
#
# Any dispute, controversy or claim arising under or in relation to providing this software shall be
# submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
# 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.

# fetch all needed branches
# we need a full repo here to always be sure we get enough commits so the commits_behind_count thingy below works (only relevant for switching back to fetch GIT_STRATEGY)
git fetch --unshallow
git fetch origin "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME"
git fetch origin ivas-float-update
float_ref_branchname=$(${CI_PROJECT_DIR}/ivas-codec-ci/snippets/basop/get-float-ref-branch-name.sh $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME)
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."
  exit 1
fi

# 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"

FLOAT_REF_COMMIT="$(git rev-parse "origin/$float_ref_branchname")"
echo "FLOAT_REF_COMMIT is $FLOAT_REF_COMMIT"
echo "$FLOAT_REF_COMMIT" >"$FLOAT_REF_COMMIT_FILE"

IVAS_FLOAT_UPDATE_COMMIT="$(git rev-parse "origin/ivas-float-update")"
echo "IVAS_FLOAT_UPDATE_COMMIT is $IVAS_FLOAT_UPDATE_COMMIT"
echo "$IVAS_FLOAT_UPDATE_COMMIT" >"$IVAS_FLOAT_UPDATE_COMMIT_FILE"
+2 −16
Original line number Diff line number Diff line
@@ -28,17 +28,8 @@
# 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.

BASOP_PATTERN="^[0-9]+[_-]basop[_-].*"
MSG_DOES_NOT_MATCH="Your branch name %s does not match the template '<issue_number>_basop_<description>', e.g. '123_basop_fix_this_one_bug-2'.
If this branch is porting a float MR with a corresponding float part, then
ticking to this branch is needed for the testing system to match this branch with its float-reference counterpart.
Please rename your branch. You can easily do this by creating a new branch from this branch:
  - git checkout -b <new branch name here>
You then also need to create a new merge request and update the links in your issue.
See here for details on the porting work process: https://forge.3gpp.org/rep/sa4/audio/ivas-basop/-/wikis/Porting-MRs-from-floating-point-codec#workflow-for-porting-a-merge-request-from-floating-point-codec-to-basop-codec

If this is not a porting branch, ignore above message.
"
# 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

if [ $# -ne 1 ]; then
  echo "Usage: $0 <branchname>"
@@ -48,11 +39,6 @@ fi
branchname_in="$1"
branchname_out="ivas-float-update"

if ! [[ "$branchname_in" =~ $BASOP_PATTERN ]]; then
  printf "$MSG_DOES_NOT_MATCH" "$branchname_in"
  exit 1
fi

# 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
# If the format is correct, then before "_basop", only numbers can occur
Loading