feat: add option to enable/disable annotations

This commit is contained in:
Fernandez Ludovic 2024-05-04 01:36:48 +02:00
parent 2bff406277
commit aebff4bd9c
5 changed files with 53 additions and 27 deletions

View File

@ -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. `args`: (optional) golangci-lint command line arguments.
Note: By default, the `.golangci.yml` file should be at the root of the repository. 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=` The location of the configuration file can be changed by using `--config=`

View File

@ -35,6 +35,10 @@ inputs:
restore existing caches, subject to other options. restore existing caches, subject to other options.
default: 'false' default: 'false'
required: false required: false
annotations:
description: "To Enable/disable GitHub Action annotations"
default: 'true'
required: false
args: args:
description: "golangci-lint command line arguments" description: "golangci-lint command line arguments"
default: "" default: ""

21
dist/post_run/index.js generated vendored
View File

@ -89287,15 +89287,18 @@ async function runLint(lintPath, patchPath) {
.map(([key, value]) => [key.toLowerCase(), value ?? ""]); .map(([key, value]) => [key.toLowerCase(), value ?? ""]);
const userArgsMap = new Map(userArgsList); const userArgsMap = new Map(userArgsList);
const userArgNames = new Set(userArgsList.map(([key]) => key)); const userArgNames = new Set(userArgsList.map(([key]) => key));
const formats = (userArgsMap.get("out-format") || "") const annotations = core.getInput(`annotations`).trim() !== "false";
.trim() if (annotations) {
.split(",") const formats = (userArgsMap.get("out-format") || "")
.filter((f) => f.length > 0) .trim()
.filter((f) => !f.startsWith(`github-actions`)) .split(",")
.concat("github-actions") .filter((f) => f.length > 0)
.join(","); .filter((f) => !f.startsWith(`github-actions`))
addedArgs.push(`--out-format=${formats}`); .concat("github-actions")
userArgs = userArgs.replace(/--out-format=\S*/gi, "").trim(); .join(",");
addedArgs.push(`--out-format=${formats}`);
userArgs = userArgs.replace(/--out-format=\S*/gi, "").trim();
}
if (isOnlyNewIssues()) { if (isOnlyNewIssues()) {
if (userArgNames.has(`new`) || userArgNames.has(`new-from-rev`) || userArgNames.has(`new-from-patch`)) { 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`); throw new Error(`please, don't specify manually --new* args when requesting only new issues`);

21
dist/run/index.js generated vendored
View File

@ -89287,15 +89287,18 @@ async function runLint(lintPath, patchPath) {
.map(([key, value]) => [key.toLowerCase(), value ?? ""]); .map(([key, value]) => [key.toLowerCase(), value ?? ""]);
const userArgsMap = new Map(userArgsList); const userArgsMap = new Map(userArgsList);
const userArgNames = new Set(userArgsList.map(([key]) => key)); const userArgNames = new Set(userArgsList.map(([key]) => key));
const formats = (userArgsMap.get("out-format") || "") const annotations = core.getInput(`annotations`).trim() !== "false";
.trim() if (annotations) {
.split(",") const formats = (userArgsMap.get("out-format") || "")
.filter((f) => f.length > 0) .trim()
.filter((f) => !f.startsWith(`github-actions`)) .split(",")
.concat("github-actions") .filter((f) => f.length > 0)
.join(","); .filter((f) => !f.startsWith(`github-actions`))
addedArgs.push(`--out-format=${formats}`); .concat("github-actions")
userArgs = userArgs.replace(/--out-format=\S*/gi, "").trim(); .join(",");
addedArgs.push(`--out-format=${formats}`);
userArgs = userArgs.replace(/--out-format=\S*/gi, "").trim();
}
if (isOnlyNewIssues()) { if (isOnlyNewIssues()) {
if (userArgNames.has(`new`) || userArgNames.has(`new-from-rev`) || userArgNames.has(`new-from-patch`)) { 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`); throw new Error(`please, don't specify manually --new* args when requesting only new issues`);

View File

@ -192,16 +192,20 @@ async function runLint(lintPath: string, patchPath: string): Promise<void> {
const userArgsMap = new Map<string, string>(userArgsList) const userArgsMap = new Map<string, string>(userArgsList)
const userArgNames = new Set<string>(userArgsList.map(([key]) => key)) const userArgNames = new Set<string>(userArgsList.map(([key]) => key))
const formats = (userArgsMap.get("out-format") || "") const annotations = core.getInput(`annotations`).trim() !== "false"
.trim()
.split(",")
.filter((f) => f.length > 0)
.filter((f) => !f.startsWith(`github-actions`))
.concat("github-actions")
.join(",")
addedArgs.push(`--out-format=${formats}`) if (annotations) {
userArgs = userArgs.replace(/--out-format=\S*/gi, "").trim() 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 (isOnlyNewIssues()) {
if (userArgNames.has(`new`) || userArgNames.has(`new-from-rev`) || userArgNames.has(`new-from-patch`)) { if (userArgNames.has(`new`) || userArgNames.has(`new-from-rev`) || userArgNames.has(`new-from-patch`)) {