-
Notifications
You must be signed in to change notification settings - Fork 77
Add format: actions option to create GitHub annotations
#107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Prior to this, specific violations that shellcheck reports are logged in its output, but are not picked up by GitHub in any special way. The new "actions" format will output shellcheck errors, warnings, and notices using respective GitHub "workflow commands" that become annotations in GitHub's Pull Requests view and elsewhere. This helps navigating shellcheck results in GitHub UI. This is an alternative approach to defining GitHub problem matchers for shellcheck output.
📝 WalkthroughWalkthroughThe pull request introduces updates to the Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant ShellCheck
participant GitHubActions
User->>ShellCheck: Run ShellCheck with actions format
ShellCheck->>ShellCheck: Process input and check code
ShellCheck->>ShellCheck: Generate output in json1 format
ShellCheck->>ShellCheck: Reformat output for GitHub Actions
ShellCheck->>GitHubActions: Send formatted output as workflow commands
GitHubActions-->>User: Display annotations in GitHub UI
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
|
@coderabbitai full review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
📒 Files selected for processing (2)
- README.md (1 hunks)
- action.yaml (4 hunks)
🔇 Additional comments (3)
README.md (1)
145-145: Verify the list of supported formats.Let's ensure the documentation stays in sync with ShellCheck's supported formats.
✅ Verification successful
Documentation accurately reflects ShellCheck's supported formats
The documentation in README.md correctly lists all the output formats supported by ShellCheck:
- Documentation mentions:
checkstyle,diff,gcc,json,json1,quiet,tty, andactions- ShellCheck's help output confirms:
checkstyle,diff,gcc,json,json1,quiet,tty- The special
actionsformat is a wrapper format specific to GitHub Actions integration- The integration documentation link is valid and accessible (HTTP 200)
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify that all formats mentioned in the documentation are supported by ShellCheck # Expected: All formats in the documentation should be listed in ShellCheck's --help output # Test: Check if ShellCheck's help output contains all the formats we document echo "Checking ShellCheck's supported formats..." shellcheck --help | grep -A 5 "Output format" # Test: Verify the integration documentation link echo "Verifying ShellCheck integration documentation..." curl -s -I "https://github.com/koalaman/shellcheck/wiki/Integration" | grep "HTTP/"Length of output: 930
action.yaml (2)
40-40: LGTM: Format description update is clear and consistent.The addition of "actions" to the format options is well-documented and aligns with the PR objectives.
230-239: LGTM: Pipeline integration is correct and maintains error handling.The reformat function is properly integrated into both processing modes while preserving error handling through pipefail and status codes.
Let's verify the pipeline error handling:
✅ Verification successful
Pipeline error handling is properly implemented and verified
The verification confirms:
set -o pipefailis correctly placed before the pipeline operations- Status code is properly captured using
statuscode=$?in both batch and individual processing modes- The status code is propagated through GitHub Actions workflow via
GITHUB_OUTPUT- Final workflow step uses the captured status code for its exit status
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Verify that the pipeline properly propagates errors echo "Checking error handling in pipelines" rg -B 2 -A 2 'set -o pipefail' rg 'statuscode=|exit.*statuscode'Length of output: 646
| options+=(-S "${INPUT_SEVERITY}") | ||
| fi | ||
| if [ "${INPUT_FORMAT}" = "actions" ]; then | ||
| options+=(--format=json1) | ||
| elif [ "${INPUT_FORMAT}" = "tty" ]; then | ||
| options+=(--format=tty --color=always) | ||
| else | ||
| options+=(--format="${INPUT_FORMAT}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codebase verification
Based on the verification results, I can now provide the final response:
Potential issue with format handling implementation
The code only explicitly handles "actions" and "tty" formats, while falling back to direct format value for others. However, the input definition in action.yaml specifies 8 supported formats: "checkstyle", "diff", "gcc", "json", "json1", "quiet", "tty", and "actions". While the fallback might work, explicit handling would be safer to:
- Validate input against supported formats
- Apply format-specific options (like we do for "tty" with --color=always)
🔗 Analysis chain
LGTM: Options handling is robust and maintains compatibility.
The implementation correctly maps the "actions" format to json1 output while preserving existing format handling.
Let's verify that all format options are handled correctly:
Let me gather more information about the format handling by checking the documentation and input definitions.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Verify that all documented format options are properly handled in the code
formats="checkstyle diff gcc json json1 quiet tty actions"
for format in $formats; do
echo "Checking handling of format: $format"
rg -A 2 "INPUT_FORMAT.*=.*$format"
done
Length of output: 1642
Script:
#!/bin/bash
# Check format input definition and documentation
echo "Checking format input definition:"
rg "format:" action.yaml -B 2 -A 4
echo -e "\nChecking format documentation:"
rg -i "format.*supported" README.md -A 10 -B 2 || true
rg "format:" README.md -A 10 -B 2 || true
Length of output: 1041
Prior to this, specific violations that shellcheck reports are logged in its output, but are not picked up by GitHub in any special way. The new "actions" format will output shellcheck errors, warnings, and notices using respective GitHub "workflow commands" that become annotations in GitHub's Pull Requests view and elsewhere. This helps navigating shellcheck results in GitHub UI.
This is an alternative approach to defining GitHub problem matchers for shellcheck output #103 and is entirely opt-in for now. In the future, this action could consider switching to this output by default.