Skip to content
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

Revert "Remove non-working problem matchers. (#88)" #103

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Root-Core
Copy link

This reverts PR #88 (commit 00cae50).

The problem matchers are working as intended, I think.

grafik

Copy link

coderabbitai bot commented Oct 14, 2024

📝 Walkthrough

Walkthrough

The changes introduce new JSON configuration files for problem matching in the ShellCheck GitHub action, specifically for gcc and tty outputs. These files define problem matchers that utilize regular expressions to parse and categorize output from ShellCheck. Additionally, the README.md is updated to include a new configuration option to disable the problem matcher and clarify output formats. The action.yaml file is modified to manage problem matchers more effectively, including adding new input parameters and steps for enabling and removing matchers during execution.

Changes

File Change Summary
.github/problem-matcher-gcc.json New JSON configuration for problem matching in GCC, defining two matchers for warnings and notices.
.github/problem-matcher-tty.json New JSON configuration for problem matching in TTY, defining a matcher with multiple regex patterns.
README.md Added disable_matcher option, clarified output formats for tty and gcc, and updated examples.
action.yaml Added steps for enabling and removing problem matchers, updated input parameters with deprecation messages, and clarified descriptions.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant GitHub Action
    participant ShellCheck
    participant Problem Matcher

    User->>GitHub Action: Trigger action
    GitHub Action->>ShellCheck: Run ShellCheck
    ShellCheck->>GitHub Action: Return output
    GitHub Action->>Problem Matcher: Enable matcher (if not disabled)
    Problem Matcher->>GitHub Action: Parse output
    GitHub Action->>User: Display results
    GitHub Action->>Problem Matcher: Remove matcher
Loading

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?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

‼️ IMPORTANT
Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 7

🧹 Outside diff range comments (1)
action.yaml (1)

Line range hint 9-25: LGTM! Consider updating usage examples in README.

The updates to input parameters improve the action's functionality and clarity:

  1. Deprecating ignore in favor of ignore_paths and ignore_names provides more specific control.
  2. The updated description for disable_matcher accurately reflects its current functionality.

Consider updating the README or documentation to include usage examples for the new ignore_paths and ignore_names parameters, helping users transition from the deprecated ignore parameter.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

📥 Commits

Files that changed from the base of the PR and between 00b27aa and d5258d8.

📒 Files selected for processing (4)
  • .github/problem-matcher-gcc.json (1 hunks)
  • .github/problem-matcher-tty.json (1 hunks)
  • README.md (1 hunks)
  • action.yaml (2 hunks)
🧰 Additional context used
🔇 Additional comments (7)
.github/problem-matcher-tty.json (3)

1-23: LGTM: Well-structured problem matcher configuration.

The overall structure of the problem matcher configuration is correct and follows the expected format for GitHub Actions problem matchers.


6-10: LGTM: Effective pattern for capturing file and line information.

The regular expression ^In\\s\\.?\\/?(.+)\\sline\\s(\\d+):$ effectively captures the file name and line number from shellcheck output. It correctly handles cases where the file path might start with "./" or "/".


11-13: Clarify the purpose of the catch-all pattern.

The second pattern uses the regular expression .*, which matches any string. While this can be useful for skipping a line in the output, it's worth clarifying its specific purpose in this context. Is it intended to consume a line of output that isn't needed for problem matching?

Could you please explain the rationale behind this catch-all pattern?

.github/problem-matcher-gcc.json (2)

3-16: Well-structured problem matcher for shellcheck warnings and errors.

The "shellcheck-gcc" matcher is effectively designed to capture warnings and errors from shellcheck output. The regular expression is comprehensive, allowing for both relative and absolute file paths, and accurately capturing all necessary information (file, line, column, severity, message, and code).


17-30: Consistent and well-designed problem matcher for shellcheck notices.

The "shellcheck-gcc-notice" matcher complements the previous matcher by specifically targeting notices. It maintains consistency in handling file paths and capturing relevant information. The hardcoded severity as "notice" is appropriate for this use case.

README.md (1)

143-162: Great improvements to the documentation!

The changes made to the README.md file significantly enhance the documentation for the ShellCheck GitHub action. The new section on disabling the problem matcher and the clarifications to the output format section provide users with valuable information and configuration options.

These additions align well with the PR objectives of reverting the removal of problem matchers and improve the overall usability of the action. The changes are consistent with the existing documentation style and provide clear examples for users to follow.

Great job on improving the documentation!

action.yaml (1)

Line range hint 1-243: Overall, the changes look good and align with the PR objectives.

The modifications to action.yaml successfully reintroduce the problem matcher functionality while improving the action's overall structure and clarity. Key improvements include:

  1. Addition of steps to enable and remove problem matchers.
  2. Deprecation of the ignore parameter in favor of more specific ignore_paths and ignore_names.
  3. Updated descriptions for input parameters to accurately reflect their functionality.

These changes enhance the action's usability and maintainability. The suggestions provided in the review comments are minor and aimed at further improving consistency and documentation.

Comment on lines +1 to +23
{
"problemMatcher": [
{
"owner": "shellcheck-tty",
"pattern": [
{
"regexp": "^In\\s\\.?\\/?(.+)\\sline\\s(\\d+):$",
"file": 1,
"line": 2
},
{
"regexp": ".*"
},
{
"regexp": "(SC\\d+):\\s(.+)$",
"code": 1,
"message": 2,
"loop": true
}
]
}
]
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

Overall assessment: Well-designed problem matcher configuration.

This problem matcher configuration for shellcheck-tty output is well-structured and should effectively integrate shellcheck warnings into the GitHub Actions workflow. It correctly captures file names, line numbers, shellcheck codes, and warning messages.

Key points:

  1. The structure follows the expected format for GitHub Actions problem matchers.
  2. The patterns effectively parse shellcheck output.
  3. The use of the "loop" property allows for capturing multiple warnings.

Consider addressing the following minor points:

  1. Clarify the purpose of the catch-all pattern (.*).
  2. Consider adding word boundaries to the shellcheck code pattern for increased precision.

This problem matcher will enhance the visibility and tracking of shellcheck issues within your GitHub Actions workflow, improving the overall code quality process.

Comment on lines +14 to +19
{
"regexp": "(SC\\d+):\\s(.+)$",
"code": 1,
"message": 2,
"loop": true
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

LGTM: Effective pattern for capturing shellcheck warnings with a minor suggestion.

The regular expression (SC\\d+):\\s(.+)$ effectively captures the shellcheck code and message. The "loop" property is correctly set to true, allowing multiple warnings to be captured.

Consider adding word boundaries to the shellcheck code pattern for increased precision:

-    "regexp": "(SC\\d+):\\s(.+)$",
+    "regexp": "\\b(SC\\d+):\\s(.+)$",

This change ensures that the pattern only matches "SC" when it's at the start of a word, potentially preventing false positives.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
{
"regexp": "(SC\\d+):\\s(.+)$",
"code": 1,
"message": 2,
"loop": true
}
{
"regexp": "\\b(SC\\d+):\\s(.+)$",
"code": 1,
"message": 2,
"loop": true
}

Comment on lines +1 to +32
{
"problemMatcher": [
{
"owner": "shellcheck-gcc",
"pattern": [
{
"regexp": "^\\.?\\/?(.+):(\\d+):(\\d+):\\s(warning|error):\\s(.*)\\s\\[(SC\\d+)\\]$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5,
"code": 6
}
]
},
{
"owner": "shellcheck-gcc-notice",
"severity": "notice",
"pattern": [
{
"regexp": "^\\.?\\/?(.+):(\\d+):(\\d+):\\s(note):\\s(.*)\\s\\[(SC\\d+)\\]$",
"file": 1,
"line": 2,
"column": 3,
"message": 5,
"code": 6
}
]
}
]
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

Well-structured problem matcher configuration for shellcheck output.

The overall structure of this file is excellent, providing comprehensive coverage for shellcheck output in GCC format. The separation of matchers for warnings/errors and notices enhances the precision of issue categorization in GitHub Actions.

For improved maintainability, consider adding a brief comment at the top of the file explaining its purpose and the format of shellcheck output it's designed to parse. This would help future maintainers quickly understand the file's role.

Comment on lines +143 to +154
## Disable problem matcher

If you do not want to have the problem-matcher annotate files, you can disable it
by setting `disable_matcher` to `true`.

```yaml
...
- name: Run ShellCheck
uses: ludeeus/action-shellcheck@master
with:
disable_matcher: true
```
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

LGTM! Consider adding a brief explanation of the problem matcher.

The new section about disabling the problem matcher is well-structured and provides a clear example of how to use the disable_matcher option. This addition aligns with the PR objectives and enhances the configurability of the action.

To further improve clarity, consider adding a brief explanation of what the problem matcher does and why a user might want to disable it. For example:

 ## Disable problem matcher

-If you do not want to have the problem-matcher annotate files, you can disable it
+The problem matcher automatically annotates files with issues found by ShellCheck.
+If you do not want to have these automatic annotations, you can disable the matcher
 by setting `disable_matcher` to `true`.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
## Disable problem matcher
If you do not want to have the problem-matcher annotate files, you can disable it
by setting `disable_matcher` to `true`.
```yaml
...
- name: Run ShellCheck
uses: ludeeus/action-shellcheck@master
with:
disable_matcher: true
```
## Disable problem matcher
The problem matcher automatically annotates files with issues found by ShellCheck.
If you do not want to have these automatic annotations, you can disable the matcher
by setting `disable_matcher` to `true`.
```yaml
...
- name: Run ShellCheck
uses: ludeeus/action-shellcheck@master
with:
disable_matcher: true
```

Comment on lines +159 to +162
Only `tty` and `gcc` produce file annotations via problem matcher, default is `gcc`.

- `tty` has multi-line log messages
- `gcc` has single-line log messages
- `tty` has multi-line log messages, but all annotations are reported as errors
- `gcc` has single-line log messages, so it's easier to parse with a problem matcher (including correct severity annotation)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

LGTM! Consider standardizing the format of the list items.

The changes to the output format section provide valuable clarification on the behavior of 'tty' and 'gcc' formats. This information helps users make an informed decision about which format to use based on their needs.

To improve consistency with the rest of the document, consider standardizing the format of the list items. For example:

-Only `tty` and `gcc` produce file annotations via problem matcher, default is `gcc`.
+Only `tty` and `gcc` produce file annotations via problem matcher. The default is `gcc`.

-- `tty` has multi-line log messages, but all annotations are reported as errors
-- `gcc` has single-line log messages, so it's easier to parse with a problem matcher (including correct severity annotation)
+- `tty`: Has multi-line log messages, but all annotations are reported as errors.
+- `gcc`: Has single-line log messages, making it easier to parse with a problem matcher (including correct severity annotation).
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
Only `tty` and `gcc` produce file annotations via problem matcher, default is `gcc`.
- `tty` has multi-line log messages
- `gcc` has single-line log messages
- `tty` has multi-line log messages, but all annotations are reported as errors
- `gcc` has single-line log messages, so it's easier to parse with a problem matcher (including correct severity annotation)
Only `tty` and `gcc` produce file annotations via problem matcher. The default is `gcc`.
- `tty`: Has multi-line log messages, but all annotations are reported as errors.
- `gcc`: Has single-line log messages, making it easier to parse with a problem matcher (including correct severity annotation).

Comment on lines +59 to +69
- name: Enable problem-matcher
shell: bash
env:
INPUT_FORMAT: ${{ inputs.format }}
INPUT_DISABLE_MATCHER: ${{ inputs.disable_matcher }}
run: |
problem_matcher_file="${{ github.action_path }}/.github/problem-matcher-${INPUT_FORMAT}.json"
if [[ "${INPUT_DISABLE_MATCHER}" != "true" && -f "$problem_matcher_file" ]]; then
echo "::add-matcher::$problem_matcher_file"
fi

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

LGTM! Consider adding a comment for clarity.

The new "Enable problem-matcher" step effectively reintroduces the problem matcher functionality, aligning with the PR objectives. The logic is sound, checking for both the disable flag and the existence of the matcher file.

Consider adding a brief comment explaining the purpose of this step, e.g.:

# Enable problem-matcher if not disabled and the matcher file exists

This would enhance readability and maintainability.

Comment on lines +233 to +239
- name: Remove problem-matcher
shell: bash
run: |
echo "::remove-matcher owner=shellcheck-gcc::"
echo "::remove-matcher owner=shellcheck-gcc-notice::"
echo "::remove-matcher owner=shellcheck-tty::"

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

LGTM! Consider using environment variables for consistency.

The new "Remove problem-matcher" step effectively cleans up the problem matchers added during the action's execution. This is a good practice to avoid potential conflicts with other actions.

For consistency with the "Enable problem-matcher" step, consider using environment variables for the matcher names:

- name: Remove problem-matcher
  shell: bash
  env:
    MATCHER_GCC: "shellcheck-gcc"
    MATCHER_GCC_NOTICE: "shellcheck-gcc-notice"
    MATCHER_TTY: "shellcheck-tty"
  run: |
    echo "::remove-matcher owner=${MATCHER_GCC}::"
    echo "::remove-matcher owner=${MATCHER_GCC_NOTICE}::"
    echo "::remove-matcher owner=${MATCHER_TTY}::"

This approach would make it easier to update matcher names in the future if needed.

@ludeeus
Copy link
Owner

ludeeus commented Oct 14, 2024

Until GitHub documents this in their developer documentation; this is not something I want to add back.

@Root-Core
Copy link
Author

The https://github.com/actions/ organization is verified to be part of github.com and contains documentation about problem matchers:

https://github.com/actions/toolkit/blob/main/docs/problem-matchers.md

The feature hasn't really changed since its inception. The last change to the documentation was on Jul 28, 2021, so I would consider it stable.

I don't know the exact issue that caused the problem matcher to be removed, but it was most likely just a bug with GitHub.

I understand your position, but please consider adding it back. It is a really useful feature.
Also, @coderabbitai seems happy and seems to understand problem matchers.
I don't know it though... so I don't know if you can trust it.

Copy link

coderabbitai bot commented Oct 14, 2024

Tip

For best results, initiate chat on the files or code changes.

@Root-Core: Thank you for sharing the official documentation from the GitHub Actions Toolkit. The problem matcher feature is indeed stable and well-supported. Restoring the problem matchers can significantly enhance the usability of this action by providing immediate feedback and annotations directly in the GitHub UI.

Considering that the previous removal might have been due to a temporary issue with GitHub, it seems reasonable to reinstate them. Including the problem matchers would greatly benefit users by highlighting issues in the code more effectively.

I support adding the problem matchers back to improve the user experience.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants