From 4601e576f22fa4e2df10656b4a34de75e3e53b93 Mon Sep 17 00:00:00 2001 From: chainchad <96362174+chainchad@users.noreply.github.com> Date: Thu, 1 Dec 2022 15:57:23 -0500 Subject: [PATCH 1/3] Support extra --out-format args --- action.yml | 4 ++++ src/run.ts | 6 ++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index 3e5d74d4d0..4b03858864 100644 --- a/action.yml +++ b/action.yml @@ -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" diff --git a/src/run.ts b/src/run.ts index 2fd55d51ce..e72026da3d 100644 --- a/src/run.ts +++ b/src/run.ts @@ -117,6 +117,7 @@ async function runLint(lintPath: string, patchPath: string): Promise { } const userArgs = core.getInput(`args`) + const allowExtraOutFormatArgs = core.getInput(`allow-extra-out-format-args`) const addedArgs: string[] = [] const userArgNames = new Set( @@ -127,8 +128,9 @@ async function runLint(lintPath: string, patchPath: string): Promise { .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`) From de5e6fe60adb985ae9e2b6a7c9930d8e3a48f83b Mon Sep 17 00:00:00 2001 From: chainchad <96362174+chainchad@users.noreply.github.com> Date: Fri, 2 Dec 2022 14:45:55 -0500 Subject: [PATCH 2/3] Add built dist files --- dist/post_run/index.js | 6 ++++-- dist/run/index.js | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/dist/post_run/index.js b/dist/post_run/index.js index 25c77c3128..6c5da09749 100644 --- a/dist/post_run/index.js +++ b/dist/post_run/index.js @@ -66574,6 +66574,7 @@ 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() @@ -66581,8 +66582,9 @@ function runLint(lintPath, patchPath) { .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) { diff --git a/dist/run/index.js b/dist/run/index.js index 6dbd2dc6fb..c115ecffb0 100644 --- a/dist/run/index.js +++ b/dist/run/index.js @@ -66574,6 +66574,7 @@ 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() @@ -66581,8 +66582,9 @@ function runLint(lintPath, patchPath) { .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) { From 0df9ba717cd483bb703ef6a5091997046f0c44dc Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Fri, 9 Jun 2023 14:10:20 +0200 Subject: [PATCH 3/3] review: add documentation --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 4b3ca130df..b535707179 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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 ```