diff --git a/README.md b/README.md index 5e498a32a7..d7d97fd979 100644 --- a/README.md +++ b/README.md @@ -10,12 +10,13 @@ The action runs [golangci-lint](https://github.com/golangci/golangci-lint) and r ## Compatibility +* `v6.0.0+` works with `golangci-lint` version >= `v1.58.1`. * `v5.0.0+` removes `skip-pkg-cache` and `skip-build-cache` because the cache related to Go itself is already handled by `actions/setup-go`. * `v4.0.0+` requires an explicit `actions/setup-go` installation step before using this action: `uses: actions/setup-go@v5`. The `skip-go-installation` option has been removed. -* `v2.0.0+` works with `golangci-lint` version >= `v1.28.3` -* `v1.2.2` is deprecated due to we forgot to change the minimum version of `golangci-lint` to `v1.28.3` ([issue](https://github.com/golangci/golangci-lint-action/issues/39)) -* `v1.2.1` works with `golangci-lint` version >= `v1.14.0` ([issue](https://github.com/golangci/golangci-lint-action/issues/39)) +* `v2.0.0+` works with `golangci-lint` version >= `v1.28.3`. +* `v1.2.2` is deprecated due to we forgot to change the minimum version of `golangci-lint` to `v1.28.3` ([issue](https://github.com/golangci/golangci-lint-action/issues/39)). +* `v1.2.1` works with `golangci-lint` version >= `v1.14.0` ([issue](https://github.com/golangci/golangci-lint-action/issues/39)). ## How to use diff --git a/dist/post_run/index.js b/dist/post_run/index.js index 87f67815a6..c8d2b2f1d1 100644 --- a/dist/post_run/index.js +++ b/dist/post_run/index.js @@ -89292,12 +89292,23 @@ async function runLint(lintPath, patchPath) { const userArgNames = new Set(userArgsList.map(([key]) => key)); const annotations = core.getBooleanInput(`annotations`); if (annotations) { + // 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(`github-actions`)) - .concat("github-actions") + .concat(ghaFormat) .join(","); addedArgs.push(`--out-format=${formats}`); userArgs = userArgs.replace(/--out-format=\S*/gi, "").trim(); diff --git a/dist/run/index.js b/dist/run/index.js index 11ef531598..4601494826 100644 --- a/dist/run/index.js +++ b/dist/run/index.js @@ -89292,12 +89292,23 @@ async function runLint(lintPath, patchPath) { const userArgNames = new Set(userArgsList.map(([key]) => key)); const annotations = core.getBooleanInput(`annotations`); if (annotations) { + // 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(`github-actions`)) - .concat("github-actions") + .concat(ghaFormat) .join(","); addedArgs.push(`--out-format=${formats}`); userArgs = userArgs.replace(/--out-format=\S*/gi, "").trim(); diff --git a/problem-matchers.json b/problem-matchers.json new file mode 100644 index 0000000000..14f94bb601 --- /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 9cffa9c690..e64e1a71e5 100644 --- a/src/run.ts +++ b/src/run.ts @@ -188,12 +188,27 @@ async function runLint(lintPath: string, patchPath: string): Promise { const annotations = core.getBooleanInput(`annotations`) if (annotations) { + // 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(`github-actions`)) - .concat("github-actions") + .concat(ghaFormat) .join(",") addedArgs.push(`--out-format=${formats}`)