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 9, 2023
1 parent b7b1053 commit e6fee6d
Show file tree
Hide file tree
Showing 3 changed files with 21 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
7 changes: 7 additions & 0 deletions .github/workflows/common.main.kts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@ data class Matrix(
val exclude: (Element.() -> Boolean)? = null,
val includes: List<Element>? = null
) {
val size by lazy {
originalElements
.filterNot(exclude ?: { true })
.size +
(includes?.size ?: 0)
}

private val originalElements by lazy {
(operatingSystems ?: listOf(null))
.map { Element(operatingSystem = it) }
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 e6fee6d

Please sign in to comment.