Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
148 changes: 74 additions & 74 deletions github-workflows-kt/api/github-workflows-kt.api

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import kotlinx.serialization.Serializable

@Serializable
public data class PullRequest(
val types: List<Type> = emptyList(),
val types: List<EventType> = emptyList(),
val branches: List<String>? = null,
val branchesIgnore: List<String>? = null,
val paths: List<String>? = null,
Expand All @@ -24,14 +24,14 @@ public data class PullRequest(
}

@InternalSerializationApi
internal class Serializer : CaseEnumSerializer<Type>(Type::class.qualifiedName!!, Type.values())
internal class Serializer : CaseEnumSerializer<EventType>(EventType::class.qualifiedName!!, EventType.values())

/**
* https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request
*/
@OptIn(InternalSerializationApi::class)
@Serializable(with = Serializer::class)
public enum class Type {
public enum class EventType {
Assigned,
Unassigned,
Labeled,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import kotlinx.serialization.Serializable
// https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_target
@Serializable
public data class PullRequestTarget(
val types: List<Type> = emptyList(),
val types: List<EventType> = emptyList(),
val branches: List<String>? = null,
val branchesIgnore: List<String>? = null,
val paths: List<String>? = null,
Expand All @@ -25,11 +25,11 @@ public data class PullRequestTarget(
}

@InternalSerializationApi
internal class Serializer : CaseEnumSerializer<Type>(Type::class.qualifiedName!!, Type.values())
internal class Serializer : CaseEnumSerializer<EventType>(EventType::class.qualifiedName!!, EventType.values())

@OptIn(InternalSerializationApi::class)
@Serializable(with = Serializer::class)
public enum class Type {
public enum class EventType {
Assigned,
Unassigned,
Labeled,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,25 @@ public data class WorkflowCall(
val secrets: Map<String, Secret>? = null,
override val _customArguments: Map<String, @Contextual Any> = mapOf(),
) : Trigger() {
@Serializable
public enum class Type {
@SerialName("boolean")
Boolean,

@SerialName("number")
Number,

@SerialName("string")
String,
}

@Serializable
public class Input(
public val description: String,
public val required: Boolean,
public val type: Type,
public val default: String? = null,
)
) {
@Serializable
public enum class Type {
@SerialName("boolean")
Boolean,

@SerialName("number")
Number,

@SerialName("string")
String,
}
}

@Serializable
public class Output(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,30 @@ public data class WorkflowDispatch(
val inputs: Map<String, Input> = emptyMap(),
override val _customArguments: Map<String, @Contextual Any> = mapOf(),
) : Trigger() {
@Serializable
public enum class Type {
@SerialName("choice")
Choice,

@SerialName("environment")
Environment,

@SerialName("boolean")
Boolean,

@SerialName("number")
Number,

@SerialName("string")
String,
}

@Serializable
public class Input(
public val description: String,
public val required: Boolean,
public val type: Type,
public val options: List<String> = emptyList(),
public val default: String? = null,
)
) {
@Serializable
public enum class Type {
@SerialName("choice")
Choice,

@SerialName("environment")
Environment,

@SerialName("boolean")
Boolean,

@SerialName("number")
Number,

@SerialName("string")
String,
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.github.typesafegithub.workflows.yaml

import io.github.typesafegithub.workflows.domain.triggers.PullRequest
import io.github.typesafegithub.workflows.domain.triggers.PullRequest.Type
import io.github.typesafegithub.workflows.domain.triggers.PullRequest.EventType
import io.github.typesafegithub.workflows.domain.triggers.PullRequestTarget
import io.kotest.assertions.throwables.shouldThrowAny
import io.kotest.core.spec.style.DescribeSpec
Expand All @@ -12,9 +12,9 @@ class CaseTest :
DescribeSpec({
it("transforms to pascal case") {
listOf(
Type.Assigned to "assigned",
Type.AutoMergeDisabled to "auto_merge_disabled",
Type.ReviewRequested to "review_requested",
EventType.Assigned to "assigned",
EventType.AutoMergeDisabled to "auto_merge_disabled",
EventType.ReviewRequested to "review_requested",
).forAll { (type, expected) ->
type.toSnakeCase() shouldBe expected
}
Expand All @@ -29,8 +29,8 @@ class CaseTest :
}

it("all enums should be in pascal case") {
PullRequestTarget.Type.values().forAll { it.toSnakeCase() }
PullRequest.Type.values().forAll { it.toSnakeCase() }
PullRequestTarget.EventType.values().forAll { it.toSnakeCase() }
PullRequest.EventType.values().forAll { it.toSnakeCase() }
}
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,33 +57,33 @@ class TriggersToYamlTest :
"logLevel" to
WorkflowDispatch.Input(
description = "Log level",
type = WorkflowDispatch.Type.Choice,
type = WorkflowDispatch.Input.Type.Choice,
required = true,
default = "warning",
options = listOf("info", "warning", "debug"),
),
"tags" to
WorkflowDispatch.Input(
description = "Test scenario tags",
type = WorkflowDispatch.Type.Boolean,
type = WorkflowDispatch.Input.Type.Boolean,
required = false,
),
"retries" to
WorkflowDispatch.Input(
description = "Number of retries",
type = WorkflowDispatch.Type.Number,
type = WorkflowDispatch.Input.Type.Number,
required = false,
),
"environment" to
WorkflowDispatch.Input(
description = "Environment to run tests against",
type = WorkflowDispatch.Type.Environment,
type = WorkflowDispatch.Input.Type.Environment,
required = true,
),
"greeting" to
WorkflowDispatch.Input(
description = "Hello {greeting}",
type = WorkflowDispatch.Type.String,
type = WorkflowDispatch.Input.Type.String,
required = true,
),
),
Expand Down Expand Up @@ -163,7 +163,7 @@ class TriggersToYamlTest :
"tags" to
WorkflowCall.Input(
description = "Test scenario tags",
type = WorkflowCall.Type.Boolean,
type = WorkflowCall.Input.Type.Boolean,
required = false,
),
),
Expand Down Expand Up @@ -201,19 +201,19 @@ class TriggersToYamlTest :
"tags" to
WorkflowCall.Input(
description = "Test scenario tags",
type = WorkflowCall.Type.Boolean,
type = WorkflowCall.Input.Type.Boolean,
required = false,
),
"retries" to
WorkflowCall.Input(
description = "How many retries",
type = WorkflowCall.Type.Number,
type = WorkflowCall.Input.Type.Number,
required = false,
),
"greeting" to
WorkflowCall.Input(
description = "Hello {greeting}",
type = WorkflowCall.Type.String,
type = WorkflowCall.Input.Type.String,
required = true,
),
),
Expand Down Expand Up @@ -375,7 +375,7 @@ class TriggersToYamlTest :
PullRequest(
branches = listOf("branch1", "branch2"),
paths = listOf("path1", "path2"),
types = listOf(PullRequest.Type.AutoMergeDisabled, PullRequest.Type.Opened),
types = listOf(PullRequest.EventType.AutoMergeDisabled, PullRequest.EventType.Opened),
),
)

Expand Down Expand Up @@ -439,7 +439,7 @@ class TriggersToYamlTest :
val triggers =
listOf(
PullRequestTarget(
types = listOf(PullRequestTarget.Type.Assigned, PullRequestTarget.Type.Closed),
types = listOf(PullRequestTarget.EventType.Assigned, PullRequestTarget.EventType.Closed),
branches = listOf("branch1", "branch2"),
paths = listOf("path1", "path2"),
),
Expand All @@ -465,7 +465,7 @@ class TriggersToYamlTest :
val triggers =
listOf(
PullRequestTarget(
types = listOf(PullRequestTarget.Type.Assigned, PullRequestTarget.Type.Closed),
types = listOf(PullRequestTarget.EventType.Assigned, PullRequestTarget.EventType.Closed),
branchesIgnore = listOf("branchIgnore1", "branchIgnore2"),
pathsIgnore = listOf("pathIgnore1", "pathIgnore2"),
),
Expand Down
Loading