Skip to content

Commit 0e1e17b

Browse files
committed
[#11] Remove typingSpec
It doesn't bring much value. In the v0 phase when there might be occassional breaking changes, it's cheaper to communicate them well rather than make the clients maintain this version. With further major versions, a `version` attribute can be introduced incrementally.
1 parent 93f1bad commit 0e1e17b

File tree

4 files changed

+0
-73
lines changed

4 files changed

+0
-73
lines changed

src/main/kotlin/it/krzeminski/githubactionstyping/parsing/TypesManifestParsing.kt

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import kotlinx.serialization.decodeFromString
66

77
@Serializable
88
data class TypesManifest(
9-
val typingSpec: String? = null,
109
val inputs: Map<String, ApiItem> = emptyMap(),
1110
val outputs: Map<String, ApiItem> = emptyMap(),
1211
)

src/main/kotlin/it/krzeminski/githubactionstyping/validation/ManifestValidation.kt

-10
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,7 @@ import it.krzeminski.githubactionstyping.validation.types.validateInteger
99
import it.krzeminski.githubactionstyping.validation.types.validateList
1010
import it.krzeminski.githubactionstyping.validation.types.validateString
1111

12-
const val expectedTypingSpec = "krzema12/[email protected]"
13-
1412
fun TypesManifest.validate(): ActionValidationResult {
15-
if (this.typingSpec == null || this.typingSpec != expectedTypingSpec) {
16-
return ActionValidationResult(
17-
overallResult = ItemValidationResult.Invalid(
18-
"Set top-level 'typingSpec' attribute to '$expectedTypingSpec', was: ${typingSpec?.let { "'$it'" }}"
19-
)
20-
)
21-
}
22-
2313
val inputValidationResults = this.inputs.mapValues { (_, value) -> value.validate() }
2414
val outputValidationResults = this.outputs.mapValues { (_, value) -> value.validate() }
2515
val isSomethingInvalid = (inputValidationResults.values + outputValidationResults.values)

src/test/kotlin/it/krzeminski/githubactionstyping/validation/ManifestValidationTest.kt

-60
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ class ManifestValidationTest : FunSpec({
1010
test("primitive types") {
1111
// given
1212
val manifest = TypesManifest(
13-
typingSpec = expectedTypingSpec,
1413
inputs = mapOf(
1514
"string-input" to ApiItem(type = "string"),
1615
"boolean-input" to ApiItem(type = "boolean"),
@@ -39,7 +38,6 @@ class ManifestValidationTest : FunSpec({
3938
test("enum type") {
4039
// given
4140
val manifest = TypesManifest(
42-
typingSpec = expectedTypingSpec,
4341
inputs = mapOf(
4442
"enum-input" to ApiItem(type = "enum", allowedValues = listOf("foo", "bar", "baz")),
4543
),
@@ -60,7 +58,6 @@ class ManifestValidationTest : FunSpec({
6058
test("list type") {
6159
// given
6260
val manifest = TypesManifest(
63-
typingSpec = expectedTypingSpec,
6461
inputs = mapOf(
6562
"list-of-strings-input" to ApiItem(
6663
type = "list",
@@ -111,53 +108,9 @@ class ManifestValidationTest : FunSpec({
111108
}
112109

113110
context("failure cases") {
114-
test("no typing spec set") {
115-
// given
116-
val manifest = TypesManifest(
117-
typingSpec = null,
118-
inputs = emptyMap(),
119-
outputs = emptyMap(),
120-
)
121-
122-
// when
123-
val result = manifest.validate()
124-
125-
// then
126-
result shouldBe ActionValidationResult(
127-
overallResult = ItemValidationResult.Invalid(
128-
"Set top-level 'typingSpec' attribute to 'krzema12/[email protected]', was: null"
129-
),
130-
inputs = emptyMap(),
131-
outputs = emptyMap(),
132-
)
133-
}
134-
135-
test("incorrect typing spec set") {
136-
// given
137-
val manifest = TypesManifest(
138-
typingSpec = "incorrect-typing-spec",
139-
inputs = emptyMap(),
140-
outputs = emptyMap(),
141-
)
142-
143-
// when
144-
val result = manifest.validate()
145-
146-
// then
147-
result shouldBe ActionValidationResult(
148-
overallResult = ItemValidationResult.Invalid(
149-
"Set top-level 'typingSpec' attribute to 'krzema12/[email protected]', " +
150-
"was: 'incorrect-typing-spec'"
151-
),
152-
inputs = emptyMap(),
153-
outputs = emptyMap(),
154-
)
155-
}
156-
157111
test("input and output without type") {
158112
// given
159113
val manifest = TypesManifest(
160-
typingSpec = expectedTypingSpec,
161114
inputs = mapOf(
162115
"some-input" to ApiItem(type = null),
163116
),
@@ -188,7 +141,6 @@ class ManifestValidationTest : FunSpec({
188141
test("unknown type") {
189142
// given
190143
val manifest = TypesManifest(
191-
typingSpec = expectedTypingSpec,
192144
inputs = mapOf(
193145
"some-input" to ApiItem(type = "for-sure-unknown-type"),
194146
),
@@ -211,7 +163,6 @@ class ManifestValidationTest : FunSpec({
211163
test("primitive types with 'allowedValues' attribute") {
212164
// given
213165
val manifest = TypesManifest(
214-
typingSpec = expectedTypingSpec,
215166
inputs = mapOf(
216167
"string-input" to ApiItem(type = "string", allowedValues = listOf("foo", "bar")),
217168
"boolean-input" to ApiItem(type = "boolean", allowedValues = listOf("foo", "bar")),
@@ -238,7 +189,6 @@ class ManifestValidationTest : FunSpec({
238189
test("primitive types with 'separator' attribute") {
239190
// given
240191
val manifest = TypesManifest(
241-
typingSpec = expectedTypingSpec,
242192
inputs = mapOf(
243193
"string-input" to ApiItem(type = "string", separator = ","),
244194
"boolean-input" to ApiItem(type = "boolean", separator = ","),
@@ -265,7 +215,6 @@ class ManifestValidationTest : FunSpec({
265215
test("non-list types with 'listItem' attribute") {
266216
// given
267217
val manifest = TypesManifest(
268-
typingSpec = expectedTypingSpec,
269218
inputs = mapOf(
270219
"string-input" to ApiItem(type = "string", listItem = ApiItem(type = "string")),
271220
"boolean-input" to ApiItem(type = "boolean", listItem = ApiItem(type = "string")),
@@ -298,7 +247,6 @@ class ManifestValidationTest : FunSpec({
298247
test("enum type with 'separator' attribute") {
299248
// given
300249
val manifest = TypesManifest(
301-
typingSpec = expectedTypingSpec,
302250
inputs = mapOf(
303251
"enum-input" to ApiItem(type = "enum", allowedValues = listOf("foo", "bar", "baz"), separator = ","),
304252
),
@@ -319,7 +267,6 @@ class ManifestValidationTest : FunSpec({
319267
test("enum type without 'allowedValues' attribute") {
320268
// given
321269
val manifest = TypesManifest(
322-
typingSpec = expectedTypingSpec,
323270
inputs = mapOf(
324271
"enum-input" to ApiItem(type = "enum", allowedValues = null),
325272
),
@@ -340,7 +287,6 @@ class ManifestValidationTest : FunSpec({
340287
test("enum type with just one allowed value") {
341288
// given
342289
val manifest = TypesManifest(
343-
typingSpec = expectedTypingSpec,
344290
inputs = mapOf(
345291
"enum-input" to ApiItem(type = "enum", allowedValues = listOf("foo")),
346292
),
@@ -361,7 +307,6 @@ class ManifestValidationTest : FunSpec({
361307
test("list type without 'listItem' attribute") {
362308
// given
363309
val manifest = TypesManifest(
364-
typingSpec = expectedTypingSpec,
365310
inputs = mapOf(
366311
"list-input" to ApiItem(type = "list", separator = ","),
367312
),
@@ -382,7 +327,6 @@ class ManifestValidationTest : FunSpec({
382327
test("list type without 'separator' attribute") {
383328
// given
384329
val manifest = TypesManifest(
385-
typingSpec = expectedTypingSpec,
386330
inputs = mapOf(
387331
"list-input" to ApiItem(type = "list", listItem = ApiItem(type = "string")),
388332
),
@@ -403,7 +347,6 @@ class ManifestValidationTest : FunSpec({
403347
test("list type with 'allowedValues' attribute") {
404348
// given
405349
val manifest = TypesManifest(
406-
typingSpec = expectedTypingSpec,
407350
inputs = mapOf(
408351
"list-input" to ApiItem(
409352
type = "list",
@@ -429,7 +372,6 @@ class ManifestValidationTest : FunSpec({
429372
test("list type with forbidden list item type") {
430373
// given
431374
val manifest = TypesManifest(
432-
typingSpec = expectedTypingSpec,
433375
inputs = mapOf(
434376
"list-of-lists-input" to ApiItem(
435377
type = "list",
@@ -460,7 +402,6 @@ class ManifestValidationTest : FunSpec({
460402
test("list type with list item type with incorrect attributes") {
461403
// given
462404
val manifest = TypesManifest(
463-
typingSpec = expectedTypingSpec,
464405
inputs = mapOf(
465406
"list-of-enums-without-allowed-values-input" to ApiItem(
466407
type = "list",
@@ -503,7 +444,6 @@ class ManifestValidationTest : FunSpec({
503444
test("non-integer types with named values") {
504445
// given
505446
val manifest = TypesManifest(
506-
typingSpec = expectedTypingSpec,
507447
inputs = mapOf(
508448
"string-input" to ApiItem(type = "string", namedValues = mapOf("foo" to 1)),
509449
"boolean-input" to ApiItem(type = "boolean", namedValues = mapOf("foo" to 1)),

src/test/kotlin/it/krzeminski/githubactionstyping/validation/ManifestsToReportTest.kt

-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ class ManifestsToReportTest : FunSpec({
2525
image: 'Dockerfile'
2626
""".trimIndent()
2727
val typesManifest = """
28-
typingSpec: krzema12/[email protected]
2928
inputs:
3029
verbose:
3130
type: boolean
@@ -79,7 +78,6 @@ class ManifestsToReportTest : FunSpec({
7978
image: 'Dockerfile'
8079
""".trimIndent()
8180
val typesManifest = """
82-
typingSpec: krzema12/[email protected]
8381
inputs:
8482
verbose:
8583
type: boolean

0 commit comments

Comments
 (0)