Skip to content

Commit cb94d37

Browse files
authored
refactor(library): move building step outputs to ActionStep (#1786)
Part of #1780. It will help us provide cleaner API for describing a step outside of the `job` DSL function.
1 parent 75847cf commit cb94d37

File tree

5 files changed

+7
-16
lines changed

5 files changed

+7
-16
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ public final class io/github/typesafegithub/workflows/domain/AbstractResult$Stat
1919
}
2020

2121
public class io/github/typesafegithub/workflows/domain/ActionStep : io/github/typesafegithub/workflows/domain/Step {
22-
public fun <init> (Ljava/lang/String;Ljava/lang/String;Lio/github/typesafegithub/workflows/domain/actions/Action;Ljava/util/Map;Ljava/lang/String;Ljava/lang/Boolean;Ljava/lang/Integer;Lio/github/typesafegithub/workflows/domain/actions/Action$Outputs;Ljava/util/Map;)V
23-
public synthetic fun <init> (Ljava/lang/String;Ljava/lang/String;Lio/github/typesafegithub/workflows/domain/actions/Action;Ljava/util/Map;Ljava/lang/String;Ljava/lang/Boolean;Ljava/lang/Integer;Lio/github/typesafegithub/workflows/domain/actions/Action$Outputs;Ljava/util/Map;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
22+
public fun <init> (Ljava/lang/String;Ljava/lang/String;Lio/github/typesafegithub/workflows/domain/actions/Action;Ljava/util/Map;Ljava/lang/String;Ljava/lang/Boolean;Ljava/lang/Integer;Ljava/util/Map;)V
23+
public synthetic fun <init> (Ljava/lang/String;Ljava/lang/String;Lio/github/typesafegithub/workflows/domain/actions/Action;Ljava/util/Map;Ljava/lang/String;Ljava/lang/Boolean;Ljava/lang/Integer;Ljava/util/Map;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
2424
public fun getAction ()Lio/github/typesafegithub/workflows/domain/actions/Action;
2525
public fun getCondition ()Ljava/lang/String;
2626
public fun getContinueOnError ()Ljava/lang/Boolean;

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,16 @@ public open class ActionStep<out OUTPUTS : Outputs>(
7676
override val condition: String? = null,
7777
override val continueOnError: Boolean? = null,
7878
override val timeoutMinutes: Int? = null,
79-
override val outputs: OUTPUTS,
8079
override val _customArguments: Map<String, @Contextual Any?> = emptyMap(),
8180
) : Step<OUTPUTS>(
8281
id = id,
8382
condition = condition,
8483
continueOnError = continueOnError,
8584
timeoutMinutes = timeoutMinutes,
8685
env = env,
87-
outputs = outputs,
86+
outputs = action.buildOutputObject(id),
8887
_customArguments = _customArguments,
89-
)
88+
) {
89+
override val outputs: OUTPUTS
90+
get() = super.outputs
91+
}

github-workflows-kt/src/main/kotlin/io/github/typesafegithub/workflows/dsl/JobBuilder.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,6 @@ public class JobBuilder<OUTPUT : JobOutputs>(
194194
condition = `if` ?: condition,
195195
continueOnError = continueOnError,
196196
timeoutMinutes = timeoutMinutes,
197-
outputs = action.buildOutputObject(stepId),
198197
_customArguments = _customArguments,
199198
)
200199
job = job.copy(steps = job.steps + newStep)

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package io.github.typesafegithub.workflows.domain
22

33
import io.github.typesafegithub.workflows.actions.actions.Checkout
44
import io.github.typesafegithub.workflows.domain.AbstractResult.Status
5-
import io.github.typesafegithub.workflows.domain.actions.Action
65
import io.kotest.core.spec.style.FunSpec
76
import io.kotest.matchers.shouldBe
87

@@ -21,7 +20,6 @@ class StepTest :
2120
ActionStep(
2221
id = "whatever",
2322
action = Checkout(),
24-
outputs = Action.Outputs("whatever"),
2523
)
2624
someStep.conclusion.toString() shouldBe "steps.whatever.conclusion"
2725
someStep.conclusion eq Status.Failure shouldBe "steps.whatever.conclusion == 'failure'"

github-workflows-kt/src/test/kotlin/io/github/typesafegithub/workflows/yaml/StepsToYamlTest.kt

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import io.github.typesafegithub.workflows.actions.actions.UploadArtifact
88
import io.github.typesafegithub.workflows.domain.ActionStep
99
import io.github.typesafegithub.workflows.domain.CommandStep
1010
import io.github.typesafegithub.workflows.domain.Shell
11-
import io.github.typesafegithub.workflows.domain.actions.Action
1211
import io.github.typesafegithub.workflows.domain.actions.CustomAction
1312
import io.kotest.core.spec.style.DescribeSpec
1413
import io.kotest.matchers.shouldBe
@@ -28,7 +27,6 @@ class StepsToYamlTest :
2827
id = "someId",
2928
name = "Some external action",
3029
action = Checkout(),
31-
outputs = Action.Outputs("someId"),
3230
),
3331
)
3432

@@ -239,7 +237,6 @@ class StepsToYamlTest :
239237
ActionStep(
240238
id = "someId",
241239
action = Checkout(),
242-
outputs = Action.Outputs("someId"),
243240
),
244241
)
245242

@@ -276,7 +273,6 @@ class StepsToYamlTest :
276273
""".trimIndent(),
277274
),
278275
condition = "\${{ matrix.foo == 'bar' }}",
279-
outputs = Action.Outputs("someId"),
280276
_customArguments =
281277
mapOf(
282278
"foo" to true,
@@ -339,7 +335,6 @@ class StepsToYamlTest :
339335
"compiler" to "latexmk",
340336
),
341337
),
342-
outputs = Action.Outputs("someId"),
343338
),
344339
)
345340

@@ -378,7 +373,6 @@ class StepsToYamlTest :
378373
"answer" to "42",
379374
),
380375
),
381-
outputs = Action.Outputs("someId"),
382376
),
383377
)
384378

@@ -413,7 +407,6 @@ class StepsToYamlTest :
413407
path = listOf("path1", "path2"),
414408
_customVersion = "v2.3.4",
415409
),
416-
outputs = Action.Outputs("someId"),
417410
),
418411
)
419412

@@ -447,7 +440,6 @@ class StepsToYamlTest :
447440
id = "someId",
448441
name = "Will be overridden",
449442
action = Checkout(),
450-
outputs = Action.Outputs("someId"),
451443
_customArguments =
452444
mapOf(
453445
"name" to "Overridden!",

0 commit comments

Comments
 (0)