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 Aug 31, 2024
1 parent 3dcf646 commit 59626c0
Show file tree
Hide file tree
Showing 38 changed files with 1,447 additions and 528 deletions.
33 changes: 17 additions & 16 deletions .github/workflows/bindings-server.main.kts
Original file line number Diff line number Diff line change
Expand Up @@ -79,25 +79,26 @@ workflow(
}
}

cleanMavenLocal()
// TODO: Reenable after release, currently, new class "Expression" cannot be found
//cleanMavenLocal()

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

cleanMavenLocal()
//cleanMavenLocal()

run(
name = "Execute the script using bindings but without dependency on library",
command = """
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
""".trimIndent(),
)
//run(
// name = "Execute the script using bindings but without dependency on library",
// command = """
// 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
// """.trimIndent(),
//)

run(
name = "Fetch maven-metadata.xml for top-level action",
Expand Down
18 changes: 1 addition & 17 deletions .github/workflows/bindings-server.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,25 +46,9 @@ jobs:
GHWKT_GITHUB_CONTEXT_JSON: '${{ toJSON(github) }}'
run: 'GHWKT_RUN_STEP=''end-to-end-test:step-3'' ''.github/workflows/bindings-server.main.kts'''
- id: 'step-4'
name: 'Clean Maven Local to fetch required POMs again'
run: 'rm -rf ~/.m2/repository/'
- id: 'step-5'
name: 'Execute the script using the bindings from the server'
run: |-
mv .github/workflows/test-script-consuming-jit-bindings.main.do-not-compile.kts .github/workflows/test-script-consuming-jit-bindings.main.kts
.github/workflows/test-script-consuming-jit-bindings.main.kts
- id: 'step-6'
name: 'Clean Maven Local to fetch required POMs again'
run: 'rm -rf ~/.m2/repository/'
- id: 'step-7'
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-8'
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-9'
- id: 'step-5'
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/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/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/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/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 59626c0

Please sign in to comment.