mirror of
https://github.com/super-linter/super-linter.git
synced 2024-11-22 00:31:07 -05:00
Output transformation (with error messages or simpler) (#1)
* Output transformation (with error messages or simpler) * colon causes issues when transforming TAP to XUnit
This commit is contained in:
parent
7cf73e5dc5
commit
9a909c5d1d
3 changed files with 34 additions and 5 deletions
|
@ -186,7 +186,8 @@ ENV GITHUB_SHA=${GITHUB_SHA} \
|
|||
ACTIONS_RUNNER_DEBUG=${ACTIONS_RUNNER_DEBUG} \
|
||||
DISABLE_ERRORS=${DISABLE_ERRORS} \
|
||||
OUTPUT_FORMAT=${OUTPUT_FORMAT} \
|
||||
OUTPUT_FOLDER=${OUTPUT_FOLDER}
|
||||
OUTPUT_FOLDER=${OUTPUT_FOLDER} \
|
||||
OUTPUT_DETAILS=${OUTPUT_DETAILS}
|
||||
|
||||
#############################
|
||||
# Copy scripts to container #
|
||||
|
|
|
@ -173,6 +173,8 @@ and won't run anything unexpected.
|
|||
| **DEFAULT_WORKSPACE** | `/tmp/lint` | The location containing files to lint if you are running locally. |
|
||||
| **OUTPUT_FORMAT** | `` | The report format to be generated, besides the stdout one. Supported formats: tap |
|
||||
| **OUTPUT_FOLDER** | `super-linter.report` | The location where the output reporting will be generated to. |
|
||||
| **OUTPUT_DETAILS** | `simpler` | What level of details to be reported. Supported formats: simpler or detailed. |
|
||||
|
||||
|
||||
### Template rules files
|
||||
You can use the **GitHub** **Super-Linter** *with* or *without* your own personal rules sets. This allows for greater flexibility for each individual code base. The Template rules all try to follow the standards we believe should be enabled at the basic level.
|
||||
|
|
|
@ -139,6 +139,7 @@ DEFAULT_IFS="$IFS" # Get the Default IFS for updating
|
|||
##############
|
||||
OUTPUT_FORMAT="${OUTPUT_FORMAT}" # Output format to be generated. Default none
|
||||
OUTPUT_FOLDER="${OUTPUT_FOLDER:-super-linter.report}" # Folder where the reports are generated. Default super-linter.report
|
||||
OUTPUT_DETAILS="${OUTPUT_DETAILS:-simpler}" # What level of details. (simpler or detailed). Default simpler
|
||||
REPORT_OUTPUT_FOLDER="${DEFAULT_WORKSPACE}/${OUTPUT_FOLDER}"
|
||||
|
||||
##########################
|
||||
|
@ -577,7 +578,13 @@ LintAnsibleFiles()
|
|||
#######################################################
|
||||
if IsTAP ; then
|
||||
echo "not ok ${INDEX} - ${FILE}" >> "${TMPFILE}"
|
||||
printf " ---\n message:[%s]\n ..." "$LINT_CMD" >> "${TMPFILE}"
|
||||
##########################################
|
||||
# Report the detailed message if enabled #
|
||||
##########################################
|
||||
DETAILED_MSG=$(TransformTAPDetails "$LINT_CMD")
|
||||
if [ -n "${DETAILED_MSG}" ] ; then
|
||||
printf " ---\n message: %s\n ..." "$DETAILED_MSG" >> "${TMPFILE}"
|
||||
fi
|
||||
fi
|
||||
else
|
||||
###########
|
||||
|
@ -2034,7 +2041,13 @@ LintCodebase()
|
|||
#######################################################
|
||||
if IsTAP ; then
|
||||
echo "not ok ${INDEX} - ${FILE}" >> "${TMPFILE}"
|
||||
printf " ---\n message:[%s]\n ..." "$LINT_CMD" >> "${TMPFILE}"
|
||||
##########################################
|
||||
# Report the detailed message if enabled #
|
||||
##########################################
|
||||
DETAILED_MSG=$(TransformTAPDetails "$LINT_CMD")
|
||||
if [ -n "${DETAILED_MSG}" ] ; then
|
||||
printf " ---\n message: %s\n ..." "$DETAILED_MSG" >> "${TMPFILE}"
|
||||
fi
|
||||
fi
|
||||
|
||||
else
|
||||
|
@ -2430,6 +2443,19 @@ IsTAP()
|
|||
return 1
|
||||
fi
|
||||
}
|
||||
################################################################################
|
||||
#### Function TransformTAPDetails ##############################################
|
||||
TransformTAPDetails()
|
||||
{
|
||||
DATA=$1
|
||||
if [ -n "${DATA}" ] && [ "${OUTPUT_DETAILS}" == "detailed" ] ; then
|
||||
#########################################################
|
||||
# Transform new lines to \\n, remove colours and colons #
|
||||
#########################################################
|
||||
echo "${DATA}" | awk 'BEGIN{RS="\n";ORS="\\n"}1' | sed -r "s/\x1B\[([0-9]{1,3}(;[0-9]{1,2})?)?[mGK]//g" | tr ':' ' '
|
||||
fi
|
||||
}
|
||||
|
||||
################################################################################
|
||||
############################### MAIN ###########################################
|
||||
################################################################################
|
||||
|
|
Loading…
Reference in a new issue