diff --git a/.teamcity/settings.kts b/.teamcity/settings.kts index e5a8c24d2..a61ce767b 100644 --- a/.teamcity/settings.kts +++ b/.teamcity/settings.kts @@ -2,7 +2,6 @@ import jetbrains.buildServer.configs.kotlin.* import jetbrains.buildServer.configs.kotlin.CustomChart.Serie import jetbrains.buildServer.configs.kotlin.CustomChart.SeriesKey import jetbrains.buildServer.configs.kotlin.buildFeatures.* -import jetbrains.buildServer.configs.kotlin.buildSteps.exec import jetbrains.buildServer.configs.kotlin.buildSteps.powerShell import jetbrains.buildServer.configs.kotlin.buildSteps.script import jetbrains.buildServer.configs.kotlin.projectFeatures.ProjectReportTab @@ -41,6 +40,11 @@ project { buildType(Lint) buildType(Tests) + template(GitHubIntegrationTemplate) + template(LintTemplate) + template(UnitTestsTemplate) + template(ExamplesTemplate) + features { buildTypeCustomChart { id = "PROJECT_EXT_41" @@ -60,30 +64,12 @@ project { sourceBuildBranchFilter = "+:" } } -} - -object Examples : BuildType({ - name = "Examples" - artifactRules = """imod-python\imod\tests\temp => test_output.zip""" + subProject(Nightly) +} - vcs { - root(DslContext.settingsRoot, "+:. => imod-python") - root(AbsoluteId("iMOD6_IMODPython_MetaSwapLookupTable"), ". => lookup_table") - } - - steps { - script { - name = "Run examples" - id = "Run_examples" - workingDir = "imod-python" - scriptContent = """ - set Path=%system.teamcity.build.checkoutDir%\modflow6;%env.Path% - pixi run --frozen examples - """.trimIndent() - formatStderrAsError = true - } - } +object GitHubIntegrationTemplate : Template({ + name = "GitHubIntegrationTemplate" features { commitStatusPublisher { @@ -95,10 +81,6 @@ object Examples : BuildType({ } } } - xmlReport { - reportType = XmlReport.XmlReportType.JUNIT - rules = "imod-python/imod/tests/*report.xml" - } pullRequests { vcsRootExtId = "${DslContext.settingsRoot.id}" provider = github { @@ -109,19 +91,87 @@ object Examples : BuildType({ } } } +}) - dependencies { - dependency(AbsoluteId("MetaSWAP_Modflow_Modflow6Release642")) { - snapshot { - onDependencyFailure = FailureAction.FAIL_TO_START - } +object LintTemplate : Template({ + name = "LintTemplate" - artifacts { - artifactRules = "+:MODFLOW6.zip!** => modflow6" + detectHangingBuilds = false + + vcs { + root(DslContext.settingsRoot, "+:. => imod-python") + + cleanCheckout = true + } + + steps { + script { + name = "Static code analysis" + id = "Static_code_analysis" + workingDir = "imod-python" + scriptContent = """ + pixi run --frozen lint + """.trimIndent() + formatStderrAsError = true + } + } + + requirements { + equals("env.OS", "Windows_NT") + } +}) + +object UnitTestsTemplate : Template({ + name = "UnitTestsTemplate" + + allowExternalStatus = true + artifactRules = """ + imod-python\imod\tests\temp => test_output.zip + imod-python\imod\tests\coverage => coverage.zip + """.trimIndent() + + vcs { + root(DslContext.settingsRoot, "+:. => imod-python") + + cleanCheckout = true + } + + steps { + script { + name = "Run unittests" + id = "Run_unittests" + workingDir = "imod-python" + scriptContent = """ + set Path=%system.teamcity.build.checkoutDir%\modflow6;%env.Path% + pixi run --frozen unittests + """.trimIndent() + formatStderrAsError = true + } + powerShell { + name = "Extract coverage statistics" + id = "Extract_coverage_statistics" + workingDir = "imod-python/imod/tests" + scriptMode = script { + content = """ + ${'$'}REPORT = echo "coverage report" | pixi shell + + ${'$'}TOTALS = ${'$'}REPORT | Select-String -Pattern 'TOTAL' -CaseSensitive -SimpleMatch + ${'$'}STATISTICS = ${'$'}TOTALS -split "\s+" + ${'$'}TOTALLINES = ${'$'}STATISTICS[1] + ${'$'}MISSEDLINES = ${'$'}STATISTICS[2] + ${'$'}COVEREDLINES = ${'$'}TOTALLINES - ${'$'}MISSEDLINES + + Write-Host "##teamcity[buildStatisticValue key='CodeCoverageAbsLCovered' value='${'$'}COVEREDLINES']" + Write-Host "##teamcity[buildStatisticValue key='CodeCoverageAbsLTotal' value='${'$'}TOTALLINES']" + """.trimIndent() } } - snapshot(Lint) { - onDependencyFailure = FailureAction.FAIL_TO_START + } + + features { + xmlReport { + reportType = XmlReport.XmlReportType.JUNIT + rules = "imod-python/imod/tests/*report.xml" } } @@ -130,45 +180,35 @@ object Examples : BuildType({ } }) -object Lint : BuildType({ - name = "Lint" +object ExamplesTemplate : Template({ + name = "ExamplesTemplate" - detectHangingBuilds = false + artifactRules = """imod-python\imod\tests\temp => test_output.zip""" vcs { root(DslContext.settingsRoot, "+:. => imod-python") + root(AbsoluteId("iMOD6_IMODPython_MetaSwapLookupTable"), ". => lookup_table") + + cleanCheckout = true } steps { - exec { - name = "Static code analysis" - id = "Static_code_analysis" + script { + name = "Run examples" + id = "Run_examples" workingDir = "imod-python" - path = "pixi" - arguments = "run --frozen lint" + scriptContent = """ + set Path=%system.teamcity.build.checkoutDir%\modflow6;%env.Path% + pixi run --frozen examples + """.trimIndent() formatStderrAsError = true - param("script.content", "pixi run lint") } } features { - commitStatusPublisher { - vcsRootExtId = "${DslContext.settingsRoot.id}" - publisher = github { - githubUrl = "https://api.github.com" - authType = personalToken { - token = "credentialsJSON:558df52e-822f-4d9d-825a-854846a9a2ff" - } - } - } - pullRequests { - vcsRootExtId = "${DslContext.settingsRoot.id}" - provider = github { - authType = token { - token = "credentialsJSON:558df52e-822f-4d9d-825a-854846a9a2ff" - } - filterAuthorRole = PullRequests.GitHubRoleFilter.MEMBER - } + xmlReport { + reportType = XmlReport.XmlReportType.JUNIT + rules = "imod-python/imod/tests/*report.xml" } } @@ -177,11 +217,59 @@ object Lint : BuildType({ } }) +object Lint : BuildType({ + name = "Lint" + + templates(LintTemplate, GitHubIntegrationTemplate) +}) + +object UnitTests : BuildType({ + name = "UnitTests" + + templates(UnitTestsTemplate, GitHubIntegrationTemplate) + + dependencies { + dependency(AbsoluteId("MetaSWAP_Modflow_Modflow6Release642")) { + snapshot { + onDependencyFailure = FailureAction.FAIL_TO_START + } + + artifacts { + artifactRules = "+:MODFLOW6.zip!** => modflow6" + } + } + snapshot(Lint) { + onDependencyFailure = FailureAction.FAIL_TO_START + } + } +}) + +object Examples : BuildType({ + name = "Examples" + + templates(ExamplesTemplate, GitHubIntegrationTemplate) + + dependencies { + dependency(AbsoluteId("MetaSWAP_Modflow_Modflow6Release642")) { + snapshot { + onDependencyFailure = FailureAction.FAIL_TO_START + } + + artifacts { + artifactRules = "+:MODFLOW6.zip!** => modflow6" + } + } + snapshot(Lint) { + onDependencyFailure = FailureAction.FAIL_TO_START + } + } +}) + object Tests : BuildType({ name = "Tests" allowExternalStatus = true - type = BuildTypeSettings.Type.COMPOSITE + type = Type.COMPOSITE vcs { root(DslContext.settingsRoot) @@ -193,15 +281,6 @@ object Tests : BuildType({ showDependenciesChanges = true } - triggers { - finishBuildTrigger { - buildType = "iMOD6_Modflow6buildWin64" - successfulOnly = true - } - vcs { - } - } - features { pullRequests { vcsRootExtId = "${DslContext.settingsRoot.id}" @@ -230,92 +309,112 @@ object Tests : BuildType({ } }) -object UnitTests : BuildType({ - name = "UnitTests" +object Nightly : Project({ + name = "Nightly" - allowExternalStatus = true - artifactRules = """ - imod-python\imod\tests\temp => test_output.zip - imod-python\imod\tests\coverage => coverage.zip - """.trimIndent() + buildType(NightlyLint) + buildType(NightlyUnitTests) + buildType(NightlyExamples) + buildType(NightlyTests) +}) - vcs { - root(DslContext.settingsRoot, "+:. => imod-python") - } +object NightlyLint : BuildType({ + name = "Lint" - steps { - script { - name = "Run unittests" - id = "Run_unittests" - workingDir = "imod-python" - scriptContent = """ - set Path=%system.teamcity.build.checkoutDir%\modflow6;%env.Path% - pixi run --frozen unittests - """.trimIndent() - formatStderrAsError = true + templates(LintTemplate) +}) + +object NightlyUnitTests : BuildType({ + name = "UnitTests" + + templates(UnitTestsTemplate) + + dependencies { + snapshot(NightlyLint) { + onDependencyFailure = FailureAction.FAIL_TO_START } - powerShell { - name = "Extract coverage statistics" - id = "Extract_coverage_statistics" - workingDir = "imod-python/imod/tests" - scriptMode = script { - content = """ - ${'$'}REPORT = echo "coverage report" | pixi shell - - ${'$'}TOTALS = ${'$'}REPORT | Select-String -Pattern 'TOTAL' -CaseSensitive -SimpleMatch - ${'$'}STATISTICS = ${'$'}TOTALS -split "\s+" - ${'$'}TOTALLINES = ${'$'}STATISTICS[1] - ${'$'}MISSEDLINES = ${'$'}STATISTICS[2] - ${'$'}COVEREDLINES = ${'$'}TOTALLINES - ${'$'}MISSEDLINES - - Write-Host "##teamcity[buildStatisticValue key='CodeCoverageAbsLCovered' value='${'$'}COVEREDLINES']" - Write-Host "##teamcity[buildStatisticValue key='CodeCoverageAbsLTotal' value='${'$'}TOTALLINES']" - """.trimIndent() + dependency(AbsoluteId("iMOD6_Modflow6buildWin64")) { + snapshot { + onDependencyFailure = FailureAction.FAIL_TO_START + } + + artifacts { + artifactRules = "+:MODFLOW6.zip!** => modflow6" } } } +}) - features { - commitStatusPublisher { - vcsRootExtId = "${DslContext.settingsRoot.id}" - publisher = github { - githubUrl = "https://api.github.com" - authType = personalToken { - token = "credentialsJSON:558df52e-822f-4d9d-825a-854846a9a2ff" - } +object NightlyExamples : BuildType({ + name = "Examples" + + templates(ExamplesTemplate) + + dependencies { + snapshot(NightlyLint) { + onDependencyFailure = FailureAction.FAIL_TO_START + } + dependency(AbsoluteId("iMOD6_Modflow6buildWin64")) { + snapshot { + onDependencyFailure = FailureAction.FAIL_TO_START + } + + artifacts { + artifactRules = "+:MODFLOW6.zip!** => modflow6" } } - xmlReport { - reportType = XmlReport.XmlReportType.JUNIT - rules = "imod-python/imod/tests/*report.xml" + } +}) + +object NightlyTests : BuildType({ + name = "Tests" + + allowExternalStatus = true + type = Type.COMPOSITE + + vcs { + root(AbsoluteId("iMOD6_IMODPython_ImodPython")) + + branchFilter = """ + +:* + -:release_imod56 + """.trimIndent() + showDependenciesChanges = true + } + + triggers { + finishBuildTrigger { + buildType = "iMOD6_Modflow6buildWin64" + successfulOnly = true } - pullRequests { - vcsRootExtId = "${DslContext.settingsRoot.id}" - provider = github { - authType = token { - token = "credentialsJSON:558df52e-822f-4d9d-825a-854846a9a2ff" - } - filterAuthorRole = PullRequests.GitHubRoleFilter.MEMBER + } + + features { + notifications { + notifierSettings = emailNotifier { + email = """ + joeri.vanengelen@deltares.nl + luitjan.slooten@deltares.nl + sunny.titus@deltares.nl + """.trimIndent() } + buildFailedToStart = true + buildFailed = true } } dependencies { - dependency(AbsoluteId("MetaSWAP_Modflow_Modflow6Release642")) { + snapshot(NightlyExamples) { + onDependencyFailure = FailureAction.FAIL_TO_START + } + dependency(NightlyUnitTests) { snapshot { onDependencyFailure = FailureAction.FAIL_TO_START } artifacts { - artifactRules = "+:MODFLOW6.zip!** => modflow6" + artifactRules = "+:coverage.zip => ." } } - snapshot(Lint) { - onDependencyFailure = FailureAction.FAIL_TO_START - } } - - requirements { - equals("env.OS", "Windows_NT") - } -}) +}) \ No newline at end of file