Skip to content

Commit

Permalink
feat: option to use the matchers file inside the Official GitHub Action
Browse files Browse the repository at this point in the history
  • Loading branch information
ldez committed May 6, 2024
1 parent a6711f9 commit 77bc9b9
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion pkg/printers/githubaction_problem_matchers.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"io"
"os"
"path/filepath"
"strconv"

"github.com/golangci/golangci-lint/pkg/result"
)
Expand Down Expand Up @@ -85,7 +86,12 @@ func (p *GitHubActionProblemMatchers) Print(issues []result.Issue) error {

_, _ = fmt.Fprintln(p.w, "::debug::problem matcher definition file: "+filename)

_, _ = fmt.Fprintln(p.w, "::add-matcher::"+filename)
// Used by the official GitHub Action (https://github.com/golangci/golangci-lint-action).
// The problem matchers is embedded inside the GitHub Action to avoid errors:
// https://github.com/golangci/golangci-lint/issues/4695
if ok, _ := strconv.ParseBool(os.Getenv("GOLANGCI_LINT_SKIP_GHA_PM_INSTALL")); !ok {
_, _ = fmt.Fprintln(p.w, "::add-matcher::"+filename)
}

for ind := range issues {
_, err := fmt.Fprintln(p.w, formatIssueAsProblemMatcher(&issues[ind]))
Expand Down Expand Up @@ -115,6 +121,9 @@ func (p *GitHubActionProblemMatchers) storeProblemMatcher() (string, error) {
return file.Name(), nil
}

// generateProblemMatcher generated the problem matchers file.
// Should be synced with the official GitHub Action.
// https://github.com/golangci/golangci-lint-action/blob/master/problem-matchers.json
func generateProblemMatcher() GHProblemMatchers {
return GHProblemMatchers{
Matchers: []GHMatcher{
Expand Down

0 comments on commit 77bc9b9

Please sign in to comment.