Skip to content

Commit

Permalink
Update after_n_builds in codecov.yml dynamically from matrix size
Browse files Browse the repository at this point in the history
  • Loading branch information
Vampire committed Jun 6, 2023
1 parent 428a466 commit fefe78e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/branches-and-prs.main.kts
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,18 @@ workflow(
)
}

val matrix = Matrix.full
with(__FILE__.parentFile.resolve("../../codecov.yml")) {
readText()
.replace("after_n_builds:.*+$".toRegex(), "after_n_builds: ${matrix.size}")
.let(::writeText)
}
job(
id = "build-and-verify",
name = "Build and Verify",
runsOn = RunnerType.Custom(expr(Matrix.operatingSystem)),
strategy = Strategy(
matrix = Matrix.full
matrix = matrix
)
) {
uses(
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/common.main.kts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ data class Matrix(
val excludes: List<Map<String, String>>? = null,
val includes: List<Map<String, String>>? = null
) {
val size = ((variants?.size ?: 1) * (javaVersions?.size ?: 1)) - (excludes?.size ?: 0) + (includes?.size ?: 0)

fun toCustomArguments() = mapOf(
*listOfNotNull(
operatingSystems?.let { "os" to operatingSystems },
Expand Down
8 changes: 7 additions & 1 deletion .github/workflows/release.main.kts
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,19 @@ workflow(
val SONATYPE_OSS_PASSWORD by secrets
val SIGNING_GPG_PASSWORD by secrets

val matrix = Matrix.full
with(__FILE__.parentFile.resolve("../../codecov.yml")) {
readText()
.replace("after_n_builds:.*+$".toRegex(), "after_n_builds: ${matrix.size}")
.let(::writeText)
}
val buildAndVerify = job(
id = "build-and-verify",
name = "Build and Verify",
runsOn = RunnerType.Custom(expr(Matrix.operatingSystem)),
condition = "${github.repository} == 'spockframework/spock'",
strategy = Strategy(
matrix = Matrix.full
matrix = matrix
)
) {
uses(
Expand Down

0 comments on commit fefe78e

Please sign in to comment.