Commit 71763425 authored by Fabian Müller's avatar Fabian Müller
Browse files

Replace get-commits-behind-count with shell script

parent 942e159b
Loading
Loading
Loading
Loading
+7 −12
Original line number Diff line number Diff line
@@ -137,11 +137,6 @@ stages:
# automatically enable #define DISABLE_LIMITER in options.h, handling both /**/-comment and //-comment
  - sed -i.bak -e "s/\/\*[[:space:]]*\(#define[[:space:]]*DISABLE_LIMITER\)[[:space:]]*\*\//\1/g" ./lib_com/options.h

.get-commits-behind-count: &get-commits-behind-count
  - echo $CI_COMMIT_SHA
  - echo $CI_MERGE_REQUEST_TARGET_BRANCH_NAME
  - commits_behind_count=$(git rev-list --count $CI_COMMIT_SHA..origin/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME)

.check-commits-behind-count-in-compare-jobs: &check-commits-behind-count-in-compare-jobs
  - if [ $commits_behind_count -ne 0 ]; then echo "Your branch is not up-to-date with main -> Compare tests will not run as they can contain false negatives this way.\nMain might have changed during your pipeline run. Run 'git merge origin/main' to update."; exit 1; fi

@@ -354,9 +349,9 @@ branch-is-up-to-date-with-main-pre:
  tags:
    - ivas-linux
  script:
    - *get-commits-behind-count
    - echo $commits_behind_count
    - if [ $commits_behind_count -eq 0 ]; then exit 0; else echo "Your branch is behind main, run 'git merge origin/main' to update."; exit 1; fi;
    - commits_behind_count="$(bash "${CI_PROJECT_DIR}"/snippets/get-commits-behind-count.sh)"

check-self-test-names-pre:
  extends:
@@ -385,9 +380,9 @@ branch-is-up-to-date-with-main-post:
  tags:
    - ivas-linux
  script:
    - *get-commits-behind-count
    - echo $commits_behind_count
    - if [ $commits_behind_count -eq 0 ]; then exit 0; else echo "Your branch is behind main, possibly main changed during your pipeline run, run 'git merge origin/main' to update." exit 1; fi;
    - commits_behind_count="$(bash "${CI_PROJECT_DIR}"/snippets/get-commits-behind-count.sh)"

.basop-ci-branch-compat-template:
  extends:
@@ -775,7 +770,7 @@ renderer-pytest-on-merge-request:
  stage: compare
  script:
    - bash "$CI_PROJECT_DIR"/.gitlab-ci/snippets/print-common-info.sh
    - *get-commits-behind-count
    - commits_behind_count="$(bash "${CI_PROJECT_DIR}"/snippets/get-commits-behind-count.sh)"
    - *check-commits-behind-count-in-compare-jobs
    - *merge-request-comparison-setup-codec

@@ -860,7 +855,7 @@ split-rendering-pytest-on-merge-request:
  stage: compare
  script:
    - bash "$CI_PROJECT_DIR"/.gitlab-ci/snippets/print-common-info.sh
    - *get-commits-behind-count
    - commits_behind_count="$(bash "${CI_PROJECT_DIR}"/snippets/get-commits-behind-count.sh)"
    - *check-commits-behind-count-in-compare-jobs

    # some helper variables - "|| true" to prevent failures from grep not finding anything
@@ -931,7 +926,7 @@ ivas-pytest-on-merge-request:
  timeout: "14 minutes"
  script:
    - bash "$CI_PROJECT_DIR"/.gitlab-ci/snippets/print-common-info.sh
    - *get-commits-behind-count
    - commits_behind_count="$(bash "${CI_PROJECT_DIR}"/snippets/get-commits-behind-count.sh)"
    - *check-commits-behind-count-in-compare-jobs
    - *merge-request-comparison-setup-codec

@@ -985,7 +980,7 @@ ivas-interop-on-merge-request:
  timeout: "10 minutes"
  script:
    - bash "$CI_PROJECT_DIR"/.gitlab-ci/snippets/print-common-info.sh
    - *get-commits-behind-count
    - commits_behind_count="$(bash "${CI_PROJECT_DIR}"/snippets/get-commits-behind-count.sh)"
    - *check-commits-behind-count-in-compare-jobs
    - *merge-request-comparison-setup-codec
    # the next line is dependent on ref-using-main flag in the other tests, but here the flag does not make sense
@@ -1034,7 +1029,7 @@ evs-pytest-on-merge-request:
  timeout: "10 minutes"
  script:
    - bash "$CI_PROJECT_DIR"/.gitlab-ci/snippets/print-common-info.sh
    - *get-commits-behind-count
    - commits_behind_count="$(bash "${CI_PROJECT_DIR}"/snippets/get-commits-behind-count.sh)"
    - *check-commits-behind-count-in-compare-jobs
    - *merge-request-comparison-setup-codec

+10 −0
Original line number Diff line number Diff line
#! /bin/bash

set -euo pipefail

cd "${CI_PROJECT_DIR}"

echo "CI_COMMIT_SHA: ${CI_COMMIT_SHA}" 1>&2
echo "CI_MERGE_REQUEST_TARGET_BRANCH_NAME: ${CI_MERGE_REQUEST_TARGET_BRANCH_NAME}" 1>&2

git rev-list --count "$CI_COMMIT_SHA"..origin/"$CI_MERGE_REQUEST_TARGET_BRANCH_NAME"