From cc263937e080cfddf272c47c51fb07be34159711 Mon Sep 17 00:00:00 2001 From: Jan Macku Date: Mon, 27 Jan 2025 12:46:50 +0100 Subject: [PATCH] feat: improve debugging Make available partial results from ShellCheck new outputs: - `shellcheck-full` - `shellcheck-head` - `shellcheck-base` --- README.md | 12 ++++++++++++ src/index.sh | 10 ++++++++++ 2 files changed, 22 insertions(+) diff --git a/README.md b/README.md index 334351ad..8b918f09 100644 --- a/README.md +++ b/README.md @@ -401,6 +401,18 @@ Relative path to the HTML file containing detected defects. Example of how to us HTML output example

+### `shellcheck-full` + +ShellCheck JSON output when Full scan is requested. Useful when debugging. + +### `shellcheck-head` + +ShellCheck JSON output for HEAD commit. Useful when debugging. + +### `shellcheck-base` + +ShellCheck JSON output for BASE commit. Useful when debugging. + ## Using with Private repositories Differential ShellCheck GitHub Action could be used in private repositories by any user. But code scanning-related features are available only for GitHub Enterprise users, as mentioned in [GitHub Documentation](https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/about-code-scanning): diff --git a/src/index.sh b/src/index.sh index 4a578b70..d535800c 100755 --- a/src/index.sh +++ b/src/index.sh @@ -66,6 +66,9 @@ echo if [[ ${FULL_SCAN} -eq 0 ]]; then execute_shellcheck "${all_scripts[@]}" > "${WORK_DIR}full-shellcheck.err" + + echo "shellcheck-full=${WORK_DIR}full-shellcheck.err" >> "${GITHUB_OUTPUT}" + is_debug && cat "${WORK_DIR}full-shellcheck.err" fi exit_status=0 @@ -73,6 +76,9 @@ exit_status=0 if ! is_strict_check_on_push_demanded; then execute_shellcheck "${only_changed_scripts[@]}" > "${WORK_DIR}head-shellcheck.err" + echo "shellcheck-head=${WORK_DIR}head-shellcheck.err" >> "${GITHUB_OUTPUT}" + is_debug && cat "${WORK_DIR}head-shellcheck.err" + # Save the current state of the working directory git stash push --quiet # Checkout the base branch/commit @@ -81,6 +87,10 @@ if ! is_strict_check_on_push_demanded; then execute_shellcheck "${only_changed_scripts[@]}" > "${WORK_DIR}base-shellcheck.err" get_fixes "${WORK_DIR}base-shellcheck.err" "${WORK_DIR}head-shellcheck.err" + + echo "shellcheck-base=${WORK_DIR}base-shellcheck.err" >> "${GITHUB_OUTPUT}" + is_debug && cat "${WORK_DIR}base-shellcheck.err" + evaluate_and_print_fixes get_defects "${WORK_DIR}head-shellcheck.err" "${WORK_DIR}base-shellcheck.err"