setup-go icon indicating copy to clipboard operation
setup-go copied to clipboard

Annotation matcher can not match column ranges

Open silverwind opened this issue 9 months ago • 4 comments

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 avatar Apr 30 '24 15:04 silverwind

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

HarithaVattikuti avatar May 01 '24 18:05 HarithaVattikuti

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.

priyagupta108 avatar May 30 '24 08:05 priyagupta108

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.

silverwind avatar May 30 '24 12:05 silverwind

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.

priyagupta108 avatar Jun 03 '24 07:06 priyagupta108