From cc3904ec5a8e36107a4573df9565e8672f2bdfb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Kautler?= Date: Fri, 16 Aug 2024 12:07:43 +0200 Subject: [PATCH 1/3] feat(server): make it possible to POST custom typings for testing during typing creation --- .../api/action-binding-generator.api | 13 ++ .../domain/ActionCoords.kt | 7 +- .../domain/TypingActualSource.kt | 1 + .../generation/Generation.kt | 3 +- .../typing/TypesProviding.kt | 12 +- .../typing/TypesProvidingTest.kt | 154 ++++++++++++++++++ docs/user-guide/using-actions.md | 12 ++ jit-binding-server/build.gradle.kts | 1 + .../jitbindingserver/ArtifactRoutes.kt | 51 +++++- .../workflows/jitbindingserver/Main.kt | 2 +- .../jitbindingserver/RequestParsing.kt | 20 ++- .../mavenbinding/BindingsServerRequest.kt | 1 + .../workflows/mavenbinding/JarBuilding.kt | 4 +- .../workflows/mavenbinding/ModuleBuilding.kt | 2 +- .../workflows/mavenbinding/PomBuilding.kt | 2 +- .../mavenbinding/VersionArtifactsBuilding.kt | 3 +- 16 files changed, 271 insertions(+), 17 deletions(-) diff --git a/action-binding-generator/api/action-binding-generator.api b/action-binding-generator/api/action-binding-generator.api index 9dc904e866..6ef5c65638 100644 --- a/action-binding-generator/api/action-binding-generator.api +++ b/action-binding-generator/api/action-binding-generator.api @@ -1,4 +1,8 @@ public final class io/github/typesafegithub/workflows/actionbindinggenerator/domain/ActionCoords { + public fun (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lio/github/typesafegithub/workflows/actionbindinggenerator/domain/SignificantVersion;Ljava/lang/String;)V + public synthetic fun (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lio/github/typesafegithub/workflows/actionbindinggenerator/domain/SignificantVersion;Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public fun (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lio/github/typesafegithub/workflows/actionbindinggenerator/domain/SignificantVersion;Ljava/lang/String;Ljava/lang/String;)V + public synthetic fun (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lio/github/typesafegithub/workflows/actionbindinggenerator/domain/SignificantVersion;Ljava/lang/String;Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V public fun (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lio/github/typesafegithub/workflows/actionbindinggenerator/domain/SignificantVersion;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V public synthetic fun (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lio/github/typesafegithub/workflows/actionbindinggenerator/domain/SignificantVersion;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V public final fun component1 ()Ljava/lang/String; @@ -7,6 +11,9 @@ public final class io/github/typesafegithub/workflows/actionbindinggenerator/dom public final fun component4 ()Lio/github/typesafegithub/workflows/actionbindinggenerator/domain/SignificantVersion; public final fun component5 ()Ljava/lang/String; public final fun component6 ()Ljava/lang/String; + public static synthetic fun copy$default (Lio/github/typesafegithub/workflows/actionbindinggenerator/domain/ActionCoords;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lio/github/typesafegithub/workflows/actionbindinggenerator/domain/SignificantVersion;Ljava/lang/String;ILjava/lang/Object;)Lio/github/typesafegithub/workflows/actionbindinggenerator/domain/ActionCoords; + public final fun copy (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lio/github/typesafegithub/workflows/actionbindinggenerator/domain/SignificantVersion;Ljava/lang/String;Ljava/lang/String;)Lio/github/typesafegithub/workflows/actionbindinggenerator/domain/ActionCoords; + public static synthetic fun copy$default (Lio/github/typesafegithub/workflows/actionbindinggenerator/domain/ActionCoords;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lio/github/typesafegithub/workflows/actionbindinggenerator/domain/SignificantVersion;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Lio/github/typesafegithub/workflows/actionbindinggenerator/domain/ActionCoords; public final fun component7 ()Ljava/lang/String; public final fun copy (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lio/github/typesafegithub/workflows/actionbindinggenerator/domain/SignificantVersion;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Lio/github/typesafegithub/workflows/actionbindinggenerator/domain/ActionCoords; public static synthetic fun copy$default (Lio/github/typesafegithub/workflows/actionbindinggenerator/domain/ActionCoords;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lio/github/typesafegithub/workflows/actionbindinggenerator/domain/SignificantVersion;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Lio/github/typesafegithub/workflows/actionbindinggenerator/domain/ActionCoords; @@ -16,6 +23,7 @@ public final class io/github/typesafegithub/workflows/actionbindinggenerator/dom public final fun getOwner ()Ljava/lang/String; public final fun getPath ()Ljava/lang/String; public final fun getSignificantVersion ()Lio/github/typesafegithub/workflows/actionbindinggenerator/domain/SignificantVersion; + public final fun getTypesUuid ()Ljava/lang/String; public final fun getVersion ()Ljava/lang/String; public final fun getVersionForTypings ()Ljava/lang/String; public fun hashCode ()I @@ -81,6 +89,7 @@ public final class io/github/typesafegithub/workflows/actionbindinggenerator/dom public final class io/github/typesafegithub/workflows/actionbindinggenerator/domain/TypingActualSource : java/lang/Enum { public static final field ACTION Lio/github/typesafegithub/workflows/actionbindinggenerator/domain/TypingActualSource; + public static final field CUSTOM Lio/github/typesafegithub/workflows/actionbindinggenerator/domain/TypingActualSource; public static final field TYPING_CATALOG Lio/github/typesafegithub/workflows/actionbindinggenerator/domain/TypingActualSource; public static fun getEntries ()Lkotlin/enums/EnumEntries; public static fun valueOf (Ljava/lang/String;)Lio/github/typesafegithub/workflows/actionbindinggenerator/domain/TypingActualSource; @@ -107,6 +116,10 @@ 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;Lkotlin/Pair;Ljava/lang/String;)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;Ljava/lang/String;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;Lio/ktor/client/HttpClient;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; 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;Lio/ktor/client/HttpClient;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; } diff --git a/action-binding-generator/src/main/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/domain/ActionCoords.kt b/action-binding-generator/src/main/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/domain/ActionCoords.kt index 4a3518509a..88255f124a 100644 --- a/action-binding-generator/src/main/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/domain/ActionCoords.kt +++ b/action-binding-generator/src/main/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/domain/ActionCoords.kt @@ -25,6 +25,7 @@ public data class ActionCoords( * the typings are defined. */ val versionForTypings: String = version, + val typesUuid: String? = null, ) /** @@ -33,9 +34,11 @@ public data class ActionCoords( */ public val ActionCoords.isTopLevel: Boolean get() = path == null -public val ActionCoords.prettyPrint: String get() = "$prettyPrintWithoutVersion@$version" +public val ActionCoords.prettyPrint: String get() = "$prettyPrintBase@$version${typesUuid?.let { " (types: $it)" } ?: ""}" -public val ActionCoords.prettyPrintWithoutVersion: String get() = "$owner/$fullName${ +public val ActionCoords.prettyPrintWithoutVersion: String get() = "$prettyPrintBase${typesUuid?.let { " (types: $it)" } ?: ""}" + +private val ActionCoords.prettyPrintBase: String get() = "$owner/$fullName${ significantVersion.takeUnless { it == FULL }?.let { " with $it version" } ?: "" }${ if ((significantVersion == COMMIT_LENIENT) && (comment != null)) " and comment '$comment'" else "" diff --git a/action-binding-generator/src/main/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/domain/TypingActualSource.kt b/action-binding-generator/src/main/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/domain/TypingActualSource.kt index 094f3251b4..4a6fca4f9e 100644 --- a/action-binding-generator/src/main/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/domain/TypingActualSource.kt +++ b/action-binding-generator/src/main/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/domain/TypingActualSource.kt @@ -3,4 +3,5 @@ package io.github.typesafegithub.workflows.actionbindinggenerator.domain public enum class TypingActualSource { ACTION, TYPING_CATALOG, + CUSTOM, } diff --git a/action-binding-generator/src/main/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/generation/Generation.kt b/action-binding-generator/src/main/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/generation/Generation.kt index 4bd81df904..5c9c4e8db2 100644 --- a/action-binding-generator/src/main/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/generation/Generation.kt +++ b/action-binding-generator/src/main/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/generation/Generation.kt @@ -72,13 +72,14 @@ public suspend fun ActionCoords.generateBinding( metadataRevision: MetadataRevision, metadata: Metadata? = null, inputTypings: ActionTypings? = null, + types: String? = null, httpClient: HttpClient = HttpClient(CIO), ): List { val metadataResolved = metadata ?: this.fetchMetadata(metadataRevision, httpClient = httpClient) ?: return emptyList() val metadataProcessed = metadataResolved.removeDeprecatedInputsIfNameClash() - val inputTypingsResolved = inputTypings ?: this.provideTypes(metadataRevision, httpClient = httpClient) + val inputTypingsResolved = inputTypings ?: this.provideTypes(metadataRevision, types = types, httpClient = httpClient) val packageName = owner.toKotlinPackageName() val className = this.buildActionClassName() diff --git a/action-binding-generator/src/main/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/typing/TypesProviding.kt b/action-binding-generator/src/main/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/typing/TypesProviding.kt index 9b3369d0b1..95a4199884 100644 --- a/action-binding-generator/src/main/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/typing/TypesProviding.kt +++ b/action-binding-generator/src/main/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/typing/TypesProviding.kt @@ -11,6 +11,7 @@ import io.github.typesafegithub.workflows.actionbindinggenerator.domain.Metadata import io.github.typesafegithub.workflows.actionbindinggenerator.domain.NewestForVersion import io.github.typesafegithub.workflows.actionbindinggenerator.domain.TypingActualSource import io.github.typesafegithub.workflows.actionbindinggenerator.domain.TypingActualSource.ACTION +import io.github.typesafegithub.workflows.actionbindinggenerator.domain.TypingActualSource.CUSTOM import io.github.typesafegithub.workflows.actionbindinggenerator.domain.TypingActualSource.TYPING_CATALOG import io.github.typesafegithub.workflows.actionbindinggenerator.domain.subName import io.github.typesafegithub.workflows.actionbindinggenerator.utils.toPascalCase @@ -26,11 +27,13 @@ private val logger = logger { } internal suspend fun ActionCoords.provideTypes( metadataRevision: MetadataRevision, + types: String? = null, httpClient: HttpClient, ): ActionTypings = ( - this.fetchTypingMetadata(metadataRevision, httpClient) - ?: this.toMajorVersionForTypings().fetchFromTypingsFromCatalog(httpClient) + customTypingMetadata(types) + ?: this.fetchTypingMetadata(metadataRevision, httpClient) + ?: this.toMajorVersionForTypings().fetchTypingsFromCatalog(httpClient) )?.let { (typings, typingActualSource) -> ActionTypings( inputTypings = typings.toTypesMap(), @@ -53,6 +56,9 @@ private fun ActionCoords.actionTypesFromCatalog() = private fun ActionCoords.catalogMetadata() = "$CATALOG_BASE_URL/${owner.lowercase()}/${name.lowercase()}/metadata.yml" +private fun customTypingMetadata(types: String? = null) = + types?.let { Pair(yaml.decodeFromStringOrDefaultIfEmpty(it, ActionTypes()), CUSTOM) } + private suspend fun ActionCoords.fetchTypingMetadata( metadataRevision: MetadataRevision, httpClient: HttpClient, @@ -86,7 +92,7 @@ private suspend fun ActionCoords.fetchTypingMetadata( return Pair(yaml.decodeFromStringOrDefaultIfEmpty(typesMetadataYaml, ActionTypes()), ACTION) } -private suspend fun ActionCoords.fetchFromTypingsFromCatalog( +private suspend fun ActionCoords.fetchTypingsFromCatalog( httpClient: HttpClient, ): Pair? = ( diff --git a/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/typing/TypesProvidingTest.kt b/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/typing/TypesProvidingTest.kt index fb1bcd5a17..7229fad889 100644 --- a/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/typing/TypesProvidingTest.kt +++ b/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/typing/TypesProvidingTest.kt @@ -182,6 +182,12 @@ class TypesProvidingTest : stored-in-typing-catalog: type: string """.trimIndent() + val custom = + """ + inputs: + custom: + type: string + """.trimIndent() val metadata = """ "versionsWithTypings": @@ -564,6 +570,134 @@ class TypesProvidingTest : ) } + test("only custom") { + // Given + val fetchUri: (URI) -> String = { throw IOException() } + val actionCoord = ActionCoords("some-owner", "some-name", "v3") + + // When + val types = actionCoord.provideTypes(metadataRevision = CommitHash("some-hash"), fetchUri = fetchUri, types = custom) + + // Then + types shouldBe Pair(mapOf("custom" to StringTyping), TypingActualSource.CUSTOM) + } + + test("only custom for subaction") { + // Given + val fetchUri: (URI) -> String = { throw IOException() } + val actionCoord = ActionCoords("some-owner", "some-name", "v3", FULL, "some-sub") + + // When + val types = actionCoord.provideTypes(metadataRevision = CommitHash("some-hash"), fetchUri = fetchUri, types = custom) + + // Then + types shouldBe Pair(mapOf("custom" to StringTyping), TypingActualSource.CUSTOM) + } + + test("hosted by action, stored in typing catalog, and custom") { + // Given + val fetchUri: (URI) -> String = { + when (it) { + URI( + "https://raw.githubusercontent.com/some-owner/some-name/" + + "some-hash/action-types.yml", + ), + -> hostedByActionYml + URI( + "https://raw.githubusercontent.com/typesafegithub/github-actions-typing-catalog/" + + "main/typings/some-owner/some-name/v3/action-types.yml", + ), + -> storedInTypingCatalog + else -> throw IOException() + } + } + val actionCoord = ActionCoords("some-owner", "some-name", "v3") + + // When + val types = actionCoord.provideTypes(metadataRevision = CommitHash("some-hash"), fetchUri = fetchUri, types = custom) + + // Then + types shouldBe Pair(mapOf("custom" to StringTyping), TypingActualSource.CUSTOM) + } + + test("hosted by subaction, stored in typing catalog, and custom") { + // Given + val fetchUri: (URI) -> String = { + when (it) { + URI( + "https://raw.githubusercontent.com/some-owner/some-name/" + + "some-hash/some-sub/action-types.yml", + ), + -> hostedByActionYml + URI( + "https://raw.githubusercontent.com/typesafegithub/github-actions-typing-catalog/" + + "main/typings/some-owner/some-name/v3/some-sub/action-types.yml", + ), + -> storedInTypingCatalog + else -> throw IOException() + } + } + val actionCoord = ActionCoords("some-owner", "some-name", "v3", FULL, "some-sub") + + // When + val types = actionCoord.provideTypes(metadataRevision = CommitHash("some-hash"), fetchUri = fetchUri, types = custom) + + // Then + types shouldBe Pair(mapOf("custom" to StringTyping), TypingActualSource.CUSTOM) + } + + test("hosted by action, stored in typing catalog, and empty custom") { + // Given + val fetchUri: (URI) -> String = { + when (it) { + URI( + "https://raw.githubusercontent.com/some-owner/some-name/" + + "some-hash/action-types.yml", + ), + -> hostedByActionYml + URI( + "https://raw.githubusercontent.com/typesafegithub/github-actions-typing-catalog/" + + "main/typings/some-owner/some-name/v3/action-types.yml", + ), + -> storedInTypingCatalog + else -> throw IOException() + } + } + val actionCoord = ActionCoords("some-owner", "some-name", "v3") + + // When + val types = actionCoord.provideTypes(metadataRevision = CommitHash("some-hash"), fetchUri = fetchUri, types = "") + + // Then + types shouldBe Pair(emptyMap(), TypingActualSource.CUSTOM) + } + + test("hosted by subaction, stored in typing catalog, and empty custom") { + // Given + val fetchUri: (URI) -> String = { + when (it) { + URI( + "https://raw.githubusercontent.com/some-owner/some-name/" + + "some-hash/some-sub/action-types.yml", + ), + -> hostedByActionYml + URI( + "https://raw.githubusercontent.com/typesafegithub/github-actions-typing-catalog/" + + "main/typings/some-owner/some-name/v3/some-sub/action-types.yml", + ), + -> storedInTypingCatalog + else -> throw IOException() + } + } + val actionCoord = ActionCoords("some-owner", "some-name", "v3", FULL, "some-sub") + + // When + val types = actionCoord.provideTypes(metadataRevision = CommitHash("some-hash"), fetchUri = fetchUri, types = "") + + // Then + types shouldBe Pair(emptyMap(), TypingActualSource.CUSTOM) + } + test("only stored in typing catalog for older version") { // Given val mockClient = @@ -1125,6 +1259,26 @@ class TypesProvidingTest : ) } + test("only custom") { + // Given + val fetchUri: (URI) -> String = { throw IOException() } + val actionCoord = ActionCoords("some-owner", "some-name", "v3") + + // When + val types = actionCoord.provideTypes(metadataRevision = CommitHash("some-hash"), fetchUri = fetchUri, types = typingYml) + + // Then + types shouldBe + Pair( + mapOf( + "granted-scopes" to ListOfTypings(",", EnumTyping("GrantedScopes", listOf("read", "write"))), + "granted-scopes2" to ListOfTypings(",", EnumTyping("GrantedScopes", listOf("read", "write"))), + "granted-scopes3" to ListOfTypings("""\n""", EnumTyping("GrantedScopes", listOf("read", "write"))), + ), + TypingActualSource.CUSTOM, + ) + } + test("billion laughs attack is prevented") { // Given val billionLaughsAttack = diff --git a/docs/user-guide/using-actions.md b/docs/user-guide/using-actions.md index f88ea7208b..3f8a59dfa3 100644 --- a/docs/user-guide/using-actions.md +++ b/docs/user-guide/using-actions.md @@ -74,6 +74,18 @@ There are two ways of configuring typings: a community-maintained place to host the typings. You can contribute or fix typings for your favorite action by sending a PR. +While developing a typing manifest it might be a good idea to test the result without needing to +release the action in question or merge a PR in the catalog. For this you can `POST` the typing manifest you have +on disk to the binding server using any valid URL for the action in question, for example using +```bash +curl --data-binary @action-types.yml https://bindings.krzeminski.it/pbrisbin/setup-tool-action/v2/setup-tool-action-v2.pom +``` +The binding server generates a binding with only the given type manifest and answer with some unique coordinates +that you can use in a test workflow script. The binding will be available the normal cache time on the binding +server and locally as long as you do not delete it from your local Maven repository where it is cached. After +the cache period on the server ended requesting the same coordinates will return a binding as if no typing +information is available at all. + Once there are any typings in place for the action, the `_Untyped` suffixed class is marked `@Deprecated`, and a class without that suffix is created additionally. In that class for each input that does not have type information available there will still be only the property with `_Untyped` suffix and nullability according to required status. For each diff --git a/jit-binding-server/build.gradle.kts b/jit-binding-server/build.gradle.kts index 47d94e57ac..57fa3bf1fb 100644 --- a/jit-binding-server/build.gradle.kts +++ b/jit-binding-server/build.gradle.kts @@ -13,6 +13,7 @@ dependencies { implementation("io.ktor:ktor-server-netty") implementation("io.ktor:ktor-server-call-logging") implementation("io.ktor:ktor-server-call-id") + implementation("it.krzeminski:snakeyaml-engine-kmp:3.0.2") implementation("io.ktor:ktor-server-metrics-micrometer") implementation("io.ktor:ktor-client-core") implementation("io.ktor:ktor-client-cio") diff --git a/jit-binding-server/src/main/kotlin/io/github/typesafegithub/workflows/jitbindingserver/ArtifactRoutes.kt b/jit-binding-server/src/main/kotlin/io/github/typesafegithub/workflows/jitbindingserver/ArtifactRoutes.kt index 824d422841..014e073dda 100644 --- a/jit-binding-server/src/main/kotlin/io/github/typesafegithub/workflows/jitbindingserver/ArtifactRoutes.kt +++ b/jit-binding-server/src/main/kotlin/io/github/typesafegithub/workflows/jitbindingserver/ArtifactRoutes.kt @@ -8,24 +8,29 @@ import io.github.typesafegithub.workflows.mavenbinding.BindingsServerRequest import io.github.typesafegithub.workflows.mavenbinding.JarArtifact import io.github.typesafegithub.workflows.mavenbinding.TextArtifact import io.github.typesafegithub.workflows.mavenbinding.VersionArtifacts +import io.github.typesafegithub.workflows.mavenbinding.buildVersionArtifacts import io.ktor.http.ContentType import io.ktor.http.HttpStatusCode import io.ktor.server.application.ApplicationCall import io.ktor.server.request.httpMethod +import io.ktor.server.request.receiveText import io.ktor.server.response.respondBytes import io.ktor.server.response.respondText import io.ktor.server.routing.Route import io.ktor.server.routing.Routing import io.ktor.server.routing.get import io.ktor.server.routing.head +import io.ktor.server.routing.post import io.ktor.server.routing.route import io.micrometer.core.instrument.Tag import io.micrometer.core.instrument.binder.cache.CaffeineCacheMetrics import io.micrometer.prometheusmetrics.PrometheusMeterRegistry +import it.krzeminski.snakeyaml.engine.kmp.api.Load import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch import java.util.Optional +import java.util.UUID.randomUUID import kotlin.jvm.optionals.getOrNull private val logger = logger { } @@ -58,6 +63,7 @@ private fun Route.artifact( ) { headArtifact(bindingsCache, prometheusRegistry, refresh) getArtifact(bindingsCache, prometheusRegistry, refresh) + postArtifact(bindingsCache, prometheusRegistry) } private fun Route.headArtifact( @@ -112,17 +118,57 @@ internal fun prefetchBindingArtifacts( } } +private fun Route.postArtifact( + bindingsCache: LoadingCache, + prometheusRegistry: PrometheusMeterRegistry?, +) { + post { + val owner = "${call.parameters["owner"]}__types__${randomUUID()}" + val name = call.parameters["name"]!! + val version = call.parameters["version"]!! + val types = call.receiveText() + runCatching { + Load().loadOne(types) + }.onFailure { + call.respondText( + text = "Exception while parsing supplied typings:\n${it.stackTraceToString()}", + status = HttpStatusCode.UnprocessableEntity, + ) + return@post + } + val typingActualSource = + call + .toBindingArtifacts( + refresh = true, + bindingsCache = bindingsCache, + owner = owner, + types = types, + )?.typingActualSource ?: TypingActualSource.CUSTOM + call.respondText(text = "$owner:$name:$version") + + prometheusRegistry?.incrementArtifactCounter(call, typingActualSource) + } +} + private suspend fun ApplicationCall.toBindingArtifacts( refresh: Boolean, bindingsCache: LoadingCache, + owner: String = parameters["owner"]!!, + types: String? = null, ): VersionArtifacts? { - val parsedRequest = parameters.parseRequest(extractVersion = true) ?: return null + val parsedRequest = parameters.parseRequest(extractVersion = true, owner = owner) ?: return null logger.info { "➡️ Requesting ${parsedRequest.actionCoords.prettyPrint}" } if (refresh) { bindingsCache.invalidate(parsedRequest) } - return bindingsCache.get(parsedRequest).getOrNull() + return ( + if (types != null) { + bindingsCache.get(parsedRequest) { buildVersionArtifacts(parsedRequest, types) }.getOrNull() + } else { + bindingsCache.get(parsedRequest).getOrNull() + } + ) } private fun PrometheusMeterRegistry.incrementArtifactCounter( @@ -143,6 +189,7 @@ private fun PrometheusMeterRegistry.incrementArtifactCounter( when (typingActualSource) { TypingActualSource.ACTION -> "action" TypingActualSource.TYPING_CATALOG -> "typing_catalog" + TypingActualSource.CUSTOM -> "custom" null -> "no_typing" } diff --git a/jit-binding-server/src/main/kotlin/io/github/typesafegithub/workflows/jitbindingserver/Main.kt b/jit-binding-server/src/main/kotlin/io/github/typesafegithub/workflows/jitbindingserver/Main.kt index 77ea514214..ba3e9c66f7 100644 --- a/jit-binding-server/src/main/kotlin/io/github/typesafegithub/workflows/jitbindingserver/Main.kt +++ b/jit-binding-server/src/main/kotlin/io/github/typesafegithub/workflows/jitbindingserver/Main.kt @@ -59,7 +59,7 @@ fun main() { } embeddedServer(Netty, port = 8080) { appModule( - buildVersionArtifacts = ::buildVersionArtifacts, + buildVersionArtifacts = { buildVersionArtifacts(it, it.typesUuid?.let { "" }) }, buildPackageArtifacts = ::buildPackageArtifacts, getGithubAuthToken = ::getGithubAuthToken, ) diff --git a/jit-binding-server/src/main/kotlin/io/github/typesafegithub/workflows/jitbindingserver/RequestParsing.kt b/jit-binding-server/src/main/kotlin/io/github/typesafegithub/workflows/jitbindingserver/RequestParsing.kt index 56770914cb..85591afc64 100644 --- a/jit-binding-server/src/main/kotlin/io/github/typesafegithub/workflows/jitbindingserver/RequestParsing.kt +++ b/jit-binding-server/src/main/kotlin/io/github/typesafegithub/workflows/jitbindingserver/RequestParsing.kt @@ -10,8 +10,10 @@ import io.ktor.http.Parameters /** * Returns `null` if the request doesn't make sense and the service should return no resource. */ -fun Parameters.parseRequest(extractVersion: Boolean): BindingsServerRequest? { - val owner = this["owner"]!! +fun Parameters.parseRequest( + extractVersion: Boolean, + owner: String = this["owner"]!!, +): BindingsServerRequest? { val nameAndPathAndSignificantVersionParts = this["name"]!!.split("___", limit = 2) val significantVersion = nameAndPathAndSignificantVersionParts @@ -49,19 +51,31 @@ fun Parameters.parseRequest(extractVersion: Boolean): BindingsServerRequest? { val comment = if ((significantVersion == COMMIT_LENIENT) && extractVersion) this["version"]!!.split("__")[0] else null val versionForTypings = if (extractVersion) this["version"]!!.split("__")[0] else "irrelevant" + // we cannot give the types UUID separately from the post handler + // only in the post handler we generate the UUID, but for the other + // handlers the UUID part is already coming through the request as part of the owner + val ownerAndTypesUuid = owner.split("__types__", limit = 2) + val ownerPlain = ownerAndTypesUuid.first() + val typesUuid = + ownerAndTypesUuid + .drop(1) + .takeIf { it.isNotEmpty() } + ?.single() return BindingsServerRequest( + rawOwner = owner, rawName = this["name"]!!, rawVersion = this["version"], actionCoords = ActionCoords( - owner = owner, + owner = ownerPlain, name = name, version = version, versionForTypings = versionForTypings, significantVersion = significantVersion, path = path, comment = comment, + typesUuid = typesUuid, ), ) } diff --git a/maven-binding-builder/src/main/kotlin/io/github/typesafegithub/workflows/mavenbinding/BindingsServerRequest.kt b/maven-binding-builder/src/main/kotlin/io/github/typesafegithub/workflows/mavenbinding/BindingsServerRequest.kt index ebc3eb2b76..d99e0e74aa 100644 --- a/maven-binding-builder/src/main/kotlin/io/github/typesafegithub/workflows/mavenbinding/BindingsServerRequest.kt +++ b/maven-binding-builder/src/main/kotlin/io/github/typesafegithub/workflows/mavenbinding/BindingsServerRequest.kt @@ -3,6 +3,7 @@ package io.github.typesafegithub.workflows.mavenbinding import io.github.typesafegithub.workflows.actionbindinggenerator.domain.ActionCoords data class BindingsServerRequest( + val rawOwner: String, val rawName: String, val rawVersion: String?, val actionCoords: ActionCoords, diff --git a/maven-binding-builder/src/main/kotlin/io/github/typesafegithub/workflows/mavenbinding/JarBuilding.kt b/maven-binding-builder/src/main/kotlin/io/github/typesafegithub/workflows/mavenbinding/JarBuilding.kt index 9a6d43c171..dca0e6e8b0 100644 --- a/maven-binding-builder/src/main/kotlin/io/github/typesafegithub/workflows/mavenbinding/JarBuilding.kt +++ b/maven-binding-builder/src/main/kotlin/io/github/typesafegithub/workflows/mavenbinding/JarBuilding.kt @@ -32,9 +32,9 @@ internal data class Jars( val typingActualSource: TypingActualSource?, ) -internal suspend fun ActionCoords.buildJars(httpClient: HttpClient): Jars? { +internal suspend fun ActionCoords.buildJars(types: String?, httpClient: HttpClient): Jars? { val binding = - generateBinding(metadataRevision = NewestForVersion, httpClient = httpClient).also { + generateBinding(metadataRevision = NewestForVersion, types = types, httpClient = httpClient).also { if (it.isEmpty()) return null } diff --git a/maven-binding-builder/src/main/kotlin/io/github/typesafegithub/workflows/mavenbinding/ModuleBuilding.kt b/maven-binding-builder/src/main/kotlin/io/github/typesafegithub/workflows/mavenbinding/ModuleBuilding.kt index f9b98d6625..a8c23c38ca 100644 --- a/maven-binding-builder/src/main/kotlin/io/github/typesafegithub/workflows/mavenbinding/ModuleBuilding.kt +++ b/maven-binding-builder/src/main/kotlin/io/github/typesafegithub/workflows/mavenbinding/ModuleBuilding.kt @@ -15,7 +15,7 @@ internal fun BindingsServerRequest.buildModuleFile( { "formatVersion": "1.1", "component": { - "group": "${actionCoords.owner}", + "group": "$rawOwner", "module": "$rawName", "version": "$rawVersion", "attributes": { diff --git a/maven-binding-builder/src/main/kotlin/io/github/typesafegithub/workflows/mavenbinding/PomBuilding.kt b/maven-binding-builder/src/main/kotlin/io/github/typesafegithub/workflows/mavenbinding/PomBuilding.kt index 463c574f6f..eb5ce63d8f 100644 --- a/maven-binding-builder/src/main/kotlin/io/github/typesafegithub/workflows/mavenbinding/PomBuilding.kt +++ b/maven-binding-builder/src/main/kotlin/io/github/typesafegithub/workflows/mavenbinding/PomBuilding.kt @@ -10,7 +10,7 @@ internal fun BindingsServerRequest.buildPomFile() = 4.0.0 - ${this.actionCoords.owner} + ${this.rawOwner} ${this.rawName} ${this.rawVersion} ${this.actionCoords.fullName} diff --git a/maven-binding-builder/src/main/kotlin/io/github/typesafegithub/workflows/mavenbinding/VersionArtifactsBuilding.kt b/maven-binding-builder/src/main/kotlin/io/github/typesafegithub/workflows/mavenbinding/VersionArtifactsBuilding.kt index 55df3dc892..8859a021f4 100644 --- a/maven-binding-builder/src/main/kotlin/io/github/typesafegithub/workflows/mavenbinding/VersionArtifactsBuilding.kt +++ b/maven-binding-builder/src/main/kotlin/io/github/typesafegithub/workflows/mavenbinding/VersionArtifactsBuilding.kt @@ -20,10 +20,11 @@ data class VersionArtifacts( suspend fun buildVersionArtifacts( bindingsServerRequest: BindingsServerRequest, + types: String? = null, httpClient: HttpClient, ): VersionArtifacts? { with(bindingsServerRequest) { - val jars = actionCoords.buildJars(httpClient = httpClient) ?: return null + val jars = actionCoords.buildJars(types = types, httpClient = httpClient) ?: return null val pom = this.buildPomFile() val mainJarSize by lazy { jars.mainJar().size } val mainJarMd5Checksum by lazy { jars.mainJar().md5Checksum() } From 46e4867f8cbf837a492a63ebb730b1f9926e5f4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Kautler?= Date: Mon, 27 Jan 2025 14:03:32 +0100 Subject: [PATCH 2/3] Also make it possible to supply the action manifest --- .../api/action-binding-generator.api | 8 ++ .../generation/Generation.kt | 3 +- .../metadata/MetadataReading.kt | 5 + docs/user-guide/using-actions.md | 8 +- .../jitbindingserver/ArtifactRoutes.kt | 95 +++++++++++++++++-- .../workflows/jitbindingserver/Main.kt | 2 + .../workflows/jitbindingserver/PartData.kt | 20 ++++ .../workflows/mavenbinding/JarBuilding.kt | 8 +- .../mavenbinding/VersionArtifactsBuilding.kt | 3 +- 9 files changed, 138 insertions(+), 14 deletions(-) create mode 100644 jit-binding-server/src/main/kotlin/io/github/typesafegithub/workflows/jitbindingserver/PartData.kt diff --git a/action-binding-generator/api/action-binding-generator.api b/action-binding-generator/api/action-binding-generator.api index 6ef5c65638..88d48b76bb 100644 --- a/action-binding-generator/api/action-binding-generator.api +++ b/action-binding-generator/api/action-binding-generator.api @@ -116,6 +116,10 @@ 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/lang/String;)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;Ljava/lang/String;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;Lkotlin/Pair;Ljava/lang/String;Ljava/lang/String;)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;Ljava/lang/String;Ljava/lang/String;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;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;Lkotlin/Pair;Ljava/lang/String;)Ljava/util/List; @@ -194,6 +198,10 @@ public final class io/github/typesafegithub/workflows/actionbindinggenerator/met } public final class io/github/typesafegithub/workflows/actionbindinggenerator/metadata/MetadataReadingKt { + public static final fun fetchMetadata (Lio/github/typesafegithub/workflows/actionbindinggenerator/domain/ActionCoords;Lio/github/typesafegithub/workflows/actionbindinggenerator/domain/MetadataRevision;Lkotlin/jvm/functions/Function1;)Lio/github/typesafegithub/workflows/actionbindinggenerator/metadata/Metadata; + public static synthetic fun fetchMetadata$default (Lio/github/typesafegithub/workflows/actionbindinggenerator/domain/ActionCoords;Lio/github/typesafegithub/workflows/actionbindinggenerator/domain/MetadataRevision;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lio/github/typesafegithub/workflows/actionbindinggenerator/metadata/Metadata; + public static final fun fetchMetadata (Lio/github/typesafegithub/workflows/actionbindinggenerator/domain/ActionCoords;Lio/github/typesafegithub/workflows/actionbindinggenerator/domain/MetadataRevision;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lio/github/typesafegithub/workflows/actionbindinggenerator/metadata/Metadata; + public static synthetic fun fetchMetadata$default (Lio/github/typesafegithub/workflows/actionbindinggenerator/domain/ActionCoords;Lio/github/typesafegithub/workflows/actionbindinggenerator/domain/MetadataRevision;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lio/github/typesafegithub/workflows/actionbindinggenerator/metadata/Metadata; public static final fun fetchMetadata (Lio/github/typesafegithub/workflows/actionbindinggenerator/domain/ActionCoords;Lio/github/typesafegithub/workflows/actionbindinggenerator/domain/MetadataRevision;Lio/ktor/client/HttpClient;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; } diff --git a/action-binding-generator/src/main/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/generation/Generation.kt b/action-binding-generator/src/main/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/generation/Generation.kt index 5c9c4e8db2..622a8dc4d1 100644 --- a/action-binding-generator/src/main/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/generation/Generation.kt +++ b/action-binding-generator/src/main/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/generation/Generation.kt @@ -73,10 +73,11 @@ public suspend fun ActionCoords.generateBinding( metadata: Metadata? = null, inputTypings: ActionTypings? = null, types: String? = null, + explicitMetadata: String? = null, httpClient: HttpClient = HttpClient(CIO), ): List { val metadataResolved = - metadata ?: this.fetchMetadata(metadataRevision, httpClient = httpClient) ?: return emptyList() + metadata ?: this.fetchMetadata(metadataRevision, explicitMetadata, httpClient = httpClient) ?: return emptyList() val metadataProcessed = metadataResolved.removeDeprecatedInputsIfNameClash() val inputTypingsResolved = inputTypings ?: this.provideTypes(metadataRevision, types = types, httpClient = httpClient) diff --git a/action-binding-generator/src/main/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/metadata/MetadataReading.kt b/action-binding-generator/src/main/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/metadata/MetadataReading.kt index b4c1fea8fa..d3b8b06aec 100644 --- a/action-binding-generator/src/main/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/metadata/MetadataReading.kt +++ b/action-binding-generator/src/main/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/metadata/MetadataReading.kt @@ -50,8 +50,13 @@ private fun ActionCoords.actionYamlUrl(gitRef: String) = public suspend fun ActionCoords.fetchMetadata( metadataRevision: MetadataRevision, + explicitMetadata: String? = null, httpClient: HttpClient, ): Metadata? { + if (explicitMetadata != null) { + return yaml.decodeFromString(explicitMetadata) + } + val gitRef = when (metadataRevision) { is CommitHash -> metadataRevision.value diff --git a/docs/user-guide/using-actions.md b/docs/user-guide/using-actions.md index 3f8a59dfa3..881b35568e 100644 --- a/docs/user-guide/using-actions.md +++ b/docs/user-guide/using-actions.md @@ -78,7 +78,7 @@ While developing a typing manifest it might be a good idea to test the result wi release the action in question or merge a PR in the catalog. For this you can `POST` the typing manifest you have on disk to the binding server using any valid URL for the action in question, for example using ```bash -curl --data-binary @action-types.yml https://bindings.krzeminski.it/pbrisbin/setup-tool-action/v2/setup-tool-action-v2.pom +curl -F types=@action-types.yml https://bindings.krzeminski.it/pbrisbin/setup-tool-action/v2/setup-tool-action-v2.pom ``` The binding server generates a binding with only the given type manifest and answer with some unique coordinates that you can use in a test workflow script. The binding will be available the normal cache time on the binding @@ -86,6 +86,12 @@ server and locally as long as you do not delete it from your local Maven reposit the cache period on the server ended requesting the same coordinates will return a binding as if no typing information is available at all. +When writing typings for a new action that is not published yet or a new version with changed inputs / outputs, +you should also provide the new action manifest, that the generation works with that state using +```bash +curl -F actionYaml=@action.yml -F types=@action-types.yml https://bindings.krzeminski.it/foo/bar/vX/bar-vX.pom +``` + Once there are any typings in place for the action, the `_Untyped` suffixed class is marked `@Deprecated`, and a class without that suffix is created additionally. In that class for each input that does not have type information available there will still be only the property with `_Untyped` suffix and nullability according to required status. For each diff --git a/jit-binding-server/src/main/kotlin/io/github/typesafegithub/workflows/jitbindingserver/ArtifactRoutes.kt b/jit-binding-server/src/main/kotlin/io/github/typesafegithub/workflows/jitbindingserver/ArtifactRoutes.kt index 014e073dda..c99a053f7e 100644 --- a/jit-binding-server/src/main/kotlin/io/github/typesafegithub/workflows/jitbindingserver/ArtifactRoutes.kt +++ b/jit-binding-server/src/main/kotlin/io/github/typesafegithub/workflows/jitbindingserver/ArtifactRoutes.kt @@ -11,8 +11,10 @@ import io.github.typesafegithub.workflows.mavenbinding.VersionArtifacts import io.github.typesafegithub.workflows.mavenbinding.buildVersionArtifacts import io.ktor.http.ContentType import io.ktor.http.HttpStatusCode +import io.ktor.http.content.asFlow import io.ktor.server.application.ApplicationCall import io.ktor.server.request.httpMethod +import io.ktor.server.request.receiveMultipart import io.ktor.server.request.receiveText import io.ktor.server.response.respondBytes import io.ktor.server.response.respondText @@ -28,11 +30,16 @@ import io.micrometer.prometheusmetrics.PrometheusMeterRegistry import it.krzeminski.snakeyaml.engine.kmp.api.Load import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.flow.map +import kotlinx.coroutines.flow.toList import kotlinx.coroutines.launch import java.util.Optional import java.util.UUID.randomUUID import kotlin.jvm.optionals.getOrNull +private const val METADATA_PARAMETER = "actionYaml" +private const val TYPES_PARAMETER = "types" + private val logger = logger { } typealias CachedVersionArtifact = Optional @@ -126,14 +133,45 @@ private fun Route.postArtifact( val owner = "${call.parameters["owner"]}__types__${randomUUID()}" val name = call.parameters["name"]!! val version = call.parameters["version"]!! - val types = call.receiveText() - runCatching { - Load().loadOne(types) - }.onFailure { - call.respondText( - text = "Exception while parsing supplied typings:\n${it.stackTraceToString()}", - status = HttpStatusCode.UnprocessableEntity, - ) + + val (metadata, types) = + runCatching { + val parts = + call + .receiveMultipart() + .asFlow() + .map { it.name to it.asString() } + .toList() + .map { (name, result) -> + name to + when { + result.isSuccess -> result.getOrThrow() + else -> { + call.respondText( + text = HttpStatusCode.InternalServerError.description, + status = HttpStatusCode.InternalServerError, + ) + return@post + } + } + }.associate { it } + + if (parts.keys.any { (it != METADATA_PARAMETER) && (it != TYPES_PARAMETER) }) { + call.respondBadRequest( + text = "Only '$METADATA_PARAMETER' and '$TYPES_PARAMETER' are allowed as form data fields", + ) + return@post + } + if (!parts.containsKey(TYPES_PARAMETER)) { + call.respondBadRequest(text = "'$TYPES_PARAMETER' field is mandatory") + return@post + } + parts[METADATA_PARAMETER] to parts[TYPES_PARAMETER]!! + }.recover { + null to call.receiveText() + }.getOrThrow() + + if (!call.validateMetadata(metadata) || !call.validateTypes(types)) { return@post } val typingActualSource = @@ -143,6 +181,7 @@ private fun Route.postArtifact( bindingsCache = bindingsCache, owner = owner, types = types, + metadata = metadata, )?.typingActualSource ?: TypingActualSource.CUSTOM call.respondText(text = "$owner:$name:$version") @@ -150,11 +189,49 @@ private fun Route.postArtifact( } } +private suspend fun ApplicationCall.validateTypes(types: String): Boolean { + runCatching { + Load().loadOne(types) + }.onFailure { + respondText( + text = "Exception while parsing supplied $TYPES_PARAMETER:\n${it.stackTraceToString()}", + status = HttpStatusCode.UnprocessableEntity, + ) + return false + } + return true +} + +private suspend fun ApplicationCall.validateMetadata(metadata: String?): Boolean { + var result = true + if (metadata != null) { + if (metadata.isEmpty()) { + respondText( + text = "Supplied $METADATA_PARAMETER is empty", + status = HttpStatusCode.UnprocessableEntity, + ) + result = false + } + + runCatching { + Load().loadOne(metadata) + }.onFailure { + respondText( + text = "Exception while parsing supplied $METADATA_PARAMETER:\n${it.stackTraceToString()}", + status = HttpStatusCode.UnprocessableEntity, + ) + result = false + } + } + return result +} + private suspend fun ApplicationCall.toBindingArtifacts( refresh: Boolean, bindingsCache: LoadingCache, owner: String = parameters["owner"]!!, types: String? = null, + metadata: String? = null, ): VersionArtifacts? { val parsedRequest = parameters.parseRequest(extractVersion = true, owner = owner) ?: return null @@ -164,7 +241,7 @@ private suspend fun ApplicationCall.toBindingArtifacts( } return ( if (types != null) { - bindingsCache.get(parsedRequest) { buildVersionArtifacts(parsedRequest, types) }.getOrNull() + bindingsCache.get(parsedRequest) { buildVersionArtifacts(parsedRequest, types, metadata) }.getOrNull() } else { bindingsCache.get(parsedRequest).getOrNull() } diff --git a/jit-binding-server/src/main/kotlin/io/github/typesafegithub/workflows/jitbindingserver/Main.kt b/jit-binding-server/src/main/kotlin/io/github/typesafegithub/workflows/jitbindingserver/Main.kt index ba3e9c66f7..e826e1f145 100644 --- a/jit-binding-server/src/main/kotlin/io/github/typesafegithub/workflows/jitbindingserver/Main.kt +++ b/jit-binding-server/src/main/kotlin/io/github/typesafegithub/workflows/jitbindingserver/Main.kt @@ -139,3 +139,5 @@ private fun buildMetadataCache( val deliverOnRefreshRoute = System.getenv("GWKT_DELIVER_ON_REFRESH").toBoolean() suspend fun ApplicationCall.respondNotFound() = respondText(text = "Not found", status = HttpStatusCode.NotFound) + +suspend fun ApplicationCall.respondBadRequest(text: String) = respondText(text, status = HttpStatusCode.BadRequest) diff --git a/jit-binding-server/src/main/kotlin/io/github/typesafegithub/workflows/jitbindingserver/PartData.kt b/jit-binding-server/src/main/kotlin/io/github/typesafegithub/workflows/jitbindingserver/PartData.kt new file mode 100644 index 0000000000..3bf310379a --- /dev/null +++ b/jit-binding-server/src/main/kotlin/io/github/typesafegithub/workflows/jitbindingserver/PartData.kt @@ -0,0 +1,20 @@ +package io.github.typesafegithub.workflows.jitbindingserver + +import io.github.oshai.kotlinlogging.KotlinLogging.logger +import io.ktor.http.content.PartData +import io.ktor.utils.io.readRemaining +import io.ktor.utils.io.readText + +private val logger = logger { } + +internal suspend fun PartData.asString() = + runCatching { + when (this) { + is PartData.FileItem -> provider().readRemaining().readText() + is PartData.FormItem -> value + else -> { + logger.error { "Unexpected part data ${this::class.simpleName}" } + error("Unexpected part data ${this::class.simpleName}") + } + } + } diff --git a/maven-binding-builder/src/main/kotlin/io/github/typesafegithub/workflows/mavenbinding/JarBuilding.kt b/maven-binding-builder/src/main/kotlin/io/github/typesafegithub/workflows/mavenbinding/JarBuilding.kt index dca0e6e8b0..3ed3e8e6e7 100644 --- a/maven-binding-builder/src/main/kotlin/io/github/typesafegithub/workflows/mavenbinding/JarBuilding.kt +++ b/maven-binding-builder/src/main/kotlin/io/github/typesafegithub/workflows/mavenbinding/JarBuilding.kt @@ -32,9 +32,13 @@ internal data class Jars( val typingActualSource: TypingActualSource?, ) -internal suspend fun ActionCoords.buildJars(types: String?, httpClient: HttpClient): Jars? { +internal suspend fun ActionCoords.buildJars( + types: String?, + metadata: String?, + httpClient: HttpClient +): Jars? { val binding = - generateBinding(metadataRevision = NewestForVersion, types = types, httpClient = httpClient).also { + generateBinding(metadataRevision = NewestForVersion, types = types, explicitMetadata = metadata, httpClient = httpClient).also { if (it.isEmpty()) return null } diff --git a/maven-binding-builder/src/main/kotlin/io/github/typesafegithub/workflows/mavenbinding/VersionArtifactsBuilding.kt b/maven-binding-builder/src/main/kotlin/io/github/typesafegithub/workflows/mavenbinding/VersionArtifactsBuilding.kt index 8859a021f4..bf860bb4ae 100644 --- a/maven-binding-builder/src/main/kotlin/io/github/typesafegithub/workflows/mavenbinding/VersionArtifactsBuilding.kt +++ b/maven-binding-builder/src/main/kotlin/io/github/typesafegithub/workflows/mavenbinding/VersionArtifactsBuilding.kt @@ -21,10 +21,11 @@ data class VersionArtifacts( suspend fun buildVersionArtifacts( bindingsServerRequest: BindingsServerRequest, types: String? = null, + metadata: String? = null, httpClient: HttpClient, ): VersionArtifacts? { with(bindingsServerRequest) { - val jars = actionCoords.buildJars(types = types, httpClient = httpClient) ?: return null + val jars = actionCoords.buildJars(types = types, metadata = metadata, httpClient = httpClient) ?: return null val pom = this.buildPomFile() val mainJarSize by lazy { jars.mainJar().size } val mainJarMd5Checksum by lazy { jars.mainJar().md5Checksum() } From d41a79c4e447802c0b27a6ffc32a9636bffb10b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Kautler?= Date: Wed, 22 Apr 2026 20:29:35 +0200 Subject: [PATCH 3/3] Adapt to upstream changes --- .../api/action-binding-generator.api | 35 +-- .../domain/ActionCoords.kt | 8 +- .../generation/Generation.kt | 9 +- .../typing/TypesProvidingTest.kt | 277 ++++++++++++------ .../jitbindingserver/ArtifactRoutes.kt | 21 +- .../workflows/jitbindingserver/Main.kt | 9 +- .../workflows/jitbindingserver/PartData.kt | 10 +- .../jitbindingserver/RequestParsing.kt | 35 ++- .../jitbindingserver/ArtifactRoutesTest.kt | 2 + .../jitbindingserver/RequestParsingTest.kt | 6 + .../workflows/mavenbinding/JarBuilding.kt | 9 +- .../mavenbinding/JavaBytecodeVersionTest.kt | 2 +- .../mavenbinding/MavenMetadataBuildingTest.kt | 1 + .../mavenbinding/ModuleBuildingTest.kt | 1 + .../workflows/mavenbinding/PomBuildingTest.kt | 1 + 15 files changed, 282 insertions(+), 144 deletions(-) diff --git a/action-binding-generator/api/action-binding-generator.api b/action-binding-generator/api/action-binding-generator.api index 88d48b76bb..056fdfb1e7 100644 --- a/action-binding-generator/api/action-binding-generator.api +++ b/action-binding-generator/api/action-binding-generator.api @@ -1,22 +1,16 @@ public final class io/github/typesafegithub/workflows/actionbindinggenerator/domain/ActionCoords { - public fun (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lio/github/typesafegithub/workflows/actionbindinggenerator/domain/SignificantVersion;Ljava/lang/String;)V - public synthetic fun (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lio/github/typesafegithub/workflows/actionbindinggenerator/domain/SignificantVersion;Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - public fun (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lio/github/typesafegithub/workflows/actionbindinggenerator/domain/SignificantVersion;Ljava/lang/String;Ljava/lang/String;)V - public synthetic fun (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lio/github/typesafegithub/workflows/actionbindinggenerator/domain/SignificantVersion;Ljava/lang/String;Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - public fun (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lio/github/typesafegithub/workflows/actionbindinggenerator/domain/SignificantVersion;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V - public synthetic fun (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lio/github/typesafegithub/workflows/actionbindinggenerator/domain/SignificantVersion;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public fun (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lio/github/typesafegithub/workflows/actionbindinggenerator/domain/SignificantVersion;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V + public synthetic fun (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lio/github/typesafegithub/workflows/actionbindinggenerator/domain/SignificantVersion;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V public final fun component1 ()Ljava/lang/String; public final fun component2 ()Ljava/lang/String; public final fun component3 ()Ljava/lang/String; public final fun component4 ()Lio/github/typesafegithub/workflows/actionbindinggenerator/domain/SignificantVersion; public final fun component5 ()Ljava/lang/String; public final fun component6 ()Ljava/lang/String; - public static synthetic fun copy$default (Lio/github/typesafegithub/workflows/actionbindinggenerator/domain/ActionCoords;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lio/github/typesafegithub/workflows/actionbindinggenerator/domain/SignificantVersion;Ljava/lang/String;ILjava/lang/Object;)Lio/github/typesafegithub/workflows/actionbindinggenerator/domain/ActionCoords; - public final fun copy (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lio/github/typesafegithub/workflows/actionbindinggenerator/domain/SignificantVersion;Ljava/lang/String;Ljava/lang/String;)Lio/github/typesafegithub/workflows/actionbindinggenerator/domain/ActionCoords; - public static synthetic fun copy$default (Lio/github/typesafegithub/workflows/actionbindinggenerator/domain/ActionCoords;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lio/github/typesafegithub/workflows/actionbindinggenerator/domain/SignificantVersion;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Lio/github/typesafegithub/workflows/actionbindinggenerator/domain/ActionCoords; public final fun component7 ()Ljava/lang/String; - public final fun copy (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lio/github/typesafegithub/workflows/actionbindinggenerator/domain/SignificantVersion;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Lio/github/typesafegithub/workflows/actionbindinggenerator/domain/ActionCoords; - public static synthetic fun copy$default (Lio/github/typesafegithub/workflows/actionbindinggenerator/domain/ActionCoords;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lio/github/typesafegithub/workflows/actionbindinggenerator/domain/SignificantVersion;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Lio/github/typesafegithub/workflows/actionbindinggenerator/domain/ActionCoords; + public final fun component8 ()Ljava/lang/String; + public final fun copy (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lio/github/typesafegithub/workflows/actionbindinggenerator/domain/SignificantVersion;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Lio/github/typesafegithub/workflows/actionbindinggenerator/domain/ActionCoords; + public static synthetic fun copy$default (Lio/github/typesafegithub/workflows/actionbindinggenerator/domain/ActionCoords;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lio/github/typesafegithub/workflows/actionbindinggenerator/domain/SignificantVersion;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Lio/github/typesafegithub/workflows/actionbindinggenerator/domain/ActionCoords; public fun equals (Ljava/lang/Object;)Z public final fun getComment ()Ljava/lang/String; public final fun getName ()Ljava/lang/String; @@ -116,16 +110,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/lang/String;)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;Ljava/lang/String;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;Lkotlin/Pair;Ljava/lang/String;Ljava/lang/String;)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;Ljava/lang/String;Ljava/lang/String;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;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;Lkotlin/Pair;Ljava/lang/String;)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;Ljava/lang/String;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;Lio/ktor/client/HttpClient;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - 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;Lio/ktor/client/HttpClient;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; + 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/lang/String;Ljava/lang/String;Lio/ktor/client/HttpClient;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + 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;Ljava/lang/String;Ljava/lang/String;Lio/ktor/client/HttpClient;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; } public final class io/github/typesafegithub/workflows/actionbindinggenerator/metadata/Input { @@ -198,11 +184,8 @@ public final class io/github/typesafegithub/workflows/actionbindinggenerator/met } public final class io/github/typesafegithub/workflows/actionbindinggenerator/metadata/MetadataReadingKt { - public static final fun fetchMetadata (Lio/github/typesafegithub/workflows/actionbindinggenerator/domain/ActionCoords;Lio/github/typesafegithub/workflows/actionbindinggenerator/domain/MetadataRevision;Lkotlin/jvm/functions/Function1;)Lio/github/typesafegithub/workflows/actionbindinggenerator/metadata/Metadata; - public static synthetic fun fetchMetadata$default (Lio/github/typesafegithub/workflows/actionbindinggenerator/domain/ActionCoords;Lio/github/typesafegithub/workflows/actionbindinggenerator/domain/MetadataRevision;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lio/github/typesafegithub/workflows/actionbindinggenerator/metadata/Metadata; - public static final fun fetchMetadata (Lio/github/typesafegithub/workflows/actionbindinggenerator/domain/ActionCoords;Lio/github/typesafegithub/workflows/actionbindinggenerator/domain/MetadataRevision;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lio/github/typesafegithub/workflows/actionbindinggenerator/metadata/Metadata; - public static synthetic fun fetchMetadata$default (Lio/github/typesafegithub/workflows/actionbindinggenerator/domain/ActionCoords;Lio/github/typesafegithub/workflows/actionbindinggenerator/domain/MetadataRevision;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lio/github/typesafegithub/workflows/actionbindinggenerator/metadata/Metadata; - public static final fun fetchMetadata (Lio/github/typesafegithub/workflows/actionbindinggenerator/domain/ActionCoords;Lio/github/typesafegithub/workflows/actionbindinggenerator/domain/MetadataRevision;Lio/ktor/client/HttpClient;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static final fun fetchMetadata (Lio/github/typesafegithub/workflows/actionbindinggenerator/domain/ActionCoords;Lio/github/typesafegithub/workflows/actionbindinggenerator/domain/MetadataRevision;Ljava/lang/String;Lio/ktor/client/HttpClient;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static synthetic fun fetchMetadata$default (Lio/github/typesafegithub/workflows/actionbindinggenerator/domain/ActionCoords;Lio/github/typesafegithub/workflows/actionbindinggenerator/domain/MetadataRevision;Ljava/lang/String;Lio/ktor/client/HttpClient;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; } public final class io/github/typesafegithub/workflows/actionbindinggenerator/metadata/Output { diff --git a/action-binding-generator/src/main/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/domain/ActionCoords.kt b/action-binding-generator/src/main/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/domain/ActionCoords.kt index 88255f124a..7dbdb6e32a 100644 --- a/action-binding-generator/src/main/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/domain/ActionCoords.kt +++ b/action-binding-generator/src/main/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/domain/ActionCoords.kt @@ -34,9 +34,13 @@ public data class ActionCoords( */ public val ActionCoords.isTopLevel: Boolean get() = path == null -public val ActionCoords.prettyPrint: String get() = "$prettyPrintBase@$version${typesUuid?.let { " (types: $it)" } ?: ""}" +public val ActionCoords.prettyPrint: String get() = "$prettyPrintBase@$version${typesUuid?.let { + " (types: $it)" +} ?: ""}" -public val ActionCoords.prettyPrintWithoutVersion: String get() = "$prettyPrintBase${typesUuid?.let { " (types: $it)" } ?: ""}" +public val ActionCoords.prettyPrintWithoutVersion: String get() = "$prettyPrintBase${typesUuid?.let { + " (types: $it)" +} ?: ""}" private val ActionCoords.prettyPrintBase: String get() = "$owner/$fullName${ significantVersion.takeUnless { it == FULL }?.let { " with $it version" } ?: "" diff --git a/action-binding-generator/src/main/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/generation/Generation.kt b/action-binding-generator/src/main/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/generation/Generation.kt index 622a8dc4d1..cca197ed9a 100644 --- a/action-binding-generator/src/main/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/generation/Generation.kt +++ b/action-binding-generator/src/main/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/generation/Generation.kt @@ -77,10 +77,15 @@ public suspend fun ActionCoords.generateBinding( httpClient: HttpClient = HttpClient(CIO), ): List { val metadataResolved = - metadata ?: this.fetchMetadata(metadataRevision, explicitMetadata, httpClient = httpClient) ?: return emptyList() + metadata ?: this.fetchMetadata( + metadataRevision = metadataRevision, + explicitMetadata = explicitMetadata, + httpClient = httpClient, + ) ?: return emptyList() val metadataProcessed = metadataResolved.removeDeprecatedInputsIfNameClash() - val inputTypingsResolved = inputTypings ?: this.provideTypes(metadataRevision, types = types, httpClient = httpClient) + val inputTypingsResolved = + inputTypings ?: this.provideTypes(metadataRevision, types = types, httpClient = httpClient) val packageName = owner.toKotlinPackageName() val className = this.buildActionClassName() diff --git a/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/typing/TypesProvidingTest.kt b/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/typing/TypesProvidingTest.kt index 7229fad889..39d6e954ab 100644 --- a/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/typing/TypesProvidingTest.kt +++ b/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/typing/TypesProvidingTest.kt @@ -28,7 +28,8 @@ class TypesProvidingTest : val types = actionCoord.provideTypes( metadataRevision = CommitHash("some-hash"), - mockClientReturning(actionTypesYml), + types = null, + httpClient = mockClientReturning(actionTypesYml), ) // Then @@ -44,7 +45,8 @@ class TypesProvidingTest : val types = actionCoord.provideTypes( metadataRevision = CommitHash("some-hash"), - mockClientReturning(actionTypesYml), + types = null, + httpClient = mockClientReturning(actionTypesYml), ) // Then @@ -60,7 +62,8 @@ class TypesProvidingTest : val types = actionCoord.provideTypes( metadataRevision = CommitHash("some-hash"), - mockClientReturning(actionTypesYml), + types = null, + httpClient = mockClientReturning(actionTypesYml), ) // Then @@ -76,7 +79,8 @@ class TypesProvidingTest : val types = actionCoord.provideTypes( metadataRevision = CommitHash("some-hash"), - mockClientReturning(actionTypesYml), + types = null, + httpClient = mockClientReturning(actionTypesYml), ) // Then @@ -96,7 +100,8 @@ class TypesProvidingTest : val types = actionCoord.provideTypes( metadataRevision = CommitHash("some-hash"), - mockClientReturning(actionTypesYml), + types = null, + httpClient = mockClientReturning(actionTypesYml), ) // Then @@ -146,7 +151,8 @@ class TypesProvidingTest : val types = actionCoord.provideTypes( metadataRevision = CommitHash("some-hash"), - mockClientReturning(actionTypesYml), + types = null, + httpClient = mockClientReturning(actionTypesYml), ) // Then @@ -572,130 +578,200 @@ class TypesProvidingTest : test("only custom") { // Given - val fetchUri: (URI) -> String = { throw IOException() } + val mockClient = + HttpClient(MockEngine { _ -> respond("Not found", status = HttpStatusCode.NotFound) }) val actionCoord = ActionCoords("some-owner", "some-name", "v3") // When - val types = actionCoord.provideTypes(metadataRevision = CommitHash("some-hash"), fetchUri = fetchUri, types = custom) + val types = + actionCoord.provideTypes( + metadataRevision = CommitHash("some-hash"), + types = custom, + httpClient = mockClient, + ) // Then - types shouldBe Pair(mapOf("custom" to StringTyping), TypingActualSource.CUSTOM) + types shouldBe + ActionTypings( + inputTypings = mapOf("custom" to StringTyping), + source = TypingActualSource.CUSTOM, + fromFallbackVersion = false, + ) } test("only custom for subaction") { // Given - val fetchUri: (URI) -> String = { throw IOException() } + val mockClient = + HttpClient(MockEngine { _ -> respond("Not found", status = HttpStatusCode.NotFound) }) val actionCoord = ActionCoords("some-owner", "some-name", "v3", FULL, "some-sub") // When - val types = actionCoord.provideTypes(metadataRevision = CommitHash("some-hash"), fetchUri = fetchUri, types = custom) + val types = + actionCoord.provideTypes( + metadataRevision = CommitHash("some-hash"), + types = custom, + httpClient = mockClient, + ) // Then - types shouldBe Pair(mapOf("custom" to StringTyping), TypingActualSource.CUSTOM) + types shouldBe + ActionTypings( + inputTypings = mapOf("custom" to StringTyping), + source = TypingActualSource.CUSTOM, + fromFallbackVersion = false, + ) } test("hosted by action, stored in typing catalog, and custom") { // Given - val fetchUri: (URI) -> String = { - when (it) { - URI( - "https://raw.githubusercontent.com/some-owner/some-name/" + - "some-hash/action-types.yml", - ), - -> hostedByActionYml - URI( - "https://raw.githubusercontent.com/typesafegithub/github-actions-typing-catalog/" + - "main/typings/some-owner/some-name/v3/action-types.yml", - ), - -> storedInTypingCatalog - else -> throw IOException() - } - } + val mockClient = + HttpClient( + MockEngine { request -> + if (request.url.toString() == "https://raw.githubusercontent.com/some-owner/some-name/" + + "some-hash/action-types.yml" + ) { + respond(hostedByActionYml) + } else if (request.url.toString() == + "https://raw.githubusercontent.com/typesafegithub/github-actions-typing-catalog/" + + "main/typings/some-owner/some-name/v3/action-types.yml" + ) { + respond(storedInTypingCatalog) + } else { + respond("Not found", status = HttpStatusCode.NotFound) + } + }, + ) val actionCoord = ActionCoords("some-owner", "some-name", "v3") // When - val types = actionCoord.provideTypes(metadataRevision = CommitHash("some-hash"), fetchUri = fetchUri, types = custom) + val types = + actionCoord.provideTypes( + metadataRevision = CommitHash("some-hash"), + types = custom, + httpClient = mockClient, + ) // Then - types shouldBe Pair(mapOf("custom" to StringTyping), TypingActualSource.CUSTOM) + types shouldBe + ActionTypings( + inputTypings = mapOf("custom" to StringTyping), + source = TypingActualSource.CUSTOM, + fromFallbackVersion = false, + ) } test("hosted by subaction, stored in typing catalog, and custom") { // Given - val fetchUri: (URI) -> String = { - when (it) { - URI( - "https://raw.githubusercontent.com/some-owner/some-name/" + - "some-hash/some-sub/action-types.yml", - ), - -> hostedByActionYml - URI( - "https://raw.githubusercontent.com/typesafegithub/github-actions-typing-catalog/" + - "main/typings/some-owner/some-name/v3/some-sub/action-types.yml", - ), - -> storedInTypingCatalog - else -> throw IOException() - } - } + val mockClient = + HttpClient( + MockEngine { request -> + if (request.url.toString() == "https://raw.githubusercontent.com/some-owner/some-name/" + + "some-hash/some-sub/action-types.yml" + ) { + respond(hostedByActionYml) + } else if (request.url.toString() == + "https://raw.githubusercontent.com/typesafegithub/github-actions-typing-catalog/" + + "main/typings/some-owner/some-name/v3/some-sub/action-types.yml" + ) { + respond(storedInTypingCatalog) + } else { + respond("Not found", status = HttpStatusCode.NotFound) + } + }, + ) val actionCoord = ActionCoords("some-owner", "some-name", "v3", FULL, "some-sub") // When - val types = actionCoord.provideTypes(metadataRevision = CommitHash("some-hash"), fetchUri = fetchUri, types = custom) + val types = + actionCoord.provideTypes( + metadataRevision = CommitHash("some-hash"), + types = custom, + httpClient = mockClient, + ) // Then - types shouldBe Pair(mapOf("custom" to StringTyping), TypingActualSource.CUSTOM) + types shouldBe + ActionTypings( + inputTypings = mapOf("custom" to StringTyping), + source = TypingActualSource.CUSTOM, + fromFallbackVersion = false, + ) } test("hosted by action, stored in typing catalog, and empty custom") { // Given - val fetchUri: (URI) -> String = { - when (it) { - URI( - "https://raw.githubusercontent.com/some-owner/some-name/" + - "some-hash/action-types.yml", - ), - -> hostedByActionYml - URI( - "https://raw.githubusercontent.com/typesafegithub/github-actions-typing-catalog/" + - "main/typings/some-owner/some-name/v3/action-types.yml", - ), - -> storedInTypingCatalog - else -> throw IOException() - } - } + val mockClient = + HttpClient( + MockEngine { request -> + if (request.url.toString() == "https://raw.githubusercontent.com/some-owner/some-name/" + + "some-hash/action-types.yml" + ) { + respond(hostedByActionYml) + } else if (request.url.toString() == + "https://raw.githubusercontent.com/typesafegithub/github-actions-typing-catalog/" + + "main/typings/some-owner/some-name/v3/action-types.yml" + ) { + respond(storedInTypingCatalog) + } else { + respond("Not found", status = HttpStatusCode.NotFound) + } + }, + ) val actionCoord = ActionCoords("some-owner", "some-name", "v3") // When - val types = actionCoord.provideTypes(metadataRevision = CommitHash("some-hash"), fetchUri = fetchUri, types = "") + val types = + actionCoord.provideTypes( + metadataRevision = CommitHash("some-hash"), + types = "", + httpClient = mockClient, + ) // Then - types shouldBe Pair(emptyMap(), TypingActualSource.CUSTOM) + types shouldBe + ActionTypings( + inputTypings = emptyMap(), + source = TypingActualSource.CUSTOM, + fromFallbackVersion = false, + ) } test("hosted by subaction, stored in typing catalog, and empty custom") { // Given - val fetchUri: (URI) -> String = { - when (it) { - URI( - "https://raw.githubusercontent.com/some-owner/some-name/" + - "some-hash/some-sub/action-types.yml", - ), - -> hostedByActionYml - URI( - "https://raw.githubusercontent.com/typesafegithub/github-actions-typing-catalog/" + - "main/typings/some-owner/some-name/v3/some-sub/action-types.yml", - ), - -> storedInTypingCatalog - else -> throw IOException() - } - } + val mockClient = + HttpClient( + MockEngine { request -> + if (request.url.toString() == "https://raw.githubusercontent.com/some-owner/some-name/" + + "some-hash/some-sub/action-types.yml" + ) { + respond(hostedByActionYml) + } else if (request.url.toString() == + "https://raw.githubusercontent.com/typesafegithub/github-actions-typing-catalog/" + + "main/typings/some-owner/some-name/v3/some-sub/action-types.yml" + ) { + respond(storedInTypingCatalog) + } else { + respond("Not found", status = HttpStatusCode.NotFound) + } + }, + ) val actionCoord = ActionCoords("some-owner", "some-name", "v3", FULL, "some-sub") // When - val types = actionCoord.provideTypes(metadataRevision = CommitHash("some-hash"), fetchUri = fetchUri, types = "") + val types = + actionCoord.provideTypes( + metadataRevision = CommitHash("some-hash"), + types = "", + httpClient = mockClient, + ) // Then - types shouldBe Pair(emptyMap(), TypingActualSource.CUSTOM) + types shouldBe + ActionTypings( + inputTypings = emptyMap(), + source = TypingActualSource.CUSTOM, + fromFallbackVersion = false, + ) } test("only stored in typing catalog for older version") { @@ -1261,21 +1337,41 @@ class TypesProvidingTest : test("only custom") { // Given - val fetchUri: (URI) -> String = { throw IOException() } + val mockClient = + HttpClient(MockEngine { _ -> respond("Not found", status = HttpStatusCode.NotFound) }) val actionCoord = ActionCoords("some-owner", "some-name", "v3") // When - val types = actionCoord.provideTypes(metadataRevision = CommitHash("some-hash"), fetchUri = fetchUri, types = typingYml) + val types = + actionCoord.provideTypes( + metadataRevision = CommitHash("some-hash"), + types = typingYml, + httpClient = mockClient, + ) // Then types shouldBe - Pair( - mapOf( - "granted-scopes" to ListOfTypings(",", EnumTyping("GrantedScopes", listOf("read", "write"))), - "granted-scopes2" to ListOfTypings(",", EnumTyping("GrantedScopes", listOf("read", "write"))), - "granted-scopes3" to ListOfTypings("""\n""", EnumTyping("GrantedScopes", listOf("read", "write"))), - ), - TypingActualSource.CUSTOM, + ActionTypings( + inputTypings = + mapOf( + "granted-scopes" to + ListOfTypings( + ",", + EnumTyping("GrantedScopes", listOf("read", "write")), + ), + "granted-scopes2" to + ListOfTypings( + ",", + EnumTyping("GrantedScopes", listOf("read", "write")), + ), + "granted-scopes3" to + ListOfTypings( + """\n""", + EnumTyping("GrantedScopes", listOf("read", "write")), + ), + ), + source = TypingActualSource.CUSTOM, + fromFallbackVersion = false, ) } @@ -1332,7 +1428,8 @@ class TypesProvidingTest : val actionCoord = ActionCoords("some-owner", "some-name", "v6-beta") // When - val types = actionCoord.provideTypes(metadataRevision = CommitHash("some-hash"), httpClient = mockClient) + val types = + actionCoord.provideTypes(metadataRevision = CommitHash("some-hash"), httpClient = mockClient) // Then types shouldBe ActionTypings(inputTypings = emptyMap(), source = null) diff --git a/jit-binding-server/src/main/kotlin/io/github/typesafegithub/workflows/jitbindingserver/ArtifactRoutes.kt b/jit-binding-server/src/main/kotlin/io/github/typesafegithub/workflows/jitbindingserver/ArtifactRoutes.kt index c99a053f7e..c741e7ae26 100644 --- a/jit-binding-server/src/main/kotlin/io/github/typesafegithub/workflows/jitbindingserver/ArtifactRoutes.kt +++ b/jit-binding-server/src/main/kotlin/io/github/typesafegithub/workflows/jitbindingserver/ArtifactRoutes.kt @@ -9,6 +9,8 @@ import io.github.typesafegithub.workflows.mavenbinding.JarArtifact import io.github.typesafegithub.workflows.mavenbinding.TextArtifact import io.github.typesafegithub.workflows.mavenbinding.VersionArtifacts import io.github.typesafegithub.workflows.mavenbinding.buildVersionArtifacts +import io.ktor.client.HttpClient +import io.ktor.client.engine.cio.CIO import io.ktor.http.ContentType import io.ktor.http.HttpStatusCode import io.ktor.http.content.asFlow @@ -126,7 +128,7 @@ internal fun prefetchBindingArtifacts( } private fun Route.postArtifact( - bindingsCache: LoadingCache, + bindingsCache: LoadingCache, prometheusRegistry: PrometheusMeterRegistry?, ) { post { @@ -145,7 +147,10 @@ private fun Route.postArtifact( .map { (name, result) -> name to when { - result.isSuccess -> result.getOrThrow() + result.isSuccess -> { + result.getOrThrow() + } + else -> { call.respondText( text = HttpStatusCode.InternalServerError.description, @@ -241,7 +246,17 @@ private suspend fun ApplicationCall.toBindingArtifacts( } return ( if (types != null) { - bindingsCache.get(parsedRequest) { buildVersionArtifacts(parsedRequest, types, metadata) }.getOrNull() + bindingsCache + .get(parsedRequest) { + Optional.ofNullable( + buildVersionArtifacts( + parsedRequest, + types, + metadata, + HttpClient(CIO), + ), + ) + }.getOrNull() } else { bindingsCache.get(parsedRequest).getOrNull() } diff --git a/jit-binding-server/src/main/kotlin/io/github/typesafegithub/workflows/jitbindingserver/Main.kt b/jit-binding-server/src/main/kotlin/io/github/typesafegithub/workflows/jitbindingserver/Main.kt index e826e1f145..e740396388 100644 --- a/jit-binding-server/src/main/kotlin/io/github/typesafegithub/workflows/jitbindingserver/Main.kt +++ b/jit-binding-server/src/main/kotlin/io/github/typesafegithub/workflows/jitbindingserver/Main.kt @@ -59,7 +59,14 @@ fun main() { } embeddedServer(Netty, port = 8080) { appModule( - buildVersionArtifacts = { buildVersionArtifacts(it, it.typesUuid?.let { "" }) }, + buildVersionArtifacts = { bindingsServerRequest, httpClient -> + buildVersionArtifacts( + bindingsServerRequest, + bindingsServerRequest.actionCoords.typesUuid?.let { "" }, + null, + httpClient, + ) + }, buildPackageArtifacts = ::buildPackageArtifacts, getGithubAuthToken = ::getGithubAuthToken, ) diff --git a/jit-binding-server/src/main/kotlin/io/github/typesafegithub/workflows/jitbindingserver/PartData.kt b/jit-binding-server/src/main/kotlin/io/github/typesafegithub/workflows/jitbindingserver/PartData.kt index 3bf310379a..4c2299b687 100644 --- a/jit-binding-server/src/main/kotlin/io/github/typesafegithub/workflows/jitbindingserver/PartData.kt +++ b/jit-binding-server/src/main/kotlin/io/github/typesafegithub/workflows/jitbindingserver/PartData.kt @@ -10,8 +10,14 @@ private val logger = logger { } internal suspend fun PartData.asString() = runCatching { when (this) { - is PartData.FileItem -> provider().readRemaining().readText() - is PartData.FormItem -> value + is PartData.FileItem -> { + provider().readRemaining().readText() + } + + is PartData.FormItem -> { + value + } + else -> { logger.error { "Unexpected part data ${this::class.simpleName}" } error("Unexpected part data ${this::class.simpleName}") diff --git a/jit-binding-server/src/main/kotlin/io/github/typesafegithub/workflows/jitbindingserver/RequestParsing.kt b/jit-binding-server/src/main/kotlin/io/github/typesafegithub/workflows/jitbindingserver/RequestParsing.kt index 85591afc64..49186c037a 100644 --- a/jit-binding-server/src/main/kotlin/io/github/typesafegithub/workflows/jitbindingserver/RequestParsing.kt +++ b/jit-binding-server/src/main/kotlin/io/github/typesafegithub/workflows/jitbindingserver/RequestParsing.kt @@ -33,21 +33,7 @@ fun Parameters.parseRequest( .drop(1) .joinToString("/") .takeUnless { it.isBlank() } - val version = - if (extractVersion) { - val versionPart = this["version"]!! - if (significantVersion == COMMIT_LENIENT) { - val versionParts = versionPart.split("__") - if (versionParts.size < 2) { - return null - } - versionParts[1] - } else { - versionPart - } - } else { - "irrelevant" - } + val version = determineVersion(extractVersion, significantVersion) ?: return null val comment = if ((significantVersion == COMMIT_LENIENT) && extractVersion) this["version"]!!.split("__")[0] else null val versionForTypings = if (extractVersion) this["version"]!!.split("__")[0] else "irrelevant" @@ -79,3 +65,22 @@ fun Parameters.parseRequest( ), ) } + +fun Parameters.determineVersion( + extractVersion: Boolean, + significantVersion: SignificantVersion, +): String? = + if (extractVersion) { + val versionPart = this["version"]!! + if (significantVersion == COMMIT_LENIENT) { + val versionParts = versionPart.split("__") + if (versionParts.size < 2) { + return null + } + versionParts[1] + } else { + versionPart + } + } else { + "irrelevant" + } diff --git a/jit-binding-server/src/test/kotlin/io/github/typesafegithub/workflows/jitbindingserver/ArtifactRoutesTest.kt b/jit-binding-server/src/test/kotlin/io/github/typesafegithub/workflows/jitbindingserver/ArtifactRoutesTest.kt index 9827791493..3364647b6d 100644 --- a/jit-binding-server/src/test/kotlin/io/github/typesafegithub/workflows/jitbindingserver/ArtifactRoutesTest.kt +++ b/jit-binding-server/src/test/kotlin/io/github/typesafegithub/workflows/jitbindingserver/ArtifactRoutesTest.kt @@ -158,6 +158,8 @@ class ArtifactRoutesTest : buildVersionArtifacts = { bindingsServerRequest, _ -> buildVersionArtifacts( bindingsServerRequest, + null, + null, HttpClient( MockEngine { request -> when (request.url.toString()) { diff --git a/jit-binding-server/src/test/kotlin/io/github/typesafegithub/workflows/jitbindingserver/RequestParsingTest.kt b/jit-binding-server/src/test/kotlin/io/github/typesafegithub/workflows/jitbindingserver/RequestParsingTest.kt index 8c7ec1b67a..2d328205cb 100644 --- a/jit-binding-server/src/test/kotlin/io/github/typesafegithub/workflows/jitbindingserver/RequestParsingTest.kt +++ b/jit-binding-server/src/test/kotlin/io/github/typesafegithub/workflows/jitbindingserver/RequestParsingTest.kt @@ -21,6 +21,7 @@ class RequestParsingTest : parameters.parseRequest(extractVersion = true) shouldBe BindingsServerRequest( + rawOwner = "o", rawName = "act", rawVersion = "v1", actionCoords = @@ -39,6 +40,7 @@ class RequestParsingTest : parameters.parseRequest(extractVersion = true) shouldBe BindingsServerRequest( + rawOwner = "o", rawName = "act__p1__p2___major", rawVersion = "v9", actionCoords = @@ -57,6 +59,7 @@ class RequestParsingTest : parameters.parseRequest(extractVersion = false) shouldBe BindingsServerRequest( + rawOwner = "o", rawName = "act___minor", rawVersion = null, actionCoords = @@ -75,6 +78,7 @@ class RequestParsingTest : parameters.parseRequest(extractVersion = false) shouldBe BindingsServerRequest( + rawOwner = "o", rawName = "act___weird", rawVersion = null, actionCoords = @@ -94,6 +98,7 @@ class RequestParsingTest : parameters.parseRequest(extractVersion = true) shouldBe BindingsServerRequest( + rawOwner = "o", rawName = "my_action-name__dir_one__dir-two___minor", rawVersion = "v2", actionCoords = @@ -117,6 +122,7 @@ class RequestParsingTest : parameters.parseRequest(extractVersion = true) shouldBe BindingsServerRequest( + rawOwner = "o", rawName = "act___commit_lenient", rawVersion = "v1.2.3__323898970401d85df44b3324a610af9a862d54b3", actionCoords = diff --git a/maven-binding-builder/src/main/kotlin/io/github/typesafegithub/workflows/mavenbinding/JarBuilding.kt b/maven-binding-builder/src/main/kotlin/io/github/typesafegithub/workflows/mavenbinding/JarBuilding.kt index 3ed3e8e6e7..785ea8b8a6 100644 --- a/maven-binding-builder/src/main/kotlin/io/github/typesafegithub/workflows/mavenbinding/JarBuilding.kt +++ b/maven-binding-builder/src/main/kotlin/io/github/typesafegithub/workflows/mavenbinding/JarBuilding.kt @@ -35,10 +35,15 @@ internal data class Jars( internal suspend fun ActionCoords.buildJars( types: String?, metadata: String?, - httpClient: HttpClient + httpClient: HttpClient, ): Jars? { val binding = - generateBinding(metadataRevision = NewestForVersion, types = types, explicitMetadata = metadata, httpClient = httpClient).also { + generateBinding( + metadataRevision = NewestForVersion, + types = types, + explicitMetadata = metadata, + httpClient = httpClient, + ).also { if (it.isEmpty()) return null } diff --git a/maven-binding-builder/src/test/kotlin/io/github/typesafegithub/workflows/mavenbinding/JavaBytecodeVersionTest.kt b/maven-binding-builder/src/test/kotlin/io/github/typesafegithub/workflows/mavenbinding/JavaBytecodeVersionTest.kt index 5eed370351..4eca07d11a 100644 --- a/maven-binding-builder/src/test/kotlin/io/github/typesafegithub/workflows/mavenbinding/JavaBytecodeVersionTest.kt +++ b/maven-binding-builder/src/test/kotlin/io/github/typesafegithub/workflows/mavenbinding/JavaBytecodeVersionTest.kt @@ -12,7 +12,7 @@ class JavaBytecodeVersionTest : { test("bindings are built with desired Java bytecode version") { val actionCoords = ActionCoords("actions", "setup-java", "v3") - val jars = actionCoords.buildJars(httpClient = HttpClient(CIO))!! + val jars = actionCoords.buildJars(types = null, metadata = null, httpClient = HttpClient(CIO))!! jars.randomClassFile() shouldHaveBytecodeVersion JDK_8 } }, diff --git a/maven-binding-builder/src/test/kotlin/io/github/typesafegithub/workflows/mavenbinding/MavenMetadataBuildingTest.kt b/maven-binding-builder/src/test/kotlin/io/github/typesafegithub/workflows/mavenbinding/MavenMetadataBuildingTest.kt index 4fbdd6e71f..e12a361836 100644 --- a/maven-binding-builder/src/test/kotlin/io/github/typesafegithub/workflows/mavenbinding/MavenMetadataBuildingTest.kt +++ b/maven-binding-builder/src/test/kotlin/io/github/typesafegithub/workflows/mavenbinding/MavenMetadataBuildingTest.kt @@ -20,6 +20,7 @@ class MavenMetadataBuildingTest : FunSpec({ val bindingsServerRequest = BindingsServerRequest( + rawOwner = "owner", rawName = "name", rawVersion = null, actionCoords = diff --git a/maven-binding-builder/src/test/kotlin/io/github/typesafegithub/workflows/mavenbinding/ModuleBuildingTest.kt b/maven-binding-builder/src/test/kotlin/io/github/typesafegithub/workflows/mavenbinding/ModuleBuildingTest.kt index 8c53af52e5..8f0e862d63 100644 --- a/maven-binding-builder/src/test/kotlin/io/github/typesafegithub/workflows/mavenbinding/ModuleBuildingTest.kt +++ b/maven-binding-builder/src/test/kotlin/io/github/typesafegithub/workflows/mavenbinding/ModuleBuildingTest.kt @@ -18,6 +18,7 @@ class ModuleBuildingTest : val bindingsServerRequest = BindingsServerRequest( + rawOwner = "owner", rawName = "name$nameSuffix", rawVersion = "v1.2.3$versionSuffix", actionCoords = diff --git a/maven-binding-builder/src/test/kotlin/io/github/typesafegithub/workflows/mavenbinding/PomBuildingTest.kt b/maven-binding-builder/src/test/kotlin/io/github/typesafegithub/workflows/mavenbinding/PomBuildingTest.kt index 2a16652abb..fd4d4ea60e 100644 --- a/maven-binding-builder/src/test/kotlin/io/github/typesafegithub/workflows/mavenbinding/PomBuildingTest.kt +++ b/maven-binding-builder/src/test/kotlin/io/github/typesafegithub/workflows/mavenbinding/PomBuildingTest.kt @@ -25,6 +25,7 @@ class PomBuildingTest : val bindingsServerRequest = BindingsServerRequest( + rawOwner = "owner", rawName = "name$nameSuffix", rawVersion = "v1.2.3$versionSuffix", actionCoords =