-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TeamCity: add testing on multiple platforms
Signed-off-by: Christoph Obexer <[email protected]>
- Loading branch information
Showing
9 changed files
with
335 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Copyright 2024 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import jetbrains.buildServer.configs.kotlin.Project | ||
|
||
@SuppressWarnings("unused") // actually used in .teamcity/settings.kts | ||
class FileEventsProject(project: Project) { | ||
init { | ||
val build = FileEventsBuild() | ||
val tests = FileEventsTestProject(build) | ||
|
||
project.buildType(build) | ||
project.subProject(tests) | ||
project.buildType(tests.trigger) | ||
FileEventsPublish(build, tests.trigger) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* Copyright 2024 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import jetbrains.buildServer.configs.kotlin.FailureAction | ||
import jetbrains.buildServer.configs.kotlin.ParameterDisplay | ||
import jetbrains.buildServer.configs.kotlin.buildSteps.gradle | ||
|
||
class FileEventsPublish(build: FileEventsBuild, tests: FileEventsTestTrigger) : FileEventsBaseBuildType({ | ||
name = "Publish File Events" | ||
type = Type.DEPLOYMENT | ||
|
||
artifactRules = """ | ||
build/reports/** => file-events/reports | ||
build-logic/build/reports/** => build-logic/reports | ||
""".trimIndent() | ||
|
||
params { | ||
param("env.GRADLE_INTERNAL_REPO_URL", "%gradle.internal.repository.url%") | ||
param("ARTIFACTORY_USERNAME", "%gradle.internal.repository.build-tool.publish.username%") | ||
password("ARTIFACTORY_PASSWORD", "gradle.internal.repository.build-tool.publish.password%", display = ParameterDisplay.HIDDEN) | ||
param("env.ORG_GRADLE_PROJECT_publishApiKey", "%ARTIFACTORY_PASSWORD%") | ||
param("env.ORG_GRADLE_PROJECT_publishUserName", "%ARTIFACTORY_USERNAME%") | ||
} | ||
|
||
steps { | ||
gradle { | ||
name = "Gradle publish" | ||
tasks = "publish" | ||
} | ||
} | ||
|
||
dependencies { | ||
snapshot(build) { | ||
onDependencyFailure = FailureAction.FAIL_TO_START | ||
onDependencyCancel = FailureAction.FAIL_TO_START | ||
} | ||
dependency(build) { | ||
artifacts { | ||
cleanDestination = true | ||
artifactRules = "repo => build/remote/" | ||
} | ||
} | ||
snapshot(tests) { | ||
onDependencyFailure = FailureAction.FAIL_TO_START | ||
onDependencyCancel = FailureAction.FAIL_TO_START | ||
} | ||
} | ||
|
||
runOn(Agent.MacOsAarch64, 17) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* Copyright 2024 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import jetbrains.buildServer.configs.kotlin.FailureAction | ||
import jetbrains.buildServer.configs.kotlin.Project | ||
import jetbrains.buildServer.configs.kotlin.RelativeId | ||
import jetbrains.buildServer.configs.kotlin.buildSteps.gradle | ||
import jetbrains.buildServer.configs.kotlin.ui.id | ||
|
||
class FileEventsTestProject(build: FileEventsBuild) : Project({ | ||
name = "Test File Events" | ||
id(RelativeId("Test")) | ||
|
||
Agent.entries.forEach { agent -> | ||
buildType(FileEventsBaseBuildType { | ||
name = "Test on $agent" | ||
id = RelativeId("Test$agent") | ||
|
||
runOn(agent, 17) | ||
|
||
steps { | ||
gradle { | ||
name = "Gradle externalTest" | ||
tasks = "externalTest" | ||
} | ||
} | ||
|
||
dependencies { | ||
snapshot(build) { | ||
onDependencyFailure = FailureAction.FAIL_TO_START | ||
onDependencyCancel = FailureAction.FAIL_TO_START | ||
} | ||
dependency(build) { | ||
artifacts { | ||
cleanDestination = true | ||
artifactRules = "repo => build/remote/" | ||
} | ||
} | ||
} | ||
}) | ||
} | ||
}) { | ||
val trigger = FileEventsTestTrigger(this.buildTypes) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* Copyright 2024 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import jetbrains.buildServer.configs.kotlin.BuildType | ||
import jetbrains.buildServer.configs.kotlin.FailureAction | ||
import jetbrains.buildServer.configs.kotlin.buildFeatures.PullRequests | ||
import jetbrains.buildServer.configs.kotlin.buildFeatures.pullRequests | ||
import jetbrains.buildServer.configs.kotlin.triggers.vcs | ||
|
||
class FileEventsTestTrigger(dependencies: List<BuildType>) : FileEventsBaseBuildType({ | ||
name = "Test File Events (Trigger)" | ||
type = Type.COMPOSITE | ||
|
||
triggers { | ||
vcs { | ||
branchFilter = """ | ||
+:refs/heads/(*) | ||
-:pull/* | ||
""".trimIndent() | ||
} | ||
} | ||
|
||
features { | ||
pullRequests { | ||
provider = github { | ||
authType = vcsRoot() | ||
filterTargetBranch = "main" | ||
filterAuthorRole = PullRequests.GitHubRoleFilter.MEMBER | ||
ignoreDrafts = true | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
dependencies.forEach { | ||
snapshot(it) { | ||
onDependencyFailure = FailureAction.ADD_PROBLEM | ||
onDependencyCancel = FailureAction.FAIL_TO_START | ||
} | ||
} | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
/* | ||
* Copyright 2024 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import jetbrains.buildServer.configs.kotlin.Requirements | ||
|
||
enum class Agent(val os: Os, val architecture: Architecture) { | ||
UbuntuAmd64(os = Os.Ubuntu16, architecture = Architecture.Amd64), | ||
UbuntuAarch64(os = Os.Ubuntu24, architecture = Architecture.Aarch64), | ||
AmazonLinuxAmd64(os = Os.AmazonLinux, architecture = Architecture.Amd64), | ||
AmazonLinuxAarch64(os = Os.AmazonLinux, architecture = Architecture.Aarch64), | ||
CentOsAmd64(os = Os.CentOs, architecture = Architecture.Amd64), | ||
FreeBsdAmd64(os = Os.FreeBsd, architecture = Architecture.Amd64), | ||
WindowsAmd64(os = Os.Windows, architecture = Architecture.Amd64), | ||
MacOsAmd64(os = Os.MacOs, architecture = Architecture.Amd64), | ||
MacOsAarch64(os = Os.MacOs, architecture = Architecture.Aarch64), | ||
} | ||
|
||
interface Os { | ||
fun addAgentRequirements(requirements: Requirements) | ||
val osType: String | ||
|
||
object Ubuntu16 : Ubuntu(16) | ||
|
||
object Ubuntu24 : Ubuntu(24) | ||
|
||
object AmazonLinux : Linux() { | ||
override fun Requirements.additionalRequirements() { | ||
contains(osDistributionNameParameter, "amazon") | ||
} | ||
} | ||
|
||
object CentOs : Linux() { | ||
override fun Requirements.additionalRequirements() { | ||
contains(osDistributionNameParameter, "centos") | ||
contains(osDistributionVersionParameter, "9") | ||
} | ||
} | ||
|
||
object MacOs : OsWithNameRequirement("Mac OS X", "MacOs") | ||
|
||
object Windows : OsWithNameRequirement("Windows", "Windows") | ||
|
||
object FreeBsd : OsWithNameRequirement("FreeBSD", "FreeBsd") | ||
} | ||
|
||
private const val osDistributionNameParameter = "system.agent.os.distribution.name" | ||
private const val osDistributionVersionParameter = "system.agent.os.distribution.version" | ||
|
||
abstract class OsWithNameRequirement(private val osName: String, override val osType: String) : Os { | ||
override fun addAgentRequirements(requirements: Requirements) { | ||
requirements.contains("teamcity.agent.jvm.os.name", osName) | ||
requirements.additionalRequirements() | ||
} | ||
|
||
open fun Requirements.additionalRequirements() {} | ||
} | ||
|
||
abstract class Linux : OsWithNameRequirement("Linux", "Linux") | ||
|
||
abstract class Ubuntu(val version: Int) : Linux() { | ||
override fun Requirements.additionalRequirements() { | ||
contains(osDistributionNameParameter, "ubuntu") | ||
contains(osDistributionVersionParameter, version.toString()) | ||
} | ||
} | ||
|
||
enum class Architecture(val paramName: String) { | ||
Aarch64("aarch64") { | ||
override fun agentRequirementForOs(os: Os): String = "aarch64" | ||
}, | ||
Amd64("64bit") { | ||
override fun agentRequirementForOs(os: Os): String = when (os) { | ||
Os.MacOs -> "x86_64" | ||
else -> "amd64" | ||
} | ||
}; | ||
|
||
abstract fun agentRequirementForOs(os: Os): String | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Copyright 2024 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import jetbrains.buildServer.configs.kotlin.BuildType | ||
import jetbrains.buildServer.configs.kotlin.Requirements | ||
|
||
fun Requirements.requireAgent(agent: Agent) { | ||
agent.os.addAgentRequirements(this) | ||
contains("teamcity.agent.jvm.os.arch", agent.architecture.agentRequirementForOs(agent.os)) | ||
} | ||
|
||
fun BuildType.runOn(agent: Agent, javaVersion: Int) { | ||
params { | ||
param("env.JAVA_HOME", "%${agent.os.osType.lowercase()}.java${javaVersion}.openjdk.${agent.architecture.paramName}%") | ||
} | ||
|
||
requirements { | ||
requireAgent(agent) | ||
} | ||
} |