diff --git a/README.md b/README.md index 4f8d941..b335326 100644 --- a/README.md +++ b/README.md @@ -163,6 +163,18 @@ with: # ... ``` +`annotations`: (optional) To enable/disable GitHub Action annotations. +If disabled (`false`), the output format(s) will follow the golangci-lint configuration file and use the same default as golangci-lint (i.e. `colored-line-number`). +https://golangci-lint.run/usage/configuration/#output-configuration +The default value is `true`. + +```yml +uses: golangci/golangci-lint-action@v5 +with: + annotations: false + # ... +``` + `args`: (optional) golangci-lint command line arguments. Note: By default, the `.golangci.yml` file should be at the root of the repository. The location of the configuration file can be changed by using `--config=` diff --git a/action.yml b/action.yml index a85cf66..b498ad0 100644 --- a/action.yml +++ b/action.yml @@ -35,6 +35,10 @@ inputs: restore existing caches, subject to other options. default: 'false' required: false + annotations: + description: "To Enable/disable GitHub Action annotations" + default: 'true' + required: false args: description: "golangci-lint command line arguments" default: "" diff --git a/dist/post_run/index.js b/dist/post_run/index.js index 9dd2226..b6746c4 100644 --- a/dist/post_run/index.js +++ b/dist/post_run/index.js @@ -89287,15 +89287,18 @@ async function runLint(lintPath, patchPath) { .map(([key, value]) => [key.toLowerCase(), value ?? ""]); const userArgsMap = new Map(userArgsList); const userArgNames = new Set(userArgsList.map(([key]) => key)); - const formats = (userArgsMap.get("out-format") || "") - .trim() - .split(",") - .filter((f) => f.length > 0) - .filter((f) => !f.startsWith(`github-actions`)) - .concat("github-actions") - .join(","); - addedArgs.push(`--out-format=${formats}`); - userArgs = userArgs.replace(/--out-format=\S*/gi, "").trim(); + const annotations = core.getInput(`annotations`).trim() !== "false"; + if (annotations) { + const formats = (userArgsMap.get("out-format") || "") + .trim() + .split(",") + .filter((f) => f.length > 0) + .filter((f) => !f.startsWith(`github-actions`)) + .concat("github-actions") + .join(","); + addedArgs.push(`--out-format=${formats}`); + userArgs = userArgs.replace(/--out-format=\S*/gi, "").trim(); + } if (isOnlyNewIssues()) { if (userArgNames.has(`new`) || userArgNames.has(`new-from-rev`) || userArgNames.has(`new-from-patch`)) { throw new Error(`please, don't specify manually --new* args when requesting only new issues`); diff --git a/dist/run/index.js b/dist/run/index.js index b015ef3..278dc9a 100644 --- a/dist/run/index.js +++ b/dist/run/index.js @@ -89287,15 +89287,18 @@ async function runLint(lintPath, patchPath) { .map(([key, value]) => [key.toLowerCase(), value ?? ""]); const userArgsMap = new Map(userArgsList); const userArgNames = new Set(userArgsList.map(([key]) => key)); - const formats = (userArgsMap.get("out-format") || "") - .trim() - .split(",") - .filter((f) => f.length > 0) - .filter((f) => !f.startsWith(`github-actions`)) - .concat("github-actions") - .join(","); - addedArgs.push(`--out-format=${formats}`); - userArgs = userArgs.replace(/--out-format=\S*/gi, "").trim(); + const annotations = core.getInput(`annotations`).trim() !== "false"; + if (annotations) { + const formats = (userArgsMap.get("out-format") || "") + .trim() + .split(",") + .filter((f) => f.length > 0) + .filter((f) => !f.startsWith(`github-actions`)) + .concat("github-actions") + .join(","); + addedArgs.push(`--out-format=${formats}`); + userArgs = userArgs.replace(/--out-format=\S*/gi, "").trim(); + } if (isOnlyNewIssues()) { if (userArgNames.has(`new`) || userArgNames.has(`new-from-rev`) || userArgNames.has(`new-from-patch`)) { throw new Error(`please, don't specify manually --new* args when requesting only new issues`); diff --git a/src/run.ts b/src/run.ts index 60ff432..db8cf53 100644 --- a/src/run.ts +++ b/src/run.ts @@ -192,16 +192,20 @@ async function runLint(lintPath: string, patchPath: string): Promise { const userArgsMap = new Map(userArgsList) const userArgNames = new Set(userArgsList.map(([key]) => key)) - const formats = (userArgsMap.get("out-format") || "") - .trim() - .split(",") - .filter((f) => f.length > 0) - .filter((f) => !f.startsWith(`github-actions`)) - .concat("github-actions") - .join(",") + const annotations = core.getInput(`annotations`).trim() !== "false" - addedArgs.push(`--out-format=${formats}`) - userArgs = userArgs.replace(/--out-format=\S*/gi, "").trim() + if (annotations) { + const formats = (userArgsMap.get("out-format") || "") + .trim() + .split(",") + .filter((f) => f.length > 0) + .filter((f) => !f.startsWith(`github-actions`)) + .concat("github-actions") + .join(",") + + addedArgs.push(`--out-format=${formats}`) + userArgs = userArgs.replace(/--out-format=\S*/gi, "").trim() + } if (isOnlyNewIssues()) { if (userArgNames.has(`new`) || userArgNames.has(`new-from-rev`) || userArgNames.has(`new-from-patch`)) {