Skip to content

Commit cfbf38c

Browse files
authored
chore(library)!: rename classes for Mac OS runners to be derived from labels (#2347)
Part of #2343. Thanks to this change, there are clear rules how to derive runners' class names based on the runner label, and it will be easier to maintain the evolving collection of supported runners.
1 parent cefd376 commit cfbf38c

3 files changed

Lines changed: 42 additions & 9 deletions

File tree

github-workflows-kt/api/github-workflows-kt.api

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -457,16 +457,16 @@ public final class io/github/typesafegithub/workflows/domain/RunnerType$Labelled
457457
public fun toString ()Ljava/lang/String;
458458
}
459459

460-
public final class io/github/typesafegithub/workflows/domain/RunnerType$MacOS1015 : io/github/typesafegithub/workflows/domain/RunnerType$GitHubHosted {
461-
public static final field INSTANCE Lio/github/typesafegithub/workflows/domain/RunnerType$MacOS1015;
460+
public final class io/github/typesafegithub/workflows/domain/RunnerType$Macos1015 : io/github/typesafegithub/workflows/domain/RunnerType$GitHubHosted {
461+
public static final field INSTANCE Lio/github/typesafegithub/workflows/domain/RunnerType$Macos1015;
462462
}
463463

464-
public final class io/github/typesafegithub/workflows/domain/RunnerType$MacOS11 : io/github/typesafegithub/workflows/domain/RunnerType$GitHubHosted {
465-
public static final field INSTANCE Lio/github/typesafegithub/workflows/domain/RunnerType$MacOS11;
464+
public final class io/github/typesafegithub/workflows/domain/RunnerType$Macos11 : io/github/typesafegithub/workflows/domain/RunnerType$GitHubHosted {
465+
public static final field INSTANCE Lio/github/typesafegithub/workflows/domain/RunnerType$Macos11;
466466
}
467467

468-
public final class io/github/typesafegithub/workflows/domain/RunnerType$MacOSLatest : io/github/typesafegithub/workflows/domain/RunnerType$GitHubHosted {
469-
public static final field INSTANCE Lio/github/typesafegithub/workflows/domain/RunnerType$MacOSLatest;
468+
public final class io/github/typesafegithub/workflows/domain/RunnerType$MacosLatest : io/github/typesafegithub/workflows/domain/RunnerType$GitHubHosted {
469+
public static final field INSTANCE Lio/github/typesafegithub/workflows/domain/RunnerType$MacosLatest;
470470
}
471471

472472
public final class io/github/typesafegithub/workflows/domain/RunnerType$Ubuntu1804 : io/github/typesafegithub/workflows/domain/RunnerType$GitHubHosted {

github-workflows-kt/src/main/kotlin/io/github/typesafegithub/workflows/domain/RunnerType.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public sealed interface RunnerType {
1414

1515
public object WindowsLatest : GitHubHosted("windows-latest")
1616

17-
public object MacOSLatest : GitHubHosted("macos-latest")
17+
public object MacosLatest : GitHubHosted("macos-latest")
1818

1919
// Windows runners
2020
public object Windows2025 : GitHubHosted("windows-2025")
@@ -31,9 +31,9 @@ public sealed interface RunnerType {
3131
public object Ubuntu1804 : GitHubHosted("ubuntu-18.04")
3232

3333
// macOS runners
34-
public object MacOS11 : GitHubHosted("macos-11")
34+
public object Macos11 : GitHubHosted("macos-11")
3535

36-
public object MacOS1015 : GitHubHosted("macos-10.15")
36+
public object Macos1015 : GitHubHosted("macos-10.15")
3737

3838
// Custom runner. Could be an expression `runsOn = expr("github.event.inputs.run-on")`
3939
public data class Custom(

github-workflows-kt/src/test/kotlin/io/github/typesafegithub/workflows/domain/RunnerTypeTest.kt

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,43 @@
11
package io.github.typesafegithub.workflows.domain
22

3+
import io.kotest.assertions.assertSoftly
34
import io.kotest.assertions.throwables.shouldThrow
45
import io.kotest.core.spec.style.FunSpec
6+
import io.kotest.matchers.shouldBe
7+
import java.util.Locale
58

69
class RunnerTypeTest :
710
FunSpec({
11+
context("GitHub-hosted runners") {
12+
test("classes should have names derived from labels using the convention") {
13+
val runnerClasses =
14+
RunnerType.GitHubHosted::class
15+
.sealedSubclasses
16+
17+
assertSoftly {
18+
runnerClasses.forEach { runnerClass ->
19+
val actualClassName = runnerClass.simpleName
20+
val label = runnerClass.objectInstance!!.value
21+
val classNameFromLabel =
22+
label.split("-").joinToString("") {
23+
it
24+
.replaceFirstChar {
25+
if (it.isLowerCase()) {
26+
it.titlecase(
27+
Locale.getDefault(),
28+
)
29+
} else {
30+
it.toString()
31+
}
32+
}.replace(".", "")
33+
}
34+
35+
actualClassName shouldBe classNameFromLabel
36+
}
37+
}
38+
}
39+
}
40+
841
context("Labelled") {
942
test("should throw on invalid arguments") {
1043
shouldThrow<IllegalArgumentException> {

0 commit comments

Comments
 (0)