Support extra --out-format args

This commit is contained in:
chainchad 2022-12-01 15:57:23 -05:00 committed by Fernandez Ludovic
parent 8c13ec4e5d
commit 4601e576f2
2 changed files with 8 additions and 2 deletions

View file

@ -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"

View file

@ -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>(
@ -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`)