Skip to content

Commit 7b4ad87

Browse files
author
Abduqodiri Qurbonzoda
committed
Extract benchmarks as a subproject in teamcity settings
1 parent 45316d4 commit 7b4ad87

File tree

2 files changed

+116
-96
lines changed

2 files changed

+116
-96
lines changed

.teamcity/Benchmarks.kt

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
/*
2+
* Copyright 2016-2020 JetBrains s.r.o.
3+
* Use of this source code is governed by the Apache 2.0 License that can be found in the LICENSE.txt file.
4+
*/
5+
6+
import jetbrains.buildServer.configs.kotlin.v2018_2.*
7+
import jetbrains.buildServer.configs.kotlin.v2018_2.buildSteps.gradle
8+
import java.lang.IllegalArgumentException
9+
10+
val platforms = listOf("Windows", "Linux", "Mac OS X")
11+
val jdk = "JDK_18_x64"
12+
13+
fun benchmarksProject() = Project {
14+
this.id("Benchmarks")
15+
this.name = "Benchmarks"
16+
17+
val benchmarks = listOf(
18+
benchmark("js", "Linux"),
19+
benchmark("jvm", "Linux"),
20+
*platforms.map { benchmark("native", it) }.toTypedArray()
21+
)
22+
23+
buildTypesOrder = benchmarks
24+
}
25+
26+
fun Project.benchmark(target: String, platform: String) = platform(platform, "${target}Benchmark") {
27+
steps {
28+
gradle {
29+
name = "Benchmark"
30+
tasks = benchmarkTask(target, platform)
31+
jdkHome = "%env.$jdk%"
32+
param("org.jfrog.artifactory.selectedDeployableServer.defaultModuleVersionConfiguration", "GLOBAL")
33+
buildFile = ""
34+
gradleWrapperPath = ""
35+
}
36+
}
37+
38+
artifactRules = "benchmarks/build/reports/**=> reports"
39+
40+
requirements {
41+
benchmarkAgentInstanceTypeRequirement(platform)
42+
}
43+
44+
failureConditions {
45+
executionTimeoutMin = 1440
46+
}
47+
}
48+
49+
fun benchmarkTask(target: String, platform: String): String = when(target) {
50+
"js", "jvm" -> "${target}Benchmark"
51+
"native" -> when(platform) {
52+
"Mac OS X" -> "macosX64Benchmark"
53+
"Linux" -> "linuxX64Benchmark"
54+
"Windows" -> "mingwX64Benchmark"
55+
else -> throw IllegalArgumentException("Unknown platform: $platform")
56+
}
57+
else -> throw IllegalArgumentException("Unknown target: $target")
58+
}
59+
60+
fun Requirements.benchmarkAgentInstanceTypeRequirement(platform: String) {
61+
if (platform == "Linux") equals("system.ec2.instance-type", "m5d.xlarge")
62+
else if (platform == "Windows") equals("system.ec2.instance-type", "m5.xlarge")
63+
}
64+
65+
fun Project.platform(platform: String, name: String, configure: BuildType.() -> Unit) = BuildType {
66+
// ID is prepended with Project ID, so don't repeat it here
67+
// ID should conform to identifier rules, so just letters, numbers and underscore
68+
id("${name}_${platform.substringBefore(" ")}")
69+
// Display name of the build configuration
70+
this.name = "$name ($platform)"
71+
72+
requirements {
73+
contains("teamcity.agent.jvm.os.name", platform)
74+
}
75+
76+
params {
77+
// This parameter is needed for macOS agent to be compatible
78+
if (platform.startsWith("Mac")) param("env.JDK_17", "")
79+
}
80+
81+
commonConfigure()
82+
configure()
83+
}.also { buildType(it) }
84+
85+
86+
fun BuildType.commonConfigure() {
87+
requirements {
88+
noLessThan("teamcity.agent.hardware.memorySizeMb", "6144")
89+
}
90+
91+
// Allow to fetch build status through API for badges
92+
allowExternalStatus = true
93+
94+
// Configure VCS, by default use the same and only VCS root from which this configuration is fetched
95+
vcs {
96+
root(DslContext.settingsRoot)
97+
showDependenciesChanges = true
98+
checkoutMode = CheckoutMode.ON_AGENT
99+
}
100+
101+
failureConditions {
102+
errorMessage = true
103+
nonZeroExitCode = true
104+
executionTimeoutMin = 120
105+
}
106+
107+
features {
108+
feature {
109+
id = "perfmon"
110+
type = "perfmon"
111+
}
112+
}
113+
}

.teamcity/settings.kts

Lines changed: 3 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import jetbrains.buildServer.configs.kotlin.v2018_2.*
22
import jetbrains.buildServer.configs.kotlin.v2018_2.buildSteps.*
33
import jetbrains.buildServer.configs.kotlin.v2018_2.triggers.*
4-
import java.lang.IllegalArgumentException
54

