Skip to content

Commit

Permalink
feat: improve debugging
Browse files Browse the repository at this point in the history
Make available partial results from ShellCheck

new outputs:

- `shellcheck-full`
- `shellcheck-head`
- `shellcheck-base`
  • Loading branch information
jamacku committed Jan 27, 2025
1 parent 6327b37 commit cc26393
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,18 @@ Relative path to the HTML file containing detected defects. Example of how to us
<img src="docs/images/html-output-exmple.png" width="800" alt="HTML output example" />
</p>

### `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):
Expand Down
10 changes: 10 additions & 0 deletions src/index.sh
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,19 @@ 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}"

Check warning

Code scanning / shellcheck

SC2154 Warning

GITHUB_OUTPUT is referenced but not assigned.
is_debug && cat "${WORK_DIR}full-shellcheck.err"

Check warning on line 71 in src/index.sh

View check run for this annotation

Codecov / codecov/patch

src/index.sh#L70-L71

Added lines #L70 - L71 were not covered by tests
fi

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"

Check warning on line 80 in src/index.sh

View check run for this annotation

Codecov / codecov/patch

src/index.sh#L79-L80

Added lines #L79 - L80 were not covered by tests

# Save the current state of the working directory
git stash push --quiet
# Checkout the base branch/commit
Expand All @@ -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"

Check warning on line 92 in src/index.sh

View check run for this annotation

Codecov / codecov/patch

src/index.sh#L91-L92

Added lines #L91 - L92 were not covered by tests

evaluate_and_print_fixes

get_defects "${WORK_DIR}head-shellcheck.err" "${WORK_DIR}base-shellcheck.err"
Expand Down

0 comments on commit cc26393

Please sign in to comment.