Support TAP reporting format

This commit is contained in:
Victor Martinez 2020-06-23 15:25:12 +01:00
parent 6452f93b32
commit ddbc96bd23
No known key found for this signature in database
GPG key ID: 4058B656AD58C4F5
4 changed files with 70 additions and 1 deletions

3
.gitignore vendored
View file

@ -59,3 +59,6 @@ typings/
# next.js build output # next.js build output
.next .next
# default output report
super-linter.report

View file

@ -171,7 +171,9 @@ ENV GITHUB_SHA=${GITHUB_SHA} \
RUN_LOCAL=${RUN_LOCAL} \ RUN_LOCAL=${RUN_LOCAL} \
TEST_CASE_RUN=${TEST_CASE_RUN} \ TEST_CASE_RUN=${TEST_CASE_RUN} \
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_FOLDER=${OUTPUT_FOLDER}
############################# #############################
# Copy scripts to container # # Copy scripts to container #

View file

@ -147,6 +147,8 @@ 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_FOLDER** | `super-linter.report` | The location where the output reporting will be generated to. |
### 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

@ -125,6 +125,13 @@ READ_ONLY_CHANGE_FLAG=0 # Flag set to 1 if files c
TEST_CASE_FOLDER='.automation/test' # Folder for test cases we should always ignore TEST_CASE_FOLDER='.automation/test' # Folder for test cases we should always ignore
DEFAULT_DISABLE_ERRORS='false' # Default to enabling errors DEFAULT_DISABLE_ERRORS='false' # Default to enabling errors
##############
# Format #
##############
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
REPORT_OUTPUT_FOLDER="${DEFAULT_WORKSPACE}/${OUTPUT_FOLDER}"
########################## ##########################
# Array of changed files # # Array of changed files #
########################## ##########################
@ -1782,6 +1789,16 @@ LintCodebase()
echo "$LINE" echo "$LINE"
done done
####################################
# Prepare context if OUTPUT_FORMAT #
####################################
if [ -n "${OUTPUT_FORMAT}" ] ; then
TMPFILE=$(mktemp -q /tmp/super-linter.XXXXXX)
INDEX=0
mkdir -p "${REPORT_OUTPUT_FOLDER}"
REPORT_OUTPUT_FILE="${REPORT_OUTPUT_FOLDER}/super-linter-${FILE_TYPE}.${OUTPUT_FORMAT}"
fi
################## ##################
# Lint the files # # Lint the files #
################## ##################
@ -1803,6 +1820,8 @@ LintCodebase()
continue continue
fi fi
(("INDEX++"))
############## ##############
# File print # # File print #
############## ##############
@ -1846,13 +1865,37 @@ LintCodebase()
echo "ERROR:[$LINT_CMD]" echo "ERROR:[$LINT_CMD]"
# Increment the error count # Increment the error count
(("ERRORS_FOUND_$FILE_TYPE++")) (("ERRORS_FOUND_$FILE_TYPE++"))
#######################################################
# Store the linting as a temporary file in TAP format #
#######################################################
if [ -n "${OUTPUT_FORMAT}" ] ; then
echo "nok ok ${INDEX} - ${FILE}" >> "${TMPFILE}"
echo " ERROR:[$LINT_CMD]" >> "${TMPFILE}"
fi
else else
########### ###########
# Success # # Success #
########### ###########
echo " - File:[$FILE_NAME] was linted with [$LINTER_NAME] successfully" echo " - File:[$FILE_NAME] was linted with [$LINTER_NAME] successfully"
#######################################################
# Store the linting as a temporary file in TAP format #
#######################################################
if [ -n "${OUTPUT_FORMAT}" ] ; then
echo "ok ${INDEX} - ${FILE}" >> "${TMPFILE}"
fi
fi fi
done done
#################################
# Generate report in TAP format #
#################################
if [ -n "${OUTPUT_FORMAT}" ] && [ ${INDEX} -gt 0 ] ; then
echo "1..${INDEX}" > "${REPORT_OUTPUT_FILE}"
cat "${TMPFILE}" >> "${REPORT_OUTPUT_FILE}"
fi
fi fi
} }
################################################################################ ################################################################################
@ -2073,6 +2116,14 @@ Footer()
echo "----------------------------------------------" echo "----------------------------------------------"
echo "" echo ""
###################################
# Prints output report if enabled #
###################################
if [ -z "${FORMAT_REPORT}" ] ; then
echo "Reports generated in folder ${REPORT_OUTPUT_FOLDER}"
fi
############################## ##############################
# Prints for errors if found # # Prints for errors if found #
############################## ##############################
@ -2201,6 +2252,17 @@ RunTestCases()
########## ##########
Header Header
##############################################################
# check flag for validating the report folder does not exist #
##############################################################
if [ -n "${OUTPUT_FORMAT}" ]; then
if [ -d "${REPORT_OUTPUT_FOLDER}" ] ; then
echo "ERROR! Found ${REPORT_OUTPUT_FOLDER}"
echo "Please remove the folder and try again."
exit 1
fi
fi
####################### #######################
# Get GitHub Env Vars # # Get GitHub Env Vars #
####################### #######################