From 715933c312d05a5ca7e002d3bba7a50858cf6df1 Mon Sep 17 00:00:00 2001 From: Peter Trifanov Date: Fri, 10 Jan 2025 14:20:14 +0100 Subject: [PATCH] Publish golangci-lint report to SonarQube --- .cirrus/modules/build.star | 2 +- sonar-go-to-slang/build.gradle.kts | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/.cirrus/modules/build.star b/.cirrus/modules/build.star index 1374f13..3dd362d 100644 --- a/.cirrus/modules/build.star +++ b/.cirrus/modules/build.star @@ -40,7 +40,7 @@ def build_env(): env |= next_env() env |= { "DEPLOY_PULL_REQUEST": "true", - "BUILD_ARGUMENTS": "--build-cache" + "BUILD_ARGUMENTS": "lintGoCode --build-cache" } return env diff --git a/sonar-go-to-slang/build.gradle.kts b/sonar-go-to-slang/build.gradle.kts index f88f31d..b914cee 100644 --- a/sonar-go-to-slang/build.gradle.kts +++ b/sonar-go-to-slang/build.gradle.kts @@ -62,7 +62,7 @@ if (isCi) { callMake("build") } - tasks.register("lintGoCode") { + val lintGoCode = tasks.register("lintGoCode") { description = "Run an external Go linter." group = "verification" @@ -106,6 +106,16 @@ if (isCi) { dependsOn("testGoCode") } + tasks.named("check") { + dependsOn(lintGoCode) + } + + rootProject.tasks.named("sonar") { + // As lintGoCode produces a report to be ingested by SonarQube, we need to add an explicit dependency to it. + // See https://docs.sonarsource.com/sonarqube-server/latest/analyzing-source-code/scanners/sonarscanner-for-gradle/#task-dependencies + dependsOn(lintGoCode) + } + spotless { go { gofmt("go$goVersion")