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

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

parent 2a9b9e89
Loading
Loading
Loading
Loading
+92 −0
Original line number Diff line number Diff line
@@ -199,6 +199,9 @@ stages:
  - 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

.copy-ltv-files-to-testv-dir: &copy-ltv-files-to-testv-dir
    - cp "$LTV_DIR"/*.wav scripts/testv/
    - cp "$LTV_DIR"/*.met scripts/testv/
@@ -1205,6 +1208,42 @@ voip-be-on-merge-request:
    - python3 -m pytest tests/test_be_for_jbm_neutral_dly_profile.py


# ---------------------------------------------------------------
# Test jobs for merge requests
# ---------------------------------------------------------------

# test that runs all modes with 1s input signals
codec-smoke-test:
  extends:
    - .test-job-linux-needs-testv-dir
    - .rules-merge-request
  timeout: "20 minutes"
  tags:
    - ivas-basop-linux
  stage: test
  needs: ["build-codec-linux-make"] #, "build-codec-instrumented-linux", "build-codec-sanitizers-linux"]
  script:
    - *print-common-info
    # LTV update needed as ltv ISM metadata files are used
    - *update-ltv-repo
    - bash ci/smoke_test.sh
    ### analyze for failures
    - if ! [ -s smoke_test_output.txt ] || ! [ -s smoke_test_output_jbm.txt ] || ! [ -s smoke_test_output_hrtf.txt ]; then echo "Error in smoke test"; exit 1; fi
    - ret_val=0
    - if cat smoke_test_output.txt | grep -c "failed"; then echo "Smoke test without JBM failed"; ret_val=1; fi
    - if cat smoke_test_output_jbm.txt | grep -c "failed"; then echo "Smoke test JBM part failed"; ret_val=1; fi
    - if cat smoke_test_output_hrtf.txt | grep -c "failed"; then echo "Smoke test with external hrtf files failed"; ret_val=1; fi
    - exit $ret_val
  artifacts:
    name: "mr-$CI_MERGE_REQUEST_IID--sha-$CI_COMMIT_SHORT_SHA--stage-$CI_JOB_STAGE--results"
    expire_in: 1 week
    when: always
    paths:
      - smoke_test_output.txt
      - smoke_test_output_jbm.txt
      - smoke_test_output_hrtf.txt
    expose_as: "Smoke test results"

# compare renderer bitexactness between target and source branch
renderer-pytest-on-merge-request:
  extends:
@@ -1242,6 +1281,59 @@ renderer-pytest-on-merge-request:

    - *merge-request-comparison-check

# compare bit exactness between target and source branch
ivas-pytest-on-merge-request:
  extends:
    - .test-job-linux-needs-testv-dir
    - .rules-merge-request
  stage: compare
  needs: ["build-codec-linux-make", "codec-smoke-test"]
  timeout: "14 minutes"
  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 "\[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

    ### prepare pytest
    # create references
    - python3 -m pytest $TESTS_DIR_CODEC_BE_ON_MR -v --update_ref 1

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

    ### run pytest
    - exit_code=0
    - testcase_timeout=60
    - python3 -m pytest $TESTS_DIR_CODEC_BE_ON_MR -v --html=report.html --self-contained-html --junit-xml=report-junit.xml --testcase_timeout=$testcase_timeout || exit_code=$?
    - zero_errors=$(cat report-junit.xml | grep -c 'errors="0"') || true

    - *merge-request-comparison-check

  allow_failure:
    exit_codes:
      - 123
  artifacts:
    name: "mr-$CI_MERGE_REQUEST_IID--sha-$CI_COMMIT_SHORT_SHA--stage-$CI_JOB_STAGE--results"
    expire_in: 1 week
    when: always
    paths:
      - report-junit.xml
      - report.html
    expose_as: "pytest ivas results"
    reports:
      junit:
        - report-junit.xml

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