Skip to content

Commit

Permalink
feat: add option to enable/disable annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
ldez committed May 3, 2024
1 parent 2bff406 commit aebff4b
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 28 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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=`
Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: ""
Expand Down
21 changes: 12 additions & 9 deletions dist/post_run/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 12 additions & 9 deletions dist/run/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 14 additions & 10 deletions src/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,16 +192,20 @@ async function runLint(lintPath: string, patchPath: string): Promise<void> {
const userArgsMap = new Map<string, string>(userArgsList)
const userArgNames = new Set<string>(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`)) {
Expand Down

0 comments on commit aebff4b

Please sign in to comment.