mirror of
https://github.com/golangci/golangci-lint-action.git
synced 2025-12-14 23:11:14 +00:00
feat: embedded problem matchers
This commit is contained in:
parent
07a2113f55
commit
27164b2894
6 changed files with 54 additions and 33 deletions
17
README.md
17
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)
|
||||
|
|
|
|||
|
|
@ -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: ""
|
||||
|
|
|
|||
15
dist/post_run/index.js
generated
vendored
15
dist/post_run/index.js
generated
vendored
|
|
@ -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}`);
|
||||
|
|
|
|||
15
dist/run/index.js
generated
vendored
15
dist/run/index.js
generated
vendored
|
|
@ -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}`);
|
||||
|
|
|
|||
18
problem-matchers.json
Normal file
18
problem-matchers.json
Normal file
|
|
@ -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
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
18
src/run.ts
18
src/run.ts
|
|
@ -188,16 +188,26 @@ async function runLint(lintPath: string, patchPath: string): Promise<void> {
|
|||
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(",")
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue