Skip to content

Commit

Permalink
Namespace user-specific build parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
marcphilipp committed Jan 14, 2024
1 parent b0330b3 commit 993824e
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 32 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cross-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
- '*'

env:
DEVELOCITY_TESTDISTRIBUTION_ENABLED: true
JUNIT_DEVELOCITY_TESTDISTRIBUTION_ENABLED: true
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}

jobs:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
- '*'

env:
DEVELOCITY_TESTDISTRIBUTION_ENABLED: true
JUNIT_DEVELOCITY_TESTDISTRIBUTION_ENABLED: true
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}

jobs:
Expand Down
49 changes: 26 additions & 23 deletions gradle/plugins/build-parameters/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,38 +14,41 @@ buildParameters {
integer("javaToolchainVersion") {
description = "Defines the Java toolchain version to use for compiling code"
}
group("buildCache") {
string("server") {
description = "Remote build cache server address (protocol and hostname), e.g. https://eu-build-cache-ge.junit.org"
}
}
group("documentation") {
description = "Parameters controlling how the documentation is built"
bool("replaceCurrentDocs") {
description = "The documentation that is being deployed will replace what's currently deployed as 'current'"
defaultValue = false
}
}
group("develocity") {
description = "Parameters controlling Gradle Enterprise features"
group("predictiveTestSelection") {
bool("enabled") {
description = "Whether or not to use Predictive Test Selection for selecting tests to execute"
defaultValue = true
}
}
group("testDistribution") {
bool("enabled") {
description = "Whether or not to use Test Distribution for executing tests"
defaultValue = false
fromEnvironment()
group("junit") {
group("develocity") {
description = "Parameters controlling Develocity features"
group("buildCache") {
string("server") {
description =
"Remote build cache server address (protocol and hostname), e.g. https://eu-build-cache-ge.junit.org"
}
}
integer("maxLocalExecutors") {
description = "How many local executors to use for executing tests"
defaultValue = 1
group("predictiveTestSelection") {
bool("enabled") {
description = "Whether or not to use Predictive Test Selection for selecting tests to execute"
defaultValue = true
}
}
integer("maxRemoteExecutors") {
description = "How many remote executors to request for executing tests"
group("testDistribution") {
bool("enabled") {
description = "Whether or not to use Test Distribution for executing tests"
defaultValue = false
fromEnvironment()
}
integer("maxLocalExecutors") {
description = "How many local executors to use for executing tests"
defaultValue = 1
}
integer("maxRemoteExecutors") {
description = "How many remote executors to request for executing tests"
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ tasks.withType<Test>().configureEach {
maxRetries = buildParameters.testing.retries.orElse(if (buildParameters.ci) 2 else 0)
}
distribution {
enabled.convention(buildParameters.develocity.testDistribution.enabled && (!buildParameters.ci || System.getenv("GRADLE_ENTERPRISE_ACCESS_KEY").isNotBlank()))
maxLocalExecutors = buildParameters.develocity.testDistribution.maxLocalExecutors
maxRemoteExecutors = buildParameters.develocity.testDistribution.maxRemoteExecutors
enabled.convention(buildParameters.junit.develocity.testDistribution.enabled && (!buildParameters.ci || System.getenv("GRADLE_ENTERPRISE_ACCESS_KEY").isNotBlank()))
maxLocalExecutors = buildParameters.junit.develocity.testDistribution.maxLocalExecutors
maxRemoteExecutors = buildParameters.junit.develocity.testDistribution.maxRemoteExecutors
if (buildParameters.ci) {
when {
OperatingSystem.current().isLinux -> requirements.add("os=linux")
Expand All @@ -34,7 +34,7 @@ tasks.withType<Test>().configureEach {
}
}
predictiveSelection {
enabled = buildParameters.develocity.predictiveTestSelection.enabled
enabled = buildParameters.junit.develocity.predictiveTestSelection.enabled

// Ensure PTS works when publishing Build Scans to scans.gradle.com
this as PredictiveTestSelectionExtensionInternal
Expand Down
7 changes: 4 additions & 3 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ gradleEnterprise {
}
}

if (buildParameters.develocity.testDistribution.enabled) {
if (buildParameters.junit.develocity.testDistribution.enabled) {
tag("test-distribution")
}
}
Expand All @@ -62,15 +62,16 @@ buildCache {
local {
isEnabled = !buildParameters.ci
}
val buildCacheServer = buildParameters.junit.develocity.buildCache.server
if (useDevelocityInstance) {
remote(gradleEnterprise.buildCache) {
server = buildParameters.buildCache.server.orNull
server = buildCacheServer.orNull
val authenticated = System.getenv("GRADLE_ENTERPRISE_ACCESS_KEY") != null
isPush = buildParameters.ci && authenticated
}
} else {
remote<HttpBuildCache> {
url = uri(buildParameters.buildCache.server.getOrElse(develocityServer)).resolve("/cache/")
url = uri(buildCacheServer.getOrElse(develocityServer)).resolve("/cache/")
}
}
}
Expand Down

0 comments on commit 993824e

Please sign in to comment.