Skip to content

Commit

Permalink
feat(abg)!: allow to wire typed outputs to matching typed inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
Vampire committed Oct 27, 2024
1 parent c660603 commit 5cf2155
Show file tree
Hide file tree
Showing 47 changed files with 1,704 additions and 530 deletions.
19 changes: 10 additions & 9 deletions .github/workflows/bindings-server.main.kts
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,16 @@ workflow(
""".trimIndent(),
)

cleanMavenLocal()

run(
name = "Execute the script using the bindings from the server with v2 route",
command = """
mv .github/workflows/test-script-consuming-jit-bindings-v2.main.do-not-compile.kts .github/workflows/test-script-consuming-jit-bindings-v2.main.kts
.github/workflows/test-script-consuming-jit-bindings-v2.main.kts
""".trimIndent(),
)
// TODO: Reenable after release, currently, new class "Expression" cannot be found
//cleanMavenLocal()

//run(
// name = "Execute the script using the bindings from the server with v2 route",
// command = """
// mv .github/workflows/test-script-consuming-jit-bindings-v2.main.do-not-compile.kts .github/workflows/test-script-consuming-jit-bindings-v2.main.kts
// .github/workflows/test-script-consuming-jit-bindings-v2.main.kts
// """.trimIndent(),
//)

cleanMavenLocal()

Expand Down
12 changes: 2 additions & 10 deletions .github/workflows/bindings-server.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,22 +65,14 @@ jobs:
name: 'Clean Maven Local to fetch required POMs again'
run: 'rm -rf ~/.m2/repository/'
- id: 'step-9'
name: 'Execute the script using the bindings from the server with v2 route'
run: |-
mv .github/workflows/test-script-consuming-jit-bindings-v2.main.do-not-compile.kts .github/workflows/test-script-consuming-jit-bindings-v2.main.kts
.github/workflows/test-script-consuming-jit-bindings-v2.main.kts
- id: 'step-10'
name: 'Clean Maven Local to fetch required POMs again'
run: 'rm -rf ~/.m2/repository/'
- id: 'step-11'
name: 'Execute the script using bindings but without dependency on library'
run: |-
mv .github/workflows/test-served-bindings-depend-on-library.main.do-not-compile.kts .github/workflows/test-served-bindings-depend-on-library.main.kts
.github/workflows/test-served-bindings-depend-on-library.main.kts
- id: 'step-12'
- id: 'step-10'
name: 'Fetch maven-metadata.xml for top-level action'
run: 'curl --fail http://localhost:8080/actions/checkout/maven-metadata.xml | grep ''<version>v4</version>'''
- id: 'step-13'
- id: 'step-11'
name: 'Fetch maven-metadata.xml for nested action'
run: 'curl --fail http://localhost:8080/actions/cache__save/maven-metadata.xml | grep ''<version>v4</version>'''
deploy:
Expand Down
17 changes: 9 additions & 8 deletions .github/workflows/end-to-end-tests.main.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import io.github.typesafegithub.workflows.actions.actions.*
import io.github.typesafegithub.workflows.actions.gradle.ActionsSetupGradle
import io.github.typesafegithub.workflows.actions.wandalen.WretryAction
import io.github.typesafegithub.workflows.annotations.ExperimentalKotlinLogicStep
import io.github.typesafegithub.workflows.domain.Expression
import io.github.typesafegithub.workflows.domain.JobOutputs
import io.github.typesafegithub.workflows.domain.Mode
import io.github.typesafegithub.workflows.domain.Permission
Expand Down Expand Up @@ -81,9 +82,9 @@ workflow(
Permission.Contents to Mode.None,
),
outputs = object : JobOutputs() {
var scriptKey by output()
var scriptKey2 by output()
var scriptResult by output()
var scriptKey by output<String>()
var scriptKey2 by output<String>()
var scriptResult by output<String>()
},
) {
run(
Expand Down Expand Up @@ -179,7 +180,7 @@ workflow(
name = "Some step consuming other step's output",
action = Checkout(
sshKey = expr(addAndCommit.outputs.pythonVersion),
path = expr(addAndCommit.outputs["my-unsafe-output"]),
path = addAndCommit.outputs["my-unsafe-output"].expressionString,
),
)

Expand Down Expand Up @@ -234,7 +235,7 @@ workflow(
)
jobOutputs.scriptKey = scriptStep.outputs["key"]
jobOutputs.scriptKey2 = scriptStep.outputs["key2"]
jobOutputs.scriptResult = scriptStep.outputs.result
jobOutputs.scriptResult = Expression(scriptStep.outputs.result)
}

job(
Expand All @@ -250,9 +251,9 @@ workflow(
run(
name = "use output of script",
command = """
echo ${expr { testJob1.outputs.scriptKey }}
echo ${expr { testJob1.outputs.scriptKey2 }}
echo ${expr { testJob1.outputs.scriptResult }}
echo ${testJob1.outputs.scriptKey.expressionString}
echo ${expr(testJob1.outputs.scriptKey2.expression)}
echo ${expr { testJob1.outputs.scriptResult.expression }}
""".trimIndent(),
)

Expand Down
21 changes: 19 additions & 2 deletions action-binding-generator/api/action-binding-generator.api
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,23 @@ public final class io/github/typesafegithub/workflows/actionbindinggenerator/dom
public static final fun isTopLevel (Lio/github/typesafegithub/workflows/actionbindinggenerator/domain/ActionCoords;)Z
}

public final class io/github/typesafegithub/workflows/actionbindinggenerator/domain/ActionTypings {
public fun <init> ()V
public fun <init> (Ljava/util/Map;Ljava/util/Map;Lio/github/typesafegithub/workflows/actionbindinggenerator/domain/TypingActualSource;)V
public synthetic fun <init> (Ljava/util/Map;Ljava/util/Map;Lio/github/typesafegithub/workflows/actionbindinggenerator/domain/TypingActualSource;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
public final fun component1 ()Ljava/util/Map;
public final fun component2 ()Ljava/util/Map;
public final fun component3 ()Lio/github/typesafegithub/workflows/actionbindinggenerator/domain/TypingActualSource;
public final fun copy (Ljava/util/Map;Ljava/util/Map;Lio/github/typesafegithub/workflows/actionbindinggenerator/domain/TypingActualSource;)Lio/github/typesafegithub/workflows/actionbindinggenerator/domain/ActionTypings;
public static synthetic fun copy$default (Lio/github/typesafegithub/workflows/actionbindinggenerator/domain/ActionTypings;Ljava/util/Map;Ljava/util/Map;Lio/github/typesafegithub/workflows/actionbindinggenerator/domain/TypingActualSource;ILjava/lang/Object;)Lio/github/typesafegithub/workflows/actionbindinggenerator/domain/ActionTypings;
public fun equals (Ljava/lang/Object;)Z
public final fun getInputTypings ()Ljava/util/Map;
public final fun getOutputTypings ()Ljava/util/Map;
public final fun getSource ()Lio/github/typesafegithub/workflows/actionbindinggenerator/domain/TypingActualSource;
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
}

public final class io/github/typesafegithub/workflows/actionbindinggenerator/domain/CommitHash : io/github/typesafegithub/workflows/actionbindinggenerator/domain/MetadataRevision {
public fun <init> (Ljava/lang/String;)V
public final fun component1 ()Ljava/lang/String;
Expand Down Expand Up @@ -72,8 +89,8 @@ public final class io/github/typesafegithub/workflows/actionbindinggenerator/gen
}

public final class io/github/typesafegithub/workflows/actionbindinggenerator/generation/GenerationKt {
public static final fun generateBinding (Lio/github/typesafegithub/workflows/actionbindinggenerator/domain/ActionCoords;Lio/github/typesafegithub/workflows/actionbindinggenerator/versioning/BindingVersion;Lio/github/typesafegithub/workflows/actionbindinggenerator/domain/MetadataRevision;Lio/github/typesafegithub/workflows/actionbindinggenerator/metadata/Metadata;Lkotlin/Pair;)Ljava/util/List;
public static synthetic fun generateBinding$default (Lio/github/typesafegithub/workflows/actionbindinggenerator/domain/ActionCoords;Lio/github/typesafegithub/workflows/actionbindinggenerator/versioning/BindingVersion;Lio/github/typesafegithub/workflows/actionbindinggenerator/domain/MetadataRevision;Lio/github/typesafegithub/workflows/actionbindinggenerator/metadata/Metadata;Lkotlin/Pair;ILjava/lang/Object;)Ljava/util/List;
public static final fun generateBinding (Lio/github/typesafegithub/workflows/actionbindinggenerator/domain/ActionCoords;Lio/github/typesafegithub/workflows/actionbindinggenerator/versioning/BindingVersion;Lio/github/typesafegithub/workflows/actionbindinggenerator/domain/MetadataRevision;Lio/github/typesafegithub/workflows/actionbindinggenerator/metadata/Metadata;Lio/github/typesafegithub/workflows/actionbindinggenerator/domain/ActionTypings;)Ljava/util/List;
public static synthetic fun generateBinding$default (Lio/github/typesafegithub/workflows/actionbindinggenerator/domain/ActionCoords;Lio/github/typesafegithub/workflows/actionbindinggenerator/versioning/BindingVersion;Lio/github/typesafegithub/workflows/actionbindinggenerator/domain/MetadataRevision;Lio/github/typesafegithub/workflows/actionbindinggenerator/metadata/Metadata;Lio/github/typesafegithub/workflows/actionbindinggenerator/domain/ActionTypings;ILjava/lang/Object;)Ljava/util/List;
}

public final class io/github/typesafegithub/workflows/actionbindinggenerator/metadata/Input {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package io.github.typesafegithub.workflows.actionbindinggenerator.domain

import io.github.typesafegithub.workflows.actionbindinggenerator.typing.Typing

public data class ActionTypings(
val inputTypings: Map<String, Typing> = emptyMap(),
val outputTypings: Map<String, Typing> = emptyMap(),
val source: TypingActualSource? = null,
)
Loading

0 comments on commit 5cf2155

Please sign in to comment.