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

Port renderer-pytest-on-merge-request from upstream

parent fbeb5ef8
Loading
Loading
Loading
Loading
+98 −1
Original line number Diff line number Diff line
@@ -101,6 +101,7 @@ stages:
  - prevalidate
  - build
  - test
  - compare
  - deploy

# ---------------------------------------------------------------
@@ -117,6 +118,27 @@ stages:
    echo "Commit time was $CI_COMMIT_TIMESTAMP"
    date | xargs echo "System time is"

.disable-debugging-macro: &disable-debugging-macro
  # automatically disable #DEBUGGING macro in options.h using /**/-comment
  - sed -i.bak -e "s/^[[:space:]]*\(#define[[:space:]]*DEBUGGING\)/\/\*\1\*\//g" lib_com/options.h

.merge-request-comparison-setup-codec: &merge-request-comparison-setup-codec
  ### build test binaries, initial clean for paranoia reasons
  - *disable-debugging-macro
  - make clean
  - make -j
  - mv IVAS_cod IVAS_cod_test
  - mv IVAS_dec IVAS_dec_test
  - mv IVAS_rend IVAS_rend_test
  - git restore .

.merge-request-comparison-check: &merge-request-comparison-check
  - echo "--------------- Running merge-request-comparison-check anchor ---------------"
  - if [ $zero_errors != 1 ]; then echo "Run errors encountered!"; exit $EXIT_CODE_FAIL; fi
  - if [ $exit_code -eq 1 ] && [ $non_be_flag == 0 ]; then echo "Non-bitexact cases without non-BE tag encountered!"; exit $EXIT_CODE_FAIL; fi
  - if [ $exit_code -eq 1 ] && [ $non_be_flag != 0 ]; then echo "Non-bitexact cases with non-BE tag encountered"; exit $EXIT_CODE_NON_BE; fi
  - exit 0

.build-reference-binaries: &build-reference-binaries
- current_commit_sha=$(git rev-parse HEAD)
### build reference binaries
@@ -172,6 +194,11 @@ stages:
  - git pull
  - cd -

.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)

.copy-ltv-files-to-testv-dir: &copy-ltv-files-to-testv-dir
    - cp "$LTV_DIR"/*.wav scripts/testv/
    - cp "$LTV_DIR"/*.met scripts/testv/
@@ -245,6 +272,39 @@ stages:
# Job templates
# ---------------------------------------------------------------

# When designing templates, try not to use too much inheritance and
# if multiple templates and extended on, remember that on conflict,
# latest overwrites the parameter.

# templates for rules
.rules-basis:
  rules:
    - if: $MIRROR_ACCESS_TOKEN # Don't run in the mirror update pipeline (only then MIRROR_ACCESS_TOKEN is defined)
      when: never
    - if: $CI_PIPELINE_SOURCE == 'schedule' # Don't run in any scheduled pipelines by default (use schedule templates below to enable again for certain conditions)
      when: never
    - if: $CI_PIPELINE_SOURCE == 'trigger' # Don't run triggered pipeline by default
      when: never
    - if: $MANUAL_PIPELINE_TYPE == 'test-be-release' # Skip all the normal jobs when testing manually against release codec
      when: never
    - if: $MANUAL_PIPELINE_TYPE == 'test-long-self-test' # Skip all the normal jobs when testing manually against release codec
      when: never
    - if: $MANUAL_PIPELINE_TYPE == 'ivas-conformance'
      when: never
    - if: $MANUAL_PIPELINE_TYPE == 'ivas-conformance-linux'
      when: never
    - if: $MANUAL_PIPELINE_TYPE == 'check-clipping'
    - if: $MANUAL_PIPELINE_TYPE == 'test-branch-vs-input-passthrough'
      when: never
    - when: on_success

.rules-merge-request:
  extends: .rules-basis
  rules:
    - if: $CI_PIPELINE_SOURCE == 'merge_request_event' && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "main" # only have MR pipelines for MRs to main
    - if: $CI_PIPELINE_SOURCE == 'push'
      when: never

# templates to define stages and platforms
.test-job-linux:
  tags:
@@ -1145,6 +1205,43 @@ voip-be-on-merge-request:
    - python3 -m pytest tests/test_be_for_jbm_neutral_dly_profile.py


# compare renderer bitexactness between target and source branch
renderer-pytest-on-merge-request:
  extends:
    - .test-job-linux-needs-testv-dir
    - .rules-merge-request
  needs: ["build-codec-linux-make"]
  # TODO: set reasonable timeout, will most likely take less
  timeout: "20 minutes"
  stage: compare
  script:
    - *print-common-info
    - *get-commits-behind-count
    - *check-commits-behind-count-in-compare-jobs
    - *merge-request-comparison-setup-codec

    # some helper variables - "|| true" to prevent failures from grep not finding anything
    # write to temporary file as workaround for failures observed with piping echo
    - echo $CI_MERGE_REQUEST_TITLE > tmp.txt
    - non_be_flag=$(grep -c --ignore-case "\[rend\(erer\)*[ -]*non[ -]*be\]" tmp.txt) || true
    - ref_using_main=$(grep -c --ignore-case "\[ref[ -]*using[ -]*main\]" tmp.txt) || true

    ### If ref_using_main is not set, checkout the source branch to use scripts and input from there
    - if [ $ref_using_main == 0 ]; then git checkout $source_branch_commit_sha; fi

    - exit_code=0
    - testcase_timeout=60
    - python3 -m pytest -q --log-level ERROR -n auto -rA --html=report.html --self-contained-html --junit-xml=report-junit.xml tests/renderer/test_renderer.py --create_ref --testcase_timeout=$testcase_timeout || exit_code=$?

    ### Run test using branch scripts and input
    - if [ $ref_using_main == 1 ]; then git checkout $source_branch_commit_sha; fi

    # run test
    - python3 -m pytest -q --log-level ERROR -n auto -rA --html=report.html --self-contained-html --junit-xml=report-junit.xml tests/renderer/test_renderer_.py --create_cut --testcase_timeout=$testcase_timeout || exit_code=$?
    - zero_errors=$(cat report-junit.xml | grep -c 'errors="0"') || true

    - *merge-request-comparison-check

# ---------------------------------------------------------------
# Complexity measurement jobs
# ---------------------------------------------------------------