|
6 | 6 | "io" |
7 | 7 | "os" |
8 | 8 | "path/filepath" |
| 9 | + "strconv" |
9 | 10 |
|
10 | 11 | "github.com/golangci/golangci-lint/pkg/result" |
11 | 12 | ) |
@@ -72,20 +73,23 @@ func NewGitHubActionProblemMatchers(w io.Writer) *GitHubActionProblemMatchers { |
72 | 73 | } |
73 | 74 |
|
74 | 75 | func (p *GitHubActionProblemMatchers) Print(issues []result.Issue) error { |
75 | | - // Note: the file with the problem matcher definition should not be removed. |
76 | | - // A sleep can mitigate this problem but this will be flaky. |
77 | | - // |
78 | | - // Result if the file is removed prematurely: |
79 | | - // Error: Unable to process command '::add-matcher::/tmp/golangci-lint-action-problem-matchers.json' successfully. |
80 | | - // Error: Could not find file '/tmp/golangci-lint-action-problem-matchers.json'. |
81 | | - filename, err := p.storeProblemMatcher() |
82 | | - if err != nil { |
83 | | - return err |
84 | | - } |
85 | | - |
86 | | - _, _ = fmt.Fprintln(p.w, "::debug::problem matcher definition file: "+filename) |
| 76 | + // Used by the official GitHub Action (https://github.com/golangci/golangci-lint-action). |
| 77 | + // The problem matchers is embedded inside the GitHub Action to avoid errors: |
| 78 | + // https://github.com/golangci/golangci-lint/issues/4695 |
| 79 | + if ok, _ := strconv.ParseBool(os.Getenv("GOLANGCI_LINT_SKIP_GHA_PM_INSTALL")); !ok { |
| 80 | + // Note: the file with the problem matcher definition should not be removed. |
| 81 | + // A sleep can mitigate this problem but this will be flaky. |
| 82 | + // |
| 83 | + // Result if the file is removed prematurely: |
| 84 | + // Error: Unable to process command '::add-matcher::/tmp/golangci-lint-action-problem-matchers.json' successfully. |
| 85 | + // Error: Could not find file '/tmp/golangci-lint-action-problem-matchers.json'. |
| 86 | + filename, err := p.storeProblemMatcher() |
| 87 | + if err != nil { |
| 88 | + return err |
| 89 | + } |
87 | 90 |
|
88 | | - _, _ = fmt.Fprintln(p.w, "::add-matcher::"+filename) |
| 91 | + _, _ = fmt.Fprintln(p.w, "::add-matcher::"+filename) |
| 92 | + } |
89 | 93 |
|
90 | 94 | for ind := range issues { |
91 | 95 | _, err := fmt.Fprintln(p.w, formatIssueAsProblemMatcher(&issues[ind])) |
@@ -115,6 +119,9 @@ func (p *GitHubActionProblemMatchers) storeProblemMatcher() (string, error) { |
115 | 119 | return file.Name(), nil |
116 | 120 | } |
117 | 121 |
|
| 122 | +// generateProblemMatcher generated the problem matchers file. |
| 123 | +// Should be synced with the official GitHub Action. |
| 124 | +// https://github.com/golangci/golangci-lint-action/blob/master/problem-matchers.json |
118 | 125 | func generateProblemMatcher() GHProblemMatchers { |
119 | 126 | return GHProblemMatchers{ |
120 | 127 | Matchers: []GHMatcher{ |
|
0 commit comments