65
/*
76
The settings script is an entry point for defining a TeamCity
@@ -66,13 +65,10 @@ project {
6665
}
6766
}
6867

69-
val benchmarks = listOf(
70-
benchmark("js", "Linux"),
71-
benchmark("jvm", "Linux"),
72-
*platforms.map { benchmark("native", it) }.toTypedArray()
73-
)
68+
buildTypesOrder = listOf(buildAll, buildVersion, *builds.toTypedArray(), deployPublish, deployConfigure, *deploys.toTypedArray())
7469

75-
buildTypesOrder = listOf(buildAll, buildVersion, *builds.toTypedArray(), deployPublish, deployConfigure, *deploys.toTypedArray(), *benchmarks.toTypedArray())
70+
val benchmarksProject = benchmarksProject()
71+
subProject(benchmarksProject)
7672
}
7773

7874
fun Project.buildVersion() = BuildType {
@@ -143,45 +139,6 @@ fun Project.build(platform: String, versionBuild: BuildType) = platform(platform
143139
artifactRules = "+:build/maven=>maven\n+:build/api=>api"
144140
}
145141

146-
fun Project.benchmark(target: String, platform: String) = platform(platform, "${target}Benchmark") {
147-
steps {
148-
gradle {
149-
name = "Benchmark"
150-
tasks = benchmarkTask(target, platform)
151-
jdkHome = "%env.$jdk%"
152-
param("org.jfrog.artifactory.selectedDeployableServer.defaultModuleVersionConfiguration", "GLOBAL")
153-
buildFile = ""
154-
gradleWrapperPath = ""
155-
}
156-
}
157-
158-
artifactRules = "benchmarks/build/reports/**=> reports"
159-
160-
requirements {
161-
benchmarkAgentInstanceTypeRequirement(platform)
162-
}
163-
164-
failureConditions {
165-
executionTimeoutMin = 1440
166-
}
167-
}
168-
169-
fun benchmarkTask(target: String, platform: String): String = when(target) {
170-
"js", "jvm" -> "${target}Benchmark"
171-
"native" -> when(platform) {
172-
"Mac OS X" -> "macosX64Benchmark"
173-
"Linux" -> "linuxX64Benchmark"
174-
"Windows" -> "mingwX64Benchmark"
175-
else -> throw IllegalArgumentException("Unknown platform: $platform")
176-
}
177-
else -> throw IllegalArgumentException("Unknown target: $target")
178-
}
179-
180-
fun Requirements.benchmarkAgentInstanceTypeRequirement(platform: String) {
181-
if (platform == "Linux") equals("system.ec2.instance-type", "m5d.xlarge")
182-
else if (platform == "Windows") equals("system.ec2.instance-type", "m5.xlarge")
183-
}
184-
185142
fun BuildType.dependsOn(build: BuildType, configure: Dependency.() -> Unit) =
186143
apply {
187144
dependencies.dependency(build, configure)
@@ -268,53 +225,3 @@ fun Project.deploy(platform: String, configureBuild: BuildType) = platform(platf
268225
}
269226
}
270227
}.dependsOnSnapshot(configureBuild)
271-
272-
fun Project.platform(platform: String, name: String, configure: BuildType.() -> Unit) = BuildType {
273-
// ID is prepended with Project ID, so don't repeat it here
274-
// ID should conform to identifier rules, so just letters, numbers and underscore
275-
id("${name}_${platform.substringBefore(" ")}")
276-
// Display name of the build configuration
277-
this.name = "$name ($platform)"
278-
279-
requirements {
280-
contains("teamcity.agent.jvm.os.name", platform)
281-
}
282-
283-
params {
284-
// This parameter is needed for macOS agent to be compatible
285-
if (platform.startsWith("Mac")) param("env.JDK_17", "")
286-
}
287-
288-
commonConfigure()
289-
configure()
290-
}.also { buildType(it) }
291-
292-
293-
fun BuildType.commonConfigure() {
294-
requirements {
295-
noLessThan("teamcity.agent.hardware.memorySizeMb", "6144")
296-
}
297-
298-
// Allow to fetch build status through API for badges
299-
allowExternalStatus = true
300-
301-
// Configure VCS, by default use the same and only VCS root from which this configuration is fetched
302-
vcs {
303-
root(DslContext.settingsRoot)
304-
showDependenciesChanges = true
305-
checkoutMode = CheckoutMode.ON_AGENT
306-
}
307-
308-
failureConditions {
309-
errorMessage = true
310-
nonZeroExitCode = true
311-
executionTimeoutMin = 120
312-
}
313-
314-
features {
315-
feature {
316-
id = "perfmon"
317-
type = "perfmon"
318-
}
319-
}
320-
}

0 commit comments

Comments
 (0)