Skip to content

Commit

Permalink
Merge branch 'kotlin-workflow-files' into codecov-settings
Browse files Browse the repository at this point in the history
  • Loading branch information
Vampire committed Apr 19, 2023
2 parents 7dbf123 + 245d8cd commit 757e058
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 6 deletions.
22 changes: 20 additions & 2 deletions .github/workflows/branches-and-prs.main.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@
*/

@file:DependsOn("io.github.typesafegithub:github-workflows-kt:0.41.0")
@file:DependsOn("org.codehaus.groovy:groovy:3.0.15")

import groovy.lang.Binding
import groovy.lang.GroovyShell
import io.github.typesafegithub.workflows.actions.actions.CheckoutV3
import io.github.typesafegithub.workflows.actions.actions.GithubScriptV6
import io.github.typesafegithub.workflows.actions.codecov.CodecovActionV3
Expand Down Expand Up @@ -74,8 +77,7 @@ workflow(
)
}

val variants = listOf("2.5", "3.0", "4.0")
val javaVersions = listOf("8", "11", "17")
val (javaVersions, variants) = getMatrixAxes()
val matrixExcludes = javaVersions
.filter { it.toInt() >= 17 }
.map { javaVersion ->
Expand Down Expand Up @@ -168,3 +170,19 @@ data class SetupBuildEnv(

override fun buildOutputObject(stepId: String): Outputs = Outputs(stepId)
}

fun getMatrixAxes(): Pair<List<String>, List<String>> {
val binding = object : Binding() {
lateinit var javaVersions: List<String>
lateinit var variants: List<String>

override fun setVariable(name: String?, value: Any?) {
when (name) {
"javaVersions" -> javaVersions = (value as List<Int>).map { it.toString() }
"variants" -> variants = value as List<String>
}
}
}
GroovyShell(binding).evaluate(__FILE__.parentFile.resolve("../../matrix.groovy"))
return binding.javaVersions to binding.variants
}
22 changes: 20 additions & 2 deletions .github/workflows/release.main.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@
*/

@file:DependsOn("io.github.typesafegithub:github-workflows-kt:0.41.0")
@file:DependsOn("org.codehaus.groovy:groovy:3.0.15")

import groovy.lang.Binding
import groovy.lang.GroovyShell
import io.github.typesafegithub.workflows.actions.actions.CheckoutV3
import io.github.typesafegithub.workflows.actions.actions.CheckoutV3.FetchDepth
import io.github.typesafegithub.workflows.actions.actions.GithubScriptV6
Expand Down Expand Up @@ -52,8 +55,7 @@ workflow(
val SPOCK_BUILD_CACHE_PASSWORD by Contexts.secrets
val GRADLE_ENTERPRISE_ACCESS_KEY by Contexts.secrets

val variants = listOf("2.5", "3.0", "4.0")
val javaVersions = listOf("8", "11", "17")
val (javaVersions, variants) = getMatrixAxes()
val matrixExcludes = javaVersions
.filter { it.toInt() >= 17 }
.map { javaVersion ->
Expand Down Expand Up @@ -241,3 +243,19 @@ data class SetupBuildEnv(

override fun buildOutputObject(stepId: String): Outputs = Outputs(stepId)
}

fun getMatrixAxes(): Pair<List<String>, List<String>> {
val binding = object : Binding() {
lateinit var javaVersions: List<String>
lateinit var variants: List<String>

override fun setVariable(name: String?, value: Any?) {
when (name) {
"javaVersions" -> javaVersions = (value as List<Int>).map { it.toString() }
"variants" -> variants = value as List<String>
}
}
}
GroovyShell(binding).evaluate(__FILE__.parentFile.resolve("../../matrix.groovy"))
return binding.javaVersions to binding.variants
}
7 changes: 5 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,16 @@ plugins {

description = "Spock Framework"

ext.javaVersions = null
ext.variants = null
apply from: 'matrix.groovy'
variants = variants.collect { it as BigDecimal }

ext {
baseVersion = "2.4"
snapshotVersion = true
milestone = 0
javaVersions = [8, 11, 17] // ensure that latest version is actually build on travis, otherwise no docs get published
javaVersion = (System.getProperty("javaVersion") ?: 8) as int
variants = [2.5, 3.0, 4.0]
variant = System.getProperty("variant") as BigDecimal ?: variants.first()
buildScan.tag "groovy-$variant"
if (variant == 2.5) {
Expand Down
2 changes: 2 additions & 0 deletions matrix.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
javaVersions = [8, 11, 17] // ensure that latest version is actually built on GitHub Actions, otherwise no docs get published
variants = ['2.5', '3.0', '4.0']

0 comments on commit 757e058

Please sign in to comment.