Commit 291c1b0f authored by Jan Kiene's avatar Jan Kiene
Browse files

Merge branch '33-clang-format-check' into 'main'

Resolve "Add clang-format check as part of the merge request pipeline"

See merge request !220
parents 3837b7df 97b78656
Loading
Loading
Loading
Loading
Loading
+43 −0
Original line number Diff line number Diff line
@@ -417,6 +417,49 @@ evs-pytest-on-merge-request:
      junit:
        - report-junit-evs.xml

clang-format-check:
  extends:
    - .test-job-linux
    - .rules-merge-request
  variables:
    ARTIFACT_BASE_NAME: "mr-$CI_MERGE_REQUEST_IID--sha-$CI_COMMIT_SHORT_SHA--formatting-fix"
  stage: validate
  needs: []
  timeout: "5 minutes"
  script:
    # Set up variables. This can't be done in the "variables" section because variables are not expanded properly there
    - PATCH_FILE_NAME="$ARTIFACT_BASE_NAME".patch
    - >
      INSTRUCTIONS_GITLAB="To fix formatting issues:\n
      - download the diff patch available as artifact of this job\n
      - unzip the artifact and place the patch file in the root directory of your local IVAS repo\n
      - run: git apply $PATCH_FILE_NAME\n
      - commit new changes"
    - >
      INSTRUCTIONS_README="To fix formatting issues:\n
      - place the patch file in the root directory of your local IVAS repo\n
      - run: git apply $PATCH_FILE_NAME\n
      - commit new changes"
    
    - scripts/check-format.sh -af -p 8 || format_problems=$?
    - if [ $format_problems == 0 ] ; then exit 0; fi

    - mkdir tmp-formatting-fix
    - git diff > "tmp-formatting-fix/$PATCH_FILE_NAME"

    # Print instructions to job output
    - echo -e "$INSTRUCTIONS_GITLAB"

    # Include readme in the artifact, in case someone misses the job printout (e.g. getting the artifact via MR interface)
    - echo -e "$INSTRUCTIONS_README" > "tmp-formatting-fix/readme.txt"

    - exit $format_problems
  artifacts:
    paths:
      - tmp-formatting-fix/
    when: on_failure
    name: "$ARTIFACT_BASE_NAME"
    expose_as: 'formatting patch'

# ---------------------------------------------------------------
# Test jobs for main branch
+2 −1
Original line number Diff line number Diff line
@@ -206,7 +206,8 @@ ivas_error ivas_core_dec(
        {
            float gain;

            gain = ( st->element_mode == IVAS_CPE_MDCT ) ? st->hTcxDec->conceal_eof_gain : ( st->hPlcInfo != NULL ) ? st->hPlcInfo->recovery_gain : 0.0f;
            gain = ( st->element_mode == IVAS_CPE_MDCT ) ? st->hTcxDec->conceal_eof_gain : ( st->hPlcInfo != NULL ) ? st->hPlcInfo->recovery_gain
                                                                                                                    : 0.0f;

            if ( ( st->element_mode == IVAS_CPE_MDCT && hMCT == NULL ) || ( st->hPlcInfo != NULL ) )
            {
+2 −3
Original line number Diff line number Diff line
@@ -963,8 +963,7 @@ static void dec_prm_tcx(
static void stereo_tcx_dec_mode_switch_reconf(
    Decoder_State *st,
    const int16_t MCT_flag,
    const int16_t last_element_mode
)
    const int16_t last_element_mode )
{
    int16_t frame_size_index;

+2 −2
Original line number Diff line number Diff line
@@ -62,7 +62,7 @@ EOM
}

cl-format-check-version() {
    ${CLANG_FORMAT} --version | awk '{print $3}'
    ${CLANG_FORMAT} --version | sed 's/.*version \([1-9]*\.[0-9]*\).*/\1/'
}

cl-format-apply() {
@@ -229,7 +229,7 @@ else
    rm "$NUMFAILSTMPFILE"
    if [[ $NUMFAILS -gt 0 ]]; then
        echo "Total fails:  $NUMFAILS"
#        exit $NUMFAILS  ## uncomment if script should have num fails as return code
        exit $NUMFAILS  ## uncomment if script should have num fails as return code
    fi
fi

+4 −4

File changed.

Contains only whitespace changes.