feat: golangci-lint v2 support (#1198)

This commit is contained in:
Ludovic Fernandez
2025-03-24 15:16:39 +01:00
committed by GitHub
parent 1f07148fa0
commit dec74fa030
15 changed files with 106 additions and 165 deletions

View File

@@ -51,7 +51,7 @@ async function runLint(binPath: string, patchPath: string): Promise<void> {
printOutput(res)
}
let userArgs = core.getInput(`args`)
const userArgs = core.getInput(`args`)
const addedArgs: string[] = []
const userArgsList = userArgs
@@ -76,23 +76,13 @@ async function runLint(binPath: string, patchPath: string): Promise<void> {
}
}
const formats = (userArgsMap.get("out-format") || "")
.trim()
.split(",")
.filter((f) => f.length > 0)
.filter((f) => !f.startsWith(`github-actions`)) // Removes `github-actions` format.
.join(",")
if (formats) {
// Adds formats but without `github-actions` format.
addedArgs.push(`--out-format=${formats}`)
}
// Removes `--out-format` from the user flags because it's already inside `addedArgs`.
userArgs = userArgs.replace(/--out-format=\S*/gi, "").trim()
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`) ||
userArgNames.has(`new-from-merge-base`)
) {
throw new Error(`please, don't specify manually --new* args when requesting only new issues`)
}
@@ -110,6 +100,7 @@ async function runLint(binPath: string, patchPath: string): Promise<void> {
// Override config values.
addedArgs.push(`--new=false`)
addedArgs.push(`--new-from-rev=`)
addedArgs.push(`--new-from-merge-base=`)
}
break
case `merge_group`:
@@ -118,6 +109,7 @@ async function runLint(binPath: string, patchPath: string): Promise<void> {
// Override config values.
addedArgs.push(`--new=false`)
addedArgs.push(`--new-from-patch=`)
addedArgs.push(`--new-from-merge-base=`)
break
default:
break
@@ -150,7 +142,6 @@ async function runLint(binPath: string, patchPath: string): Promise<void> {
core.info(`golangci-lint found no issues`)
} catch (exc) {
// This logging passes issues to GitHub annotations but comments can be more convenient for some users.
// TODO: support reviewdog or leaving comments by GitHub API.
printOutput(exc)
if (exc.code === 1) {