Skip to content
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
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ jobs:
# The location of the configuration file can be changed by using `--config=`
# args: --config=/my/path/.golangci.yml --issues-exit-code=0

# Optional: if set to true then the action allows additional --out-format args (default of --out-format=github-actions remains)
# allow-extra-out-format-args: true

# Optional: show only new issues if it's a pull request. The default value is `false`.
# only-new-issues: true

Expand Down Expand Up @@ -121,6 +124,9 @@ jobs:
# The location of the configuration file can be changed by using `--config=`
# args: --config=/my/path/.golangci.yml --issues-exit-code=0

# Optional: if set to true then the action allows additional --out-format args (default of --out-format=github-actions remains)
# allow-extra-out-format-args: true

# Optional: show only new issues if it's a pull request. The default value is `false`.
# only-new-issues: true
```
Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ inputs:
description: "if set to true then the action doesn't cache or restore ~/.cache/go-build."
default: false
required: false
allow-extra-out-format-args:
description: "if set to true then the action allows additional --out-format args (default of --out-format=github-actions remains)"
default: false
required: false
runs:
using: "node16"
main: "dist/run/index.js"
Expand Down
6 changes: 4 additions & 2 deletions dist/post_run/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -66574,15 +66574,17 @@ function runLint(lintPath, patchPath) {
printOutput(res);
}
const userArgs = core.getInput(`args`);
const allowExtraOutFormatArgs = core.getInput(`allow-extra-out-format-args`);
const addedArgs = [];
const userArgNames = new Set(userArgs
.trim()
.split(/\s+/)
.map((arg) => arg.split(`=`)[0])
.filter((arg) => arg.startsWith(`-`))
.map((arg) => arg.replace(/^-+/, ``)));
if (userArgNames.has(`out-format`)) {
throw new Error(`please, don't change out-format for golangci-lint: it can be broken in a future`);
if (userArgNames.has(`out-format`) && !allowExtraOutFormatArgs) {
throw new Error(`please, don't change out-format for golangci-lint: it can be broken in a
future version (set 'allow-extra-out-format-args' input to true to override)`);
}
addedArgs.push(`--out-format=github-actions`);
if (patchPath) {
Expand Down
6 changes: 4 additions & 2 deletions dist/run/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -66574,15 +66574,17 @@ function runLint(lintPath, patchPath) {
printOutput(res);
}
const userArgs = core.getInput(`args`);
const allowExtraOutFormatArgs = core.getInput(`allow-extra-out-format-args`);
const addedArgs = [];
const userArgNames = new Set(userArgs
.trim()
.split(/\s+/)
.map((arg) => arg.split(`=`)[0])
.filter((arg) => arg.startsWith(`-`))
.map((arg) => arg.replace(/^-+/, ``)));
if (userArgNames.has(`out-format`)) {
throw new Error(`please, don't change out-format for golangci-lint: it can be broken in a future`);
if (userArgNames.has(`out-format`) && !allowExtraOutFormatArgs) {
throw new Error(`please, don't change out-format for golangci-lint: it can be broken in a
future version (set 'allow-extra-out-format-args' input to true to override)`);
}
addedArgs.push(`--out-format=github-actions`);
if (patchPath) {
Expand Down
6 changes: 4 additions & 2 deletions src/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ async function runLint(lintPath: string, patchPath: string): Promise<void> {
}

const userArgs = core.getInput(`args`)
const allowExtraOutFormatArgs = core.getInput(`allow-extra-out-format-args`)
const addedArgs: string[] = []

const userArgNames = new Set<string>(
Expand All @@ -127,8 +128,9 @@ async function runLint(lintPath: string, patchPath: string): Promise<void> {
.filter((arg) => arg.startsWith(`-`))
.map((arg) => arg.replace(/^-+/, ``))
)
if (userArgNames.has(`out-format`)) {
throw new Error(`please, don't change out-format for golangci-lint: it can be broken in a future`)
if (userArgNames.has(`out-format`) && !allowExtraOutFormatArgs) {
throw new Error(`please, don't change out-format for golangci-lint: it can be broken in a
future version (set 'allow-extra-out-format-args' input to true to override)`)
}
addedArgs.push(`--out-format=github-actions`)

Expand Down