From 3d3274d18a853d13ef63235a0f83b411e3ddd165 Mon Sep 17 00:00:00 2001 From: Marco Ferrari Date: Wed, 14 Aug 2024 18:16:44 +0200 Subject: [PATCH] fix: remove intro text from stdout and stderr (#6020) - Remove introductory text from stdout and stderr files. - Always create stdout and stderr files, not only when there are errors. --- lib/functions/worker.sh | 29 +++++++++++------------------ lib/linter.sh | 8 ++++---- 2 files changed, 15 insertions(+), 22 deletions(-) diff --git a/lib/functions/worker.sh b/lib/functions/worker.sh index 005bb20b..a56eb991 100755 --- a/lib/functions/worker.sh +++ b/lib/functions/worker.sh @@ -209,16 +209,12 @@ function LintCodebase() { fi if [ -n "${STDOUT_LINTER}" ]; then - local STDOUT_LINTER_LOG_MESSAGE - STDOUT_LINTER_LOG_MESSAGE="Command output for ${FILE_TYPE}:\n------\n${STDOUT_LINTER}\n------" - info "${STDOUT_LINTER_LOG_MESSAGE}" + info "Command output for ${FILE_TYPE}:\n------\n${STDOUT_LINTER}\n------" - if [ ${PARALLEL_COMMAND_RETURN_CODE} -ne 0 ]; then - local STDOUT_LINTER_FILE_PATH - STDOUT_LINTER_FILE_PATH="${SUPER_LINTER_PRIVATE_OUTPUT_DIRECTORY_PATH}/super-linter-parallel-stdout-${FILE_TYPE}" - debug "Saving stdout for ${FILE_TYPE} to ${STDOUT_LINTER_FILE_PATH} in case we need it later" - printf '%s\n' "${STDOUT_LINTER_LOG_MESSAGE}" >"${STDOUT_LINTER_FILE_PATH}" - fi + local STDOUT_LINTER_FILE_PATH + STDOUT_LINTER_FILE_PATH="${SUPER_LINTER_PRIVATE_OUTPUT_DIRECTORY_PATH}/super-linter-parallel-stdout-${FILE_TYPE}" + debug "Saving stdout for ${FILE_TYPE} to ${STDOUT_LINTER_FILE_PATH} in case we need it later" + printf '%s\n' "${STDOUT_LINTER}" >"${STDOUT_LINTER_FILE_PATH}" else debug "Stdout for ${FILE_TYPE} is empty" fi @@ -229,15 +225,12 @@ function LintCodebase() { fi if [ -n "${STDERR_LINTER}" ]; then - local STDERR_LINTER_LOG_MESSAGE - STDERR_LINTER_LOG_MESSAGE="Stderr contents for ${FILE_TYPE}:\n------\n${STDERR_LINTER}\n------" - info "${STDERR_LINTER_LOG_MESSAGE}" - if [ ${PARALLEL_COMMAND_RETURN_CODE} -ne 0 ]; then - local STDERR_LINTER_FILE_PATH - STDERR_LINTER_FILE_PATH="${SUPER_LINTER_PRIVATE_OUTPUT_DIRECTORY_PATH}/super-linter-parallel-stderr-${FILE_TYPE}" - debug "Saving stderr for ${FILE_TYPE} to ${STDERR_LINTER_FILE_PATH} in case we need it later" - printf '%s\n' "${STDERR_LINTER_LOG_MESSAGE}" >"${STDERR_LINTER_FILE_PATH}" - fi + info "Stderr contents for ${FILE_TYPE}:\n------\n${STDERR_LINTER}\n------" + + local STDERR_LINTER_FILE_PATH + STDERR_LINTER_FILE_PATH="${SUPER_LINTER_PRIVATE_OUTPUT_DIRECTORY_PATH}/super-linter-parallel-stderr-${FILE_TYPE}" + debug "Saving stderr for ${FILE_TYPE} to ${STDERR_LINTER_FILE_PATH} in case we need it later" + printf '%s\n' "${STDERR_LINTER}" >"${STDERR_LINTER_FILE_PATH}" else debug "Stderr for ${FILE_TYPE} is empty" fi diff --git a/lib/linter.sh b/lib/linter.sh index 224fafc4..a1674f31 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -502,13 +502,13 @@ Footer() { WriteSummaryLineFailure "${SUPER_LINTER_SUMMARY_OUTPUT_PATH}" "${LANGUAGE}" fi - # Print output as error in case users disabled the INFO level so they - # get feedback + # Print stdout and stderr in case the log level is higher than INFO + # so users still get feedback. Print output as error so it gets emitted if [[ "${LOG_VERBOSE}" != "true" ]]; then local STDOUT_LINTER_FILE_PATH STDOUT_LINTER_FILE_PATH="${SUPER_LINTER_PRIVATE_OUTPUT_DIRECTORY_PATH}/super-linter-parallel-stdout-${LANGUAGE}" if [[ -e "${STDOUT_LINTER_FILE_PATH}" ]]; then - error "$(cat "${STDOUT_LINTER_FILE_PATH}")" + error "Stdout contents for ${LANGUAGE}:\n------\n$(cat "${STDOUT_LINTER_FILE_PATH}")\n------" else debug "Stdout output file path for ${LANGUAGE} (${STDOUT_LINTER_FILE_PATH}) doesn't exist" fi @@ -516,7 +516,7 @@ Footer() { local STDERR_LINTER_FILE_PATH STDERR_LINTER_FILE_PATH="${SUPER_LINTER_PRIVATE_OUTPUT_DIRECTORY_PATH}/super-linter-parallel-stderr-${LANGUAGE}" if [[ -e "${STDERR_LINTER_FILE_PATH}" ]]; then - error "$(cat "${STDERR_LINTER_FILE_PATH}")" + error "Stderr contents for ${LANGUAGE}:\n------\n$(cat "${STDERR_LINTER_FILE_PATH}")\n------" else debug "Stderr output file path for ${LANGUAGE} (${STDERR_LINTER_FILE_PATH}) doesn't exist" fi