-
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -37,7 +37,7 @@ inputs: | |
| default: "false" | ||
| deprecationMessage: "There are no problem-matchers, this setting does not do anything." | ||
| format: | ||
| description: "Output format (checkstyle, diff, gcc, json, json1, quiet, tty)" | ||
| description: "Output format (checkstyle, diff, gcc, json, json1, quiet, tty, actions)" | ||
| required: false | ||
| default: "gcc" | ||
| version: | ||
|
|
@@ -91,9 +91,15 @@ runs: | |
| run: | | ||
| declare -a options | ||
| if [[ -n "${INPUT_SEVERITY}" ]]; then | ||
| options+=("-S ${INPUT_SEVERITY}") | ||
| 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}") | ||
|
Comment on lines
+94
to
+101
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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:
🔗 Analysis chainLGTM: 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 executedThe 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 |
||
| fi | ||
| options+=("--format=${INPUT_FORMAT}") | ||
| echo "options=${options[@]}" >> $GITHUB_OUTPUT | ||
|
|
||
| - name: Gather excluded paths | ||
|
|
@@ -152,6 +158,7 @@ runs: | |
| INPUT_EXCLUDE_ARGS: ${{ steps.exclude.outputs.excludes }} | ||
| INPUT_ADDITIONAL_FILE_ARGS: ${{ steps.additional.outputs.files }} | ||
| INPUT_SHELLCHECK_OPTIONS: ${{ steps.options.outputs.options }} | ||
| INPUT_FORMAT: ${{ inputs.format }} | ||
| run: | | ||
| statuscode=0 | ||
| declare -a filepaths | ||
|
|
@@ -203,15 +210,33 @@ runs: | |
| -type f ! -name '*.*' -perm /111 \ | ||
| -print0) | ||
|
|
||
| # Reformats shellcheck "json1" output as GitHub Actions workflow commands | ||
| reformat() { | ||
| if [ "${INPUT_FORMAT}" = "actions" ]; then | ||
| jq -r ' | ||
| def workflow_command: | ||
| if . == "note" or . == "info" or . == "style" | ||
| then "notice" | ||
| else . # error, warning | ||
| end; | ||
| .comments[] | | ||
| "::\(.level | workflow_command) file=\(.file),line=\(.line),endLine=\(.endLine),col=\(.column),endColumn=\(.endColumn)::\(.message) [SC\(.code)]" | ||
| ' | ||
| else | ||
| cat | ||
| fi | ||
| } | ||
mislav marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| set -o pipefail | ||
| if [[ -n "${INPUT_CHECK_TOGETHER}" ]]; then | ||
| "${{ github.action_path }}/shellcheck" \ | ||
| ${INPUT_SHELLCHECK_OPTIONS} \ | ||
| "${filepaths[@]}" || statuscode=$? | ||
| "${filepaths[@]}" | reformat || statuscode=$? | ||
| else | ||
| for file in "${filepaths[@]}"; do | ||
| "${{ github.action_path }}/shellcheck" \ | ||
| ${INPUT_SHELLCHECK_OPTIONS} \ | ||
| "$file" || statuscode=$? | ||
| "$file" | reformat || statuscode=$? | ||
| done | ||
| fi | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.