Skip to content

feat: embedded problem matchers #1037

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
13 changes: 12 additions & 1 deletion dist/post_run/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 12 additions & 1 deletion dist/run/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions problem-matchers.json
Original file line number Diff line number Diff line change
@@ -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
}
]
}
]
}
17 changes: 16 additions & 1 deletion src/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,12 +188,27 @@ async function runLint(lintPath: string, patchPath: string): Promise<void> {
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}`)
Expand Down
Loading