Skip to content

Commit b1b9b41

Browse files
committed
chore(ci/api):
- add compose core api - refactoring for .teamcity packages
1 parent 406a065 commit b1b9b41

File tree

59 files changed

+627
-249
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+627
-249
lines changed

.teamcity/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/target

.teamcity/BuildParams.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import references.builds.compose.ComposeMultiplatformCore
2+
13
object BuildParams {
24
const val DOKKA_TEMPLATES_VERSION = "2.0.0"
35

@@ -36,6 +38,10 @@ object BuildParams {
3638
const val KOTLINX_METADATA_RELEASE_TAG = KOTLIN_RELEASE_TAG
3739
const val KOTLINX_METADATA_TITLE = KOTLINX_METADATA_ID
3840

41+
val API_COMPOSE = ComposeMultiplatformCore {
42+
addVersion("1.8.0", "api-reference/1.8")
43+
}
44+
3945
const val SEARCH_APP_ID = "7961PKYRXV"
4046
const val SEARCH_INDEX_NAME = "prod_KOTLINLANG_WEBHELP"
4147

@@ -47,5 +53,6 @@ object BuildParams {
4753
"api/$KOTLINX_IO_ID",
4854
"api/$KGP_ID",
4955
"api/$KOTLINX_METADATA_ID",
56+
"api/${API_COMPOSE.urlPart}",
5057
)
5158
}

.teamcity/builds/apiReferences/BuildApiReferencesProject.kt

Lines changed: 0 additions & 66 deletions
This file was deleted.

.teamcity/builds/kotlinlang/SiteProject.kt

Lines changed: 0 additions & 42 deletions
This file was deleted.

.teamcity/common/ReferenceProject.kt

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
package common
2+
3+
import common.extensions.scriptGenerateSitemap
4+
import common.extensions.scriptNoRobots
5+
import jetbrains.buildServer.configs.kotlin.BuildType
6+
import jetbrains.buildServer.configs.kotlin.Project
7+
import jetbrains.buildServer.configs.kotlin.RelativeId
8+
import templates.SCRIPT_PATH
9+
import vcsRoots.KotlinLangOrg
10+
11+
private fun String.camelCase(delim: String = "-", join: String = "") =
12+
this.split(delim).joinToString(join) { it.replaceFirstChar { char -> char.uppercase() } }
13+
14+
typealias ProjectReferenceBuilder = () -> BuildType
15+
16+
open class ReferenceProject(val urlPart: String, val projectTitle: String = urlPart) {
17+
init {
18+
if (urlPart.isBlank()) throw IllegalArgumentException("urlPart cannot be blank")
19+
}
20+
21+
val projectName = projectTitle.camelCase(join = " ")
22+
23+
val projectPrefix = urlPart.camelCase()
24+
val project = Project {
25+
id = RelativeId(projectPrefix)
26+
name = projectName
27+
description = "Project for https://kotlinlang.org/api/$urlPart/"
28+
29+
params {
30+
param("env.ALGOLIA_INDEX_NAME", urlPart)
31+
param("env.API_REFERENCE_NAME", projectTitle)
32+
}
33+
}
34+
35+
protected val versions = mutableListOf<Pair<BuildType, String>>()
36+
37+
fun getCurrentVersion(): Pair<BuildType, String>? = this.versions.lastOrNull()
38+
39+
fun addReference(version: String, buildReference: ProjectReferenceBuilder) {
40+
versions.add(buildReference() to version)
41+
}
42+
43+
fun build() {
44+
val (currentVersion) = getCurrentVersion()
45+
?: throw IllegalStateException("Current version is not set for $projectName")
46+
47+
val workingDir = "dist/api/$urlPart"
48+
49+
val pages = BuildType {
50+
id = RelativeId("${projectPrefix}_Latest")
51+
name = "API Pages"
52+
description = "The latest stable version for $projectName"
53+
54+
artifactRules = "$workingDir/** => pages.zip"
55+
56+
vcs {
57+
root(KotlinLangOrg, "${SCRIPT_PATH}/")
58+
}
59+
60+
steps {
61+
scriptNoRobots(workingDir)
62+
scriptGenerateSitemap(workingDir)
63+
}
64+
65+
dependencies {
66+
dependency(currentVersion) {
67+
snapshot {}
68+
artifacts {
69+
artifactRules = "pages.zip!** => $workingDir"
70+
cleanDestination = true
71+
}
72+
}
73+
}
74+
}
75+
76+
project.apply {
77+
buildType(pages)
78+
buildType {
79+
id = RelativeId("${projectPrefix}_Search")
80+
name = "API Search Index"
81+
description = "Build search index for $projectName"
82+
83+
dependencies {
84+
dependency(pages) {
85+
snapshot {}
86+
artifacts {
87+
artifactRules = "pages.zip!** => $workingDir"
88+
cleanDestination = true
89+
}
90+
}
91+
}
92+
}
93+
}
94+
95+
currentVersion.dependencies {
96+
for ((previousVersion, version) in versions) {
97+
if (previousVersion == currentVersion) continue
98+
artifacts(previousVersion) {
99+
buildRule = tag("release")
100+
artifactRules = "pages.zip!** => %OLD_VERSIONS_DIR%/$version/"
101+
cleanDestination = true
102+
}
103+
}
104+
}
105+
}
106+
}

.teamcity/common/extensions/index.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package common.extensions
2+
3+
object VCS {
4+
fun tag(name: String) = "refs/tags/$name"
5+
fun branch(name: String) = "refs/heads/$name"
6+
}

0 commit comments

Comments
 (0)