Skip to content

Commit

Permalink
Generate summary line only if diktat detects errors
Browse files Browse the repository at this point in the history
  • Loading branch information
nulls committed Dec 25, 2023
1 parent c4c0efe commit c347d93
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,13 @@ runs:
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
if (( ${exit_code} != 0 ))
then
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
fi
rm -f diktat.log
echo "exit-code=${exit_code}" >>$GITHUB_OUTPUT
env:
Expand Down

0 comments on commit c347d93

Please sign in to comment.