Skip to content

Commit 2ab4fbd

Browse files
authored
SONARGO-680 Add input for "goLangCiLint" task to trigger task re-run (#61)
1 parent 52c4c09 commit 2ab4fbd

3 files changed

Lines changed: 11 additions & 0 deletions

File tree

gradle-modules/src/main/kotlin/org.sonarsource.cloud-native.go-binary-builder.gradle.kts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import org.sonarsource.cloudnative.gradle.allGoSourcesAndMakeScripts
2121
import org.sonarsource.cloudnative.gradle.callMake
2222
import org.sonarsource.cloudnative.gradle.getArchitecture
2323
import org.sonarsource.cloudnative.gradle.getPlatform
24+
import org.sonarsource.cloudnative.gradle.goLangCiLintVersion
2425
import org.sonarsource.cloudnative.gradle.goSources
2526
import org.sonarsource.cloudnative.gradle.goVersion
2627
import org.sonarsource.cloudnative.gradle.isCi
@@ -77,6 +78,7 @@ if (isCi()) {
7778
val reportPath = layout.buildDirectory.file("reports/golangci-lint-report.xml")
7879
inputs.files(goSources())
7980
inputs.property("goVersion", goVersion)
81+
inputs.property("goLangCiLintVersion", goLangCiLintVersion)
8082

8183
outputs.files(reportPath)
8284
outputs.cacheIf { true }

gradle-modules/src/main/kotlin/org.sonarsource.cloud-native.go-docker-environment.gradle.kts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform
1818
import org.sonarsource.cloudnative.gradle.GO_BINARY_OUTPUT_DIR
1919
import org.sonarsource.cloudnative.gradle.GoBuild
2020
import org.sonarsource.cloudnative.gradle.allGoSourcesAndMakeScripts
21+
import org.sonarsource.cloudnative.gradle.goLangCiLintVersion
2122
import org.sonarsource.cloudnative.gradle.goVersion
2223
import org.sonarsource.cloudnative.gradle.isCi
2324
import org.sonarsource.cloudnative.gradle.isCrossCompile
@@ -66,6 +67,8 @@ val buildDockerImage by tasks.registering(Exec::class) {
6667
}
6768
add("--build-arg")
6869
add("GO_VERSION=$goVersion")
70+
add("--build-arg")
71+
add("GOLANG_CI_LINT_VERSION=$goLangCiLintVersion")
6972
add("--build-context")
7073
add("root=${project.rootDir.absolutePath}")
7174
add("--platform")
@@ -109,6 +112,8 @@ val dockerTasks = goBuildExtension.dockerCommands.map { tasksToCommands ->
109112
"GO_CROSS_COMPILE=${inputs.properties["goCrossCompile"]}",
110113
"--env",
111114
"GO_VERSION=$goVersion",
115+
"--env",
116+
"GOLANG_CI_LINT_VERSION=$goLangCiLintVersion",
112117
"${project.name}-builder",
113118
"bash",
114119
"-c",

gradle-modules/src/main/kotlin/org/sonarsource/cloudnative/gradle/GoBuild.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ val Project.goVersion get() = providers.environmentVariable("GO_VERSION")
4848
.orElse(providers.gradleProperty("goVersion"))
4949
.orNull ?: error("Either `GO_VERSION` env variable or `goVersion` Gradle property must be set")
5050

51+
val Project.goLangCiLintVersion get() = providers.environmentVariable("GOLANG_CI_LINT_VERSION")
52+
.orElse(providers.gradleProperty("goLangCiLintVersion"))
53+
.orNull ?: error("Either `GOLANG_CI_LINT_VERSION` env variable or `goLangCiLintVersion` Gradle property must be set")
54+
5155
val Project.isCrossCompile: Provider<String> get() = providers.environmentVariable("GO_CROSS_COMPILE").orElse("0")
5256

5357
fun Project.allGoSourcesAndMakeScripts(): FileTree =

0 commit comments

Comments
 (0)