Do not fail on only Warnings.

This commit is contained in:
Michael J Mulligan 2021-03-31 16:40:36 +01:00
parent e3c53feccf
commit 168c94fc3c
4 changed files with 27 additions and 3 deletions

View file

@ -32,6 +32,10 @@ inputs:
description: "if set to true then the action don't cache or restore ~/.cache/go-build." description: "if set to true then the action don't cache or restore ~/.cache/go-build."
default: false default: false
required: true required: true
allow-warnings:
description: "if set to true then the action don't fail with just golangci-lint warnings."
default: false
required: false
runs: runs:
using: "node12" using: "node12"
main: "dist/run/index.js" main: "dist/run/index.js"

View file

@ -6860,7 +6860,14 @@ function runLint(lintPath, patchPath) {
// TODO: support reviewdog or leaving comments by GitHub API. // TODO: support reviewdog or leaving comments by GitHub API.
printOutput(exc); printOutput(exc);
if (exc.code === 1) { if (exc.code === 1) {
core.setFailed(`issues found`); const allowWarnings = core.getInput(`allow-warnings`, { required: true }).trim();
const errorRegex = /^::error.+$/m;
if (allowWarnings.toLowerCase() == "true" && !exc.stdout.match(errorRegex)) {
core.info(`golangci-lint found no errors`);
}
else {
core.setFailed(`issues found`);
}
} }
else { else {
core.setFailed(`golangci-lint exit with code ${exc.code}`); core.setFailed(`golangci-lint exit with code ${exc.code}`);

9
dist/run/index.js vendored
View file

@ -6870,7 +6870,14 @@ function runLint(lintPath, patchPath) {
// TODO: support reviewdog or leaving comments by GitHub API. // TODO: support reviewdog or leaving comments by GitHub API.
printOutput(exc); printOutput(exc);
if (exc.code === 1) { if (exc.code === 1) {
core.setFailed(`issues found`); const allowWarnings = core.getInput(`allow-warnings`, { required: true }).trim();
const errorRegex = /^::error.+$/m;
if (allowWarnings.toLowerCase() == "true" && !exc.stdout.match(errorRegex)) {
core.info(`golangci-lint found no errors`);
}
else {
core.setFailed(`issues found`);
}
} }
else { else {
core.setFailed(`golangci-lint exit with code ${exc.code}`); core.setFailed(`golangci-lint exit with code ${exc.code}`);

View file

@ -175,7 +175,13 @@ async function runLint(lintPath: string, patchPath: string): Promise<void> {
printOutput(exc) printOutput(exc)
if (exc.code === 1) { if (exc.code === 1) {
core.setFailed(`issues found`) const allowWarnings = core.getInput(`allow-warnings`, { required: true }).trim()
const errorRegex = /^::error.+$/m
if (allowWarnings.toLowerCase() == "true" && !exc.stdout.match(errorRegex)) {
core.info(`golangci-lint found no errors`)
} else {
core.setFailed(`issues found`)
}
} else { } else {
core.setFailed(`golangci-lint exit with code ${exc.code}`) core.setFailed(`golangci-lint exit with code ${exc.code}`)
} }