setup-go
setup-go copied to clipboard
Annotation matcher can not match column ranges
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:
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.
Hello @silverwind Thank you for creating this issue. We will investigate it and get back to you as soon as we have some feedback.
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.
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.
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 thesetup-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.