diff --git a/README.md b/README.md index be8bdee..d7d97fd 100644 --- a/README.md +++ b/README.md @@ -233,23 +233,6 @@ with: # ... ``` -### `problem-matchers` - -(optional) - -To enable/disable GitHub Action annotations problem matchers (requires `annotations: true`). - -The problem matchers allows the display file information (path, position) inside the logs. - -The default value is `true`. - -```yml -uses: golangci/golangci-lint-action@v5 -with: - problem-matchers: false - # ... -``` - ### `args` (optional) diff --git a/action.yml b/action.yml index 4a35def..bb4a508 100644 --- a/action.yml +++ b/action.yml @@ -40,10 +40,6 @@ inputs: description: "To Enable/disable GitHub Action annotations" default: 'true' required: false - problem-matchers: - description: "To Enable/disable GitHub Action annotations problem matchers" - default: 'true' - required: false args: description: "golangci-lint command line arguments" default: "" diff --git a/dist/post_run/index.js b/dist/post_run/index.js index 53d0a84..c8d2b2f 100644 --- a/dist/post_run/index.js +++ b/dist/post_run/index.js @@ -89292,15 +89292,22 @@ async function runLint(lintPath, patchPath) { const userArgNames = new Set(userArgsList.map(([key]) => key)); const annotations = core.getBooleanInput(`annotations`); if (annotations) { - let ghaFormat = `github-actions-problem-matchers`; - if (!core.getBooleanInput(`problem-matchers`)) { - ghaFormat = `github-actions`; + // Skip the problem matchers installed by the binary, + // use the embedded files. + process.env.GOLANGCI_LINT_SKIP_GHA_PM_INSTALL = `true`; + const matchersPath = path.join(__dirname, "../..", "problem-matchers.json"); + let ghaFormat = `github-actions`; + if (fs.existsSync(matchersPath)) { + ghaFormat = `github-actions-problem-matchers`; + // Adds problem matchers. + // https://github.com/actions/setup-go/blob/cdcb36043654635271a94b9a6d1392de5bb323a7/src/main.ts#L81-L83 + core.info(`##[add-matcher]${matchersPath}`); } const formats = (userArgsMap.get("out-format") || "") .trim() .split(",") .filter((f) => f.length > 0) - .filter((f) => !f.startsWith(ghaFormat)) + .filter((f) => !f.startsWith(`github-actions`)) .concat(ghaFormat) .join(","); addedArgs.push(`--out-format=${formats}`); diff --git a/dist/run/index.js b/dist/run/index.js index 7b892e7..4601494 100644 --- a/dist/run/index.js +++ b/dist/run/index.js @@ -89292,15 +89292,22 @@ async function runLint(lintPath, patchPath) { const userArgNames = new Set(userArgsList.map(([key]) => key)); const annotations = core.getBooleanInput(`annotations`); if (annotations) { - let ghaFormat = `github-actions-problem-matchers`; - if (!core.getBooleanInput(`problem-matchers`)) { - ghaFormat = `github-actions`; + // Skip the problem matchers installed by the binary, + // use the embedded files. + process.env.GOLANGCI_LINT_SKIP_GHA_PM_INSTALL = `true`; + const matchersPath = path.join(__dirname, "../..", "problem-matchers.json"); + let ghaFormat = `github-actions`; + if (fs.existsSync(matchersPath)) { + ghaFormat = `github-actions-problem-matchers`; + // Adds problem matchers. + // https://github.com/actions/setup-go/blob/cdcb36043654635271a94b9a6d1392de5bb323a7/src/main.ts#L81-L83 + core.info(`##[add-matcher]${matchersPath}`); } const formats = (userArgsMap.get("out-format") || "") .trim() .split(",") .filter((f) => f.length > 0) - .filter((f) => !f.startsWith(ghaFormat)) + .filter((f) => !f.startsWith(`github-actions`)) .concat(ghaFormat) .join(","); addedArgs.push(`--out-format=${formats}`); diff --git a/problem-matchers.json b/problem-matchers.json new file mode 100644 index 0000000..14f94bb --- /dev/null +++ b/problem-matchers.json @@ -0,0 +1,18 @@ +{ + "problemMatcher": [ + { + "owner": "golangci-lint-action", + "severity": "error", + "pattern": [ + { + "regexp": "^([^\\s]+)\\s+([^:]+):(\\d+):(?:(\\d+):)?\\s+(.+)$", + "file": 2, + "line": 3, + "column": 4, + "severity": 1, + "message": 5 + } + ] + } + ] +} \ No newline at end of file diff --git a/src/run.ts b/src/run.ts index e0d0114..e64e1a7 100644 --- a/src/run.ts +++ b/src/run.ts @@ -188,16 +188,26 @@ async function runLint(lintPath: string, patchPath: string): Promise { const annotations = core.getBooleanInput(`annotations`) if (annotations) { - let ghaFormat = `github-actions-problem-matchers` - if (!core.getBooleanInput(`problem-matchers`)) { - ghaFormat = `github-actions` + // Skip the problem matchers installed by the binary, + // use the embedded files. + process.env.GOLANGCI_LINT_SKIP_GHA_PM_INSTALL = `true` + + const matchersPath = path.join(__dirname, "../..", "problem-matchers.json") + + let ghaFormat = `github-actions` + if (fs.existsSync(matchersPath)) { + ghaFormat = `github-actions-problem-matchers` + + // Adds problem matchers. + // https://github.com/actions/setup-go/blob/cdcb36043654635271a94b9a6d1392de5bb323a7/src/main.ts#L81-L83 + core.info(`##[add-matcher]${matchersPath}`) } const formats = (userArgsMap.get("out-format") || "") .trim() .split(",") .filter((f) => f.length > 0) - .filter((f) => !f.startsWith(ghaFormat)) + .filter((f) => !f.startsWith(`github-actions`)) .concat(ghaFormat) .join(",")