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:
Victor Martinez 2020-07-06 18:06:58 +01:00 committed by GitHub
parent 7cf73e5dc5
commit 9a909c5d1d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 34 additions and 5 deletions

View file

@ -186,7 +186,8 @@ ENV GITHUB_SHA=${GITHUB_SHA} \
ACTIONS_RUNNER_DEBUG=${ACTIONS_RUNNER_DEBUG} \ ACTIONS_RUNNER_DEBUG=${ACTIONS_RUNNER_DEBUG} \
DISABLE_ERRORS=${DISABLE_ERRORS} \ DISABLE_ERRORS=${DISABLE_ERRORS} \
OUTPUT_FORMAT=${OUTPUT_FORMAT} \ OUTPUT_FORMAT=${OUTPUT_FORMAT} \
OUTPUT_FOLDER=${OUTPUT_FOLDER} OUTPUT_FOLDER=${OUTPUT_FOLDER} \
OUTPUT_DETAILS=${OUTPUT_DETAILS}
############################# #############################
# Copy scripts to container # # Copy scripts to container #

View file

@ -171,8 +171,10 @@ and won't run anything unexpected.
| **ACTIONS_RUNNER_DEBUG** | `false` | Flag to enable additional information about the linter, versions, and additional output. | | **ACTIONS_RUNNER_DEBUG** | `false` | Flag to enable additional information about the linter, versions, and additional output. |
| **DISABLE_ERRORS** | `false` | Flag to have the linter complete with exit code 0 even if errors were detected. | | **DISABLE_ERRORS** | `false` | Flag to have the linter complete with exit code 0 even if errors were detected. |
| **DEFAULT_WORKSPACE** | `/tmp/lint` | The location containing files to lint if you are running locally. | | **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_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_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 ### 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. 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.

View file

@ -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_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_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}" REPORT_OUTPUT_FOLDER="${DEFAULT_WORKSPACE}/${OUTPUT_FOLDER}"
########################## ##########################
@ -577,7 +578,13 @@ LintAnsibleFiles()
####################################################### #######################################################
if IsTAP ; then if IsTAP ; then
echo "not ok ${INDEX} - ${FILE}" >> "${TMPFILE}" 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 fi
else else
########### ###########
@ -2034,7 +2041,13 @@ LintCodebase()
####################################################### #######################################################
if IsTAP ; then if IsTAP ; then
echo "not ok ${INDEX} - ${FILE}" >> "${TMPFILE}" 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 fi
else else
@ -2430,6 +2443,19 @@ IsTAP()
return 1 return 1
fi 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 ########################################### ############################### MAIN ###########################################
################################################################################ ################################################################################