saveourtool / benedikt

A GitHub Action to check your code with diKTat
MIT License
10 stars 2 forks source link

action doesn't work #27

Open ccfontes opened 2 months ago

ccfontes commented 2 months ago

Context: it's a private repo

workflow:

name: diktat
on: push
jobs:
  diktat_check:
    name: 'diKTat Check'
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: saveourtool/benedikt@v2
        with:
            input-paths: |
              src/**/*.kt

Error log:

/home/runner/work/_temp/da04cdc5-94bd-4ef0-8ec0-[37](https://github.com/user_redacted/project_redacted/actions/runs/8688208424/job/23823324987#step:3:39)6b8159896f.sh: line 1: ((: == 0 : syntax error: operand expected (error token is "== 0 ")
/home/runner/work/_temp/da04cdc5-94bd-4ef0-8ec0-376b8159896f.sh: line 14: ((: != 0 : syntax error: operand expected (error token is "!= 0 ")
/home/runner/work/_temp/da04cdc5-94bd-4ef0-8ec0-376b8159896f.sh: line 21: ((: <= 1 : syntax error: operand expected (error token is "<= 1 ")
/home/runner/work/_temp/da04cdc5-94bd-4ef0-8ec0-376b8159896f.sh: line 26: ((: != 1 : syntax error: operand expected (error token is "!= 1 ")

Action log:

Run if [[ 'false' == 'true' ]]
  if [[ 'false' == 'true' ]]
  then
    set -x
  fi
  DIKTAT_ARGS=('--config' 'diktat-analysis.yml' '--reporter' 'sarif')
  if [[ 'sarif' == 'sarif' ]]
  then
    report_file=${GITHUB_WORKSPACE}/report.sarif
  elif [[ 'sarif' == 'checkstyle' ]]
  then
    report_file=${GITHUB_WORKSPACE}/checkstyle-report.xml
  else
    echo "<reporter> should be set to <sarif> or <checkstyle>"
    exit 1
  fi
  DIKTAT_ARGS+=('--output' "${report_file}")

  if [[ 'false' == 'true' ]]
  then
    DIKTAT_ARGS+=('--log-level' 'DEBUG')
  fi

  set -o pipefail
  IFS=$'\n'
  INPUT_PATHS=(src/**/*.kt
  )
  DIKTAT_CMD=${GITHUB_WORKSPACE}/diktat
  chmod +x ${DIKTAT_CMD}
  { ${DIKTAT_CMD} "${DIKTAT_ARGS[@]}" "${INPUT_PATHS[@]}" | tee diktat.log; } && exit_code=$? || exit_code=$?
  total_lines=$(wc -l diktat.log | cut -d ' ' -f1)
  summary_line_number=$(grep -n 'Summary error count (descending) by rule:' diktat.log | cut -d: -f1)
  summary_line=$(tail -n $((total_lines - summary_line_number)) diktat.log | sed -e 's/^  //g' | awk '{ printf("%s,", $0) }' | sed -e 's/,$//g')
  echo "summary-line=${summary_line}" >>$GITHUB_OUTPUT
  rm -f diktat.log
  echo "exit-code=${exit_code}" >>$GITHUB_OUTPUT
  shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
  env:
    GITHUB_TOKEN: ***
Error: Process completed with exit code 1.
Run if ((  == 0 ))
  if ((  == 0 ))
  then
    status_icon=':heavy_check_mark:'
    message='completed successfully'
  else
    status_icon=':x:'
    message='exited with code ****'
  fi

  diktat='[_diKTat_](https://github.com/saveourtool/diktat)'

  echo "${status_icon} ${diktat} ${message}" >>${GITHUB_STEP_SUMMARY}

  if ((  != 0 ))
  then
    echo '```console' >>${GITHUB_STEP_SUMMARY}
    echo "" | xargs -d ',' -n1 echo >>${GITHUB_STEP_SUMMARY}
    echo '```' >>${GITHUB_STEP_SUMMARY}
  fi

  if ((  <= 1 ))
  then
    ${GITHUB_WORKSPACE}/diktat --version | awk '{ split($0, versions, ": *"); print " - _" versions[1] "_: **" versions[2] "**" }' >>${GITHUB_STEP_SUMMARY}
  fi

  if ((  != 1 ))
  then
    exit 
  elif [[ 'true' != 'false' ]]
  then
    exit 1
  fi
  shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
/home/runner/work/_temp/da04cdc5-94bd-4ef0-8ec0-[37](https://github.com/user_redacted/project_redacted/actions/runs/8688208424/job/23823324987#step:3:39)6b8159896f.sh: line 1: ((: == 0 : syntax error: operand expected (error token is "== 0 ")
/home/runner/work/_temp/da04cdc5-94bd-4ef0-8ec0-376b8159896f.sh: line 14: ((: != 0 : syntax error: operand expected (error token is "!= 0 ")
/home/runner/work/_temp/da04cdc5-94bd-4ef0-8ec0-376b8159896f.sh: line 21: ((: <= 1 : syntax error: operand expected (error token is "<= 1 ")
/home/runner/work/_temp/da04cdc5-94bd-4ef0-8ec0-376b8159896f.sh: line 26: ((: != 1 : syntax error: operand expected (error token is "!= 1 ")
unix-junkie commented 2 months ago

@ccfontes, thank you for the report!

The problem might have been caused by the version upgrade of Diktat.

I'll look into the problem and get back to you. Meanwhile, could you please try version 1.2.5 of the action and check whether it works for you?

ccfontes commented 2 months ago

@unix-junkie downgrade fixed the issue. Thank you!