Add option to configure additional output format

This commit is contained in:
Florian Gessner 2022-05-22 10:20:12 +02:00
parent f3c064d740
commit 7d26dd30b9
3 changed files with 12 additions and 1 deletions

View file

@ -57,6 +57,9 @@ jobs:
# Optional: show only new issues if it's a pull request. The default value is `false`. # Optional: show only new issues if it's a pull request. The default value is `false`.
# only-new-issues: true # only-new-issues: true
# Optional: render results of golangci-lint additionally into a file; syntax: <format>:<file_path> (see also https://golangci-lint.run/usage/configuration/#output-configuration)
# output-file: checkstyle:golangci_lint.xml
# Optional: if set to true then the all caching functionality will be complete disabled, # Optional: if set to true then the all caching functionality will be complete disabled,
# takes precedence over all other caching options. # takes precedence over all other caching options.
# skip-cache: true # skip-cache: true
@ -115,6 +118,9 @@ jobs:
# Optional: show only new issues if it's a pull request. The default value is `false`. # Optional: show only new issues if it's a pull request. The default value is `false`.
# only-new-issues: true # only-new-issues: true
# Optional: render results of golangci-lint additionally into a file; syntax: <format>:<file_path> (see also https://golangci-lint.run/usage/configuration/#output-configuration)
# output-file: checkstyle:golangci_lint.xml
``` ```
You will also likely need to add the following `.gitattributes` file to ensure that line endings for windows builds are properly formatted: You will also likely need to add the following `.gitattributes` file to ensure that line endings for windows builds are properly formatted:

View file

@ -20,6 +20,9 @@ inputs:
description: "if set to true and the action runs on a pull request - the action outputs only newly found issues" description: "if set to true and the action runs on a pull request - the action outputs only newly found issues"
default: false default: false
required: true required: true
output-file:
description: "render results of golangci-lint additionally into a file; syntax: <format>:<file_path> (see also https://golangci-lint.run/usage/configuration/#output-configuration)"
required: false
skip-cache: skip-cache:
description: | description: |
if set to true then the all caching functionality will be complete disabled, if set to true then the all caching functionality will be complete disabled,

View file

@ -130,7 +130,9 @@ async function runLint(lintPath: string, patchPath: string): Promise<void> {
if (userArgNames.has(`out-format`)) { if (userArgNames.has(`out-format`)) {
throw new Error(`please, don't change out-format for golangci-lint: it can be broken in a future`) throw new Error(`please, don't change out-format for golangci-lint: it can be broken in a future`)
} }
addedArgs.push(`--out-format=github-actions`)
const outputFile = core.getInput(`output-file`, { required: false }).trim()
addedArgs.push(`--out-format=github-actions${outputFile ? ',' + outputFile : ''}`)
if (patchPath) { if (patchPath) {
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`)) {