gitlab.com/Raven-IO/raven-delve@v1.22.4/.teamcity/settings.kts (about)

     1  import jetbrains.buildServer.configs.kotlin.AbsoluteId
     2  import jetbrains.buildServer.configs.kotlin.BuildType
     3  import jetbrains.buildServer.configs.kotlin.DslContext
     4  import jetbrains.buildServer.configs.kotlin.Project
     5  import jetbrains.buildServer.configs.kotlin.buildFeatures.PullRequests
     6  import jetbrains.buildServer.configs.kotlin.buildFeatures.commitStatusPublisher
     7  import jetbrains.buildServer.configs.kotlin.buildFeatures.golang
     8  import jetbrains.buildServer.configs.kotlin.buildFeatures.pullRequests
     9  import jetbrains.buildServer.configs.kotlin.buildSteps.dockerCommand
    10  import jetbrains.buildServer.configs.kotlin.buildSteps.exec
    11  import jetbrains.buildServer.configs.kotlin.buildSteps.powerShell
    12  import jetbrains.buildServer.configs.kotlin.failureConditions.BuildFailureOnMetric
    13  import jetbrains.buildServer.configs.kotlin.failureConditions.failOnMetricChange
    14  import jetbrains.buildServer.configs.kotlin.project
    15  import jetbrains.buildServer.configs.kotlin.triggers.schedule
    16  import jetbrains.buildServer.configs.kotlin.triggers.vcs
    17  import jetbrains.buildServer.configs.kotlin.version
    18  
    19  /*
    20  The settings script is an entry point for defining a TeamCity
    21  project hierarchy. The script should contain a single call to the
    22  project() function with a Project instance or an init function as
    23  an argument.
    24  
    25  VcsRoots, BuildTypes, Templates, and subprojects can be
    26  registered inside the project using the vcsRoot(), buildType(),
    27  template(), and subProject() methods respectively.
    28  
    29  To debug settings scripts in command-line, run the
    30  
    31      mvnDebug org.jetbrains.teamcity:teamcity-configs-maven-plugin:generate
    32  
    33  command and attach your debugger to the port 8000.
    34  
    35  To debug in IntelliJ Idea, open the 'Maven Projects' tool window (View
    36  -> Tool Windows -> Maven Projects), find the generate task node
    37  (Plugins -> teamcity-configs -> teamcity-configs:generate), the
    38  'Debug' option is available in the context menu for the task.
    39  */
    40  
    41  version = "2023.05"
    42  
    43  val targets = arrayOf(
    44          "linux/amd64/1.20",
    45          "linux/amd64/1.21",
    46          "linux/amd64/1.22",
    47          "linux/amd64/tip",
    48  
    49          "linux/386/1.22",
    50  
    51          "linux/arm64/1.22",
    52          "linux/arm64/tip",
    53  
    54          "linux/ppc64le/1.22",
    55  
    56          "windows/amd64/1.22",
    57          "windows/amd64/tip",
    58  
    59          "mac/amd64/1.22",
    60          "mac/amd64/tip",
    61  
    62          "mac/arm64/1.22",
    63          "mac/arm64/tip"
    64  )
    65  
    66  project {
    67      val tests = targets.map { target ->
    68          val (os, arch, version) = target.split("/")
    69          TestBuild(os, arch, version, AbsoluteId("Delve_${os}_${arch}_${version.replace('.', '_')}"))
    70      }
    71      tests.map { test ->
    72          test.os
    73      }.distinct().forEach { os ->
    74          subProject(OSProject(os, tests.filter { test ->
    75              test.os == os && test.version != "tip"
    76          }))
    77      }
    78      subProject(TipProject(tests.filter { test ->
    79          test.version == "tip"
    80      }))
    81      buildType(AggregatorBuild(tests.filter { test ->
    82          test.version != "tip"
    83      }))
    84      params {
    85          param("teamcity.ui.settings.readOnly", "true")
    86      }
    87  }
    88  
    89  class AggregatorBuild(tests: Collection<BuildType>) : BuildType({
    90      name = "Aggregator"
    91      type = Type.COMPOSITE
    92  
    93      vcs {
    94          root(DslContext.settingsRoot)
    95      }
    96  
    97      triggers {
    98          vcs {
    99          }
   100      }
   101  
   102      dependencies {
   103          tests.forEach { test ->
   104              snapshot(test) {
   105              }
   106          }
   107      }
   108  
   109      features {
   110          pullRequests {
   111              vcsRootExtId = "${DslContext.settingsRoot.id}"
   112              provider = github {
   113                  authType = token {
   114                      token = "credentialsJSON:1312c856-0e13-4b04-8c40-ac26d4a5f700"
   115                  }
   116                  filterAuthorRole = PullRequests.GitHubRoleFilter.EVERYBODY
   117              }
   118          }
   119          commitStatusPublisher {
   120              vcsRootExtId = "${DslContext.settingsRoot.id}"
   121              publisher = github {
   122                  githubUrl = "https://api.github.com"
   123                  authType = personalToken {
   124                      token = "credentialsJSON:1312c856-0e13-4b04-8c40-ac26d4a5f700"
   125                  }
   126              }
   127              param("github_oauth_user", "")
   128          }
   129      }
   130  
   131      failureConditions {
   132          executionTimeoutMin = 60
   133      }
   134  })
   135  
   136  class TipProject(tests: List<TestBuild>) : Project({
   137      id = AbsoluteId("Delve_tip")
   138      name = "Tip"
   139  
   140      tests.forEach { test ->
   141          buildType(test)
   142      }
   143  })
   144  
   145  class OSProject(os: String, tests: List<TestBuild>) : Project({
   146      id = AbsoluteId("Delve_$os")
   147      name = os.capitalize()
   148  
   149      tests.map { test ->
   150          test.arch
   151      }.distinct().forEach { arch ->
   152          subProject(ArchProject(os, arch, tests.filter { test ->
   153              test.arch == arch
   154          }))
   155      }
   156  })
   157  
   158  class ArchProject(os: String, arch: String, tests: List<TestBuild>) : Project({
   159      id = AbsoluteId("Delve_${os}_${arch}")
   160      name = arch
   161  
   162      tests.forEach { test ->
   163          buildType(test)
   164      }
   165  })
   166  
   167  class TestBuild(val os: String, val arch: String, val version: String, buildId: AbsoluteId) : BuildType({
   168      id = buildId
   169      name = if (version == "tip") "${os}_${arch}_tip" else version
   170  
   171      vcs {
   172          root(DslContext.settingsRoot)
   173          branchFilter = if (version == "tip") {
   174              """
   175                  +:*
   176                  -:pull/*
   177                  """.trimIndent()
   178          } else {
   179              "+:*"
   180          }
   181      }
   182  
   183      if (version == "tip") {
   184          triggers {
   185              schedule {
   186                  schedulingPolicy = daily {
   187                      hour = 23
   188                  }
   189                  withPendingChangesOnly = true
   190                  triggerBuild = always()
   191              }
   192          }
   193      }
   194  
   195      failureConditions {
   196          executionTimeoutMin = 30
   197  
   198          if (version != "tip") {
   199              failOnMetricChange {
   200                   metric = BuildFailureOnMetric.MetricType.TEST_COUNT
   201                   units = BuildFailureOnMetric.MetricUnit.DEFAULT_UNIT
   202                   comparison = BuildFailureOnMetric.MetricComparison.LESS
   203                   compareTo = value()
   204              }
   205          }
   206      }
   207  
   208      steps {
   209          when (os) {
   210              "linux" -> {
   211                  val dockerArch = when (arch) {
   212                      "386" -> "i386"
   213                      "arm64" -> "arm64v8"
   214                      else -> {
   215                          arch
   216                      }
   217                  }
   218                  val dockerPlatformArch = when (arch) {
   219                      "arm64" -> "arm64/v8"
   220                      else -> {
   221                          dockerArch
   222                      }
   223                  }
   224                  dockerCommand {
   225                      name = "Pull Ubuntu"
   226                      commandType = other {
   227                          subCommand = "pull"
   228                          commandArgs = "$dockerArch/ubuntu:20.04"
   229                      }
   230                  }
   231                  dockerCommand {
   232                      name = "Test"
   233                      commandType = other {
   234                          subCommand = "run"
   235                          commandArgs = """
   236                          -v %teamcity.build.checkoutDir%:/delve
   237                          --env TEAMCITY_VERSION=${'$'}TEAMCITY_VERSION
   238                          --env CI=true
   239                          --privileged
   240                          --platform linux/$dockerPlatformArch
   241                          $dockerArch/ubuntu:20.04
   242                          /delve/_scripts/test_linux.sh ${"go$version"} $arch
   243                      """.trimIndent()
   244                      }
   245                  }
   246              }
   247              "windows" -> {
   248                  powerShell {
   249                      name = "Test"
   250                      scriptMode = file {
   251                          path = "_scripts/test_windows.ps1"
   252                      }
   253                      param("jetbrains_powershell_scriptArguments", "-version ${"go$version"} -arch $arch")
   254                  }
   255              }
   256              "mac" -> {
   257                  exec {
   258                      name = "Test"
   259                      path = "_scripts/test_mac.sh"
   260                      arguments = "${"go$version"} $arch %system.teamcity.build.tempDir%"
   261                  }
   262              }
   263          }
   264      }
   265  
   266      requirements {
   267          when (arch) {
   268              "386", "amd64" -> equals("teamcity.agent.jvm.os.arch", if (os == "mac") "x86_64" else "amd64")
   269              "arm64" -> equals("teamcity.agent.jvm.os.arch", "aarch64")
   270              "ppc64le" -> equals("teamcity.agent.jvm.os.arch", "ppc64le")
   271          }
   272          when (os) {
   273              "linux" -> {
   274                  matches("teamcity.agent.jvm.os.family", "Linux")
   275              }
   276              "windows" -> {
   277                  matches("teamcity.agent.jvm.os.family", "Windows")
   278              }
   279              "mac" -> {
   280                  matches("teamcity.agent.jvm.os.family", "Mac OS")
   281              }
   282          }
   283      }
   284  
   285      features {
   286          pullRequests {
   287              vcsRootExtId = "${DslContext.settingsRoot.id}"
   288              provider = github {
   289                  authType = token {
   290                      token = "credentialsJSON:1312c856-0e13-4b04-8c40-ac26d4a5f700"
   291                  }
   292                  filterAuthorRole = PullRequests.GitHubRoleFilter.EVERYBODY
   293              }
   294          }
   295          golang {
   296              testFormat = "json"
   297          }
   298      }
   299  })