Skip to content

Commit fd36f3e

Browse files
committed
Move checkoutActionClassFQN under InferFromClasspath
1 parent b98f06b commit fd36f3e

File tree

4 files changed

+20
-15
lines changed

4 files changed

+20
-15
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3250,7 +3250,10 @@ public final class io/github/typesafegithub/workflows/yaml/CheckoutActionVersion
32503250
}
32513251

32523252
public final class io/github/typesafegithub/workflows/yaml/CheckoutActionVersionSource$InferFromClasspath : io/github/typesafegithub/workflows/yaml/CheckoutActionVersionSource {
3253-
public static final field INSTANCE Lio/github/typesafegithub/workflows/yaml/CheckoutActionVersionSource$InferFromClasspath;
3253+
public fun <init> ()V
3254+
public fun <init> (Ljava/lang/String;)V
3255+
public synthetic fun <init> (Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
3256+
public final fun getCheckoutActionClassFQN ()Ljava/lang/String;
32543257
}
32553258

32563259
public abstract interface class io/github/typesafegithub/workflows/yaml/ConsistencyCheckJobConfig {

github-workflows-kt/src/main/kotlin/io/github/typesafegithub/workflows/yaml/ConsistencyCheckJob.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ internal fun WorkflowBuilder.consistencyCheckJob(
4545
when (consistencyCheckJobConfig.checkoutActionVersion) {
4646
CheckoutActionVersionSource.BundledWithLibrary -> "v4"
4747
is CheckoutActionVersionSource.Given -> consistencyCheckJobConfig.checkoutActionVersion.version
48-
CheckoutActionVersionSource.InferFromClasspath ->
48+
is CheckoutActionVersionSource.InferFromClasspath ->
4949
inferCheckoutActionVersionFromClasspath(
50-
consistencyCheckJobConfig.checkoutActionClassFQN,
50+
consistencyCheckJobConfig.checkoutActionVersion.checkoutActionClassFQN,
5151
)
5252
}
5353

@@ -122,7 +122,7 @@ private fun inferCheckoutActionVersionFromClasspath(checkoutActionClassFQN: Stri
122122
error(
123123
"actions/checkout is not found in the classpath! " +
124124
"Either add a dependency on it (`@file:DependsOn(\"actions:checkout:<version>\")`), " +
125-
"or don't use CheckoutActionVersionSource.InferFromClasspath",
125+
"or don't use CheckoutActionVersionSource.InferFromClasspath()",
126126
)
127127
} as Class<*>
128128
// It's easier to call the primary constructor, even though it's private, because

github-workflows-kt/src/main/kotlin/io/github/typesafegithub/workflows/yaml/ConsistencyCheckJobConfig.kt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ public val DEFAULT_CONSISTENCY_CHECK_JOB_CONFIG: ConsistencyCheckJobConfig.Confi
88
condition = null,
99
env = emptyMap(),
1010
checkoutActionVersion = CheckoutActionVersionSource.BundledWithLibrary,
11-
checkoutActionClassFQN = "io.github.typesafegithub.workflows.actions.actions.Checkout",
1211
additionalSteps = null,
1312
useLocalBindingsServerAsFallback = false,
1413
)
@@ -24,11 +23,6 @@ public sealed interface ConsistencyCheckJobConfig {
2423
* Lets the user choose between convenience of automatic updates and more determinism and control if required.
2524
*/
2625
val checkoutActionVersion: CheckoutActionVersionSource,
27-
/**
28-
* Specifies the fully qualified name of a binding class for actions/checkout. Can be overridden if a custom
29-
* binding class is provided for this action, under a different FQN.
30-
*/
31-
val checkoutActionClassFQN: String,
3226
val additionalSteps: (JobBuilder<JobOutputs.EMPTY>.() -> Unit)?,
3327
/**
3428
* If the script execution step in the consistency check job fails, another attempt to execute is made with a
@@ -57,7 +51,13 @@ public sealed interface CheckoutActionVersionSource {
5751
*
5852
* This is the most convenient option, and a candidate to become the default one.
5953
*/
60-
public object InferFromClasspath : CheckoutActionVersionSource
54+
public class InferFromClasspath(
55+
/**
56+
* Specifies the fully qualified name of a binding class for actions/checkout. Can be overridden if a custom
57+
* binding class is provided for this action, under a different FQN.
58+
*/
59+
public val checkoutActionClassFQN: String = "io.github.typesafegithub.workflows.actions.actions.Checkout",
60+
) : CheckoutActionVersionSource
6161

6262
/**
6363
* Useful if it's desired to specify a concrete version by hand, right in your workflow.

github-workflows-kt/src/test/kotlin/io/github/typesafegithub/workflows/IntegrationTest.kt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ class IntegrationTest :
384384
sourceFile = sourceTempFile,
385385
consistencyCheckJobConfig =
386386
DEFAULT_CONSISTENCY_CHECK_JOB_CONFIG.copy(
387-
checkoutActionVersion = CheckoutActionVersionSource.InferFromClasspath,
387+
checkoutActionVersion = CheckoutActionVersionSource.InferFromClasspath(),
388388
),
389389
) {
390390
job(
@@ -443,8 +443,10 @@ class IntegrationTest :
443443
sourceFile = sourceTempFile,
444444
consistencyCheckJobConfig =
445445
DEFAULT_CONSISTENCY_CHECK_JOB_CONFIG.copy(
446-
checkoutActionVersion = CheckoutActionVersionSource.InferFromClasspath,
447-
checkoutActionClassFQN = "does.not.Exist",
446+
checkoutActionVersion =
447+
CheckoutActionVersionSource.InferFromClasspath(
448+
checkoutActionClassFQN = "does.not.Exist",
449+
),
448450
),
449451
) {
450452
job(
@@ -460,7 +462,7 @@ class IntegrationTest :
460462
}.also {
461463
it.message shouldBe "actions/checkout is not found in the classpath! " +
462464
"Either add a dependency on it (`@file:DependsOn(\"actions:checkout:<version>\")`), " +
463-
"or don't use CheckoutActionVersionSource.InferFromClasspath"
465+
"or don't use CheckoutActionVersionSource.InferFromClasspath()"
464466
}
465467
}
466468

0 commit comments

Comments
 (0)