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

Annotation matcher can not match column ranges #475

Open
silverwind opened this issue Apr 30, 2024 · 4 comments
Open

Annotation matcher can not match column ranges #475

silverwind opened this issue Apr 30, 2024 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@silverwind
Copy link

silverwind commented Apr 30, 2024

Description:
Tools like gopls check <files> can output line column ranges but the matcher installed by this action can not match them.

This action can not match these column ranges because the - character is not included in the regex ^\\s*(.+\\.go):(?:(\\d+):(\\d+):)? (.*). All such lines in this sample run should trigger a error annotation, but currently ones ones without a - trigger it:

image

Action version:
v5.0.0

Platform:
all

Runner type:
all

Tools version:
all

Repro steps:
https://github.com/go-gitea/gitea/actions/runs/8883003671/job/24388906594

Expected behavior:
Lines with - in the column field to be detected as error annotation.

Actual behavior:
Only lines without - in the column are detected as error annotation.

@silverwind silverwind added bug Something isn't working needs triage labels Apr 30, 2024
@HarithaVattikuti
Copy link
Contributor

Hello @silverwind
Thank you for creating this issue. We will investigate it and get back to you as soon as we have some feedback.

@priyagupta108
Copy link

Hello @silverwind, thank you for your report. I understood your concern. Currently, the problem matcher in the setup-go action is designed to capture a single line and column number where an error originates, and it does not support ranges of line and column numbers. This is primarily due to how GitHub's UI displays these errors. For more details, you can refer to the Problem Matchers documentation. Please note that GitHub's UI may not be able to display a range of columns as a single problem.

@silverwind
Copy link
Author

silverwind commented May 30, 2024

I think the intention of gopls is clear here, it reports the line range as an error.

The only thing that is a bit unconventional is that gopls check is not usually used as a CLI linter, it is usually used inside a editor extension like in VSCode where these line range errors also are recognized and highlighted as expected.

@priyagupta108
Copy link

Thank you for your valuable input, @silverwind. We will take your suggestion into consideration for future enhancement to our problem matcher.
In the meantime, here are potential workarounds you may consider:

  • Custom Parser Script: You could create a custom script that parses the gopls check output into a format that the problem matcher can recognize. This could be added as a step in your workflow before the setup-go action:
- name: Parse gopls check output
  run: ./custom-parser-script.sh
- name: Set up Go
  uses: actions/setup-go@v5
  with:
    go-version: '1.20'
  • Custom Problem Matcher: You could also consider creating a custom problem matcher. These are a way for GitHub Actions to interpret and highlight error messages in the console output. You could create a matcher to handle the gopls check output:
- name: Set up Go
  uses: actions/setup-go@v5
  with:
    go-version: '1.20'
- name: Add problem matchers for gopls check
  run: echo "::add-matcher::.github/problem-matcher.json"

For this, you'd need to create a .github/problem-matcher.json file in your repository with the appropriate patterns for gopls check.
For more information on how to create a custom problem matcher, please refer to the GitHub Documentation.

We sincerely appreciate your understanding and contribution to the community.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants