Skip to content

Commit 1542f03

Browse files
committed
feat(abg)!: replace data class perks by code generation in bindings
1 parent b4d13ce commit 1542f03

16 files changed

+1339
-285
lines changed

action-binding-generator/src/main/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/generation/Generation.kt

Lines changed: 299 additions & 50 deletions
Large diffs are not rendered by default.

action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/ActionBindingV2WithSubAction.kt

Lines changed: 41 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
// This file was generated using action-binding-generator. Don't change it by hand, otherwise your
22
// changes will be overwritten with the next binding code regeneration.
33
// See https://github.com/typesafegithub/github-workflows-kt for more info.
4-
@file:Suppress(
5-
"DataClassPrivateConstructor",
6-
"UNUSED_PARAMETER",
7-
)
4+
@file:Suppress("UNUSED_PARAMETER")
85

96
package io.github.typesafegithub.workflows.actions.johnsmith
107

118
import io.github.typesafegithub.workflows.domain.actions.Action
129
import io.github.typesafegithub.workflows.domain.actions.RegularAction
1310
import java.util.LinkedHashMap
14-
import kotlin.ExposedCopyVisibility
11+
import java.util.Objects
12+
import kotlin.Any
13+
import kotlin.Boolean
14+
import kotlin.Int
1515
import kotlin.String
1616
import kotlin.Suppress
1717
import kotlin.Unit
@@ -27,8 +27,8 @@ import kotlin.collections.Map
2727
* @param _customInputs Type-unsafe map where you can put any inputs that are not yet supported by the binding
2828
* @param _customVersion Allows overriding action's version, for example to use a specific minor version, or a newer version that the binding doesn't yet know about
2929
*/
30-
@ExposedCopyVisibility
31-
public data class ActionBindingV2WithSubAction private constructor(
30+
public class ActionBindingV2WithSubAction(
31+
vararg pleaseUseNamedArguments: Unit,
3232
/**
3333
* Type-unsafe map where you can put any inputs that are not yet supported by the binding
3434
*/
@@ -49,14 +49,42 @@ public data class ActionBindingV2WithSubAction private constructor(
4949

5050
}
5151

52-
public constructor(
53-
vararg pleaseUseNamedArguments: Unit,
54-
_customInputs: Map<String, String> = mapOf(),
55-
_customVersion: String? = null,
56-
) : this(_customInputs = _customInputs, _customVersion = _customVersion)
57-
5852
@Suppress("SpreadOperator")
5953
override fun toYamlArguments(): LinkedHashMap<String, String> = LinkedHashMap(_customInputs)
6054

55+
override fun equals(other: Any?): Boolean {
56+
if (this === other) return true
57+
if (javaClass != other?.javaClass) return false
58+
other as ActionBindingV2WithSubAction
59+
return _customInputs == other._customInputs &&
60+
_customVersion == other._customVersion
61+
}
62+
63+
override fun hashCode(): Int = Objects.hash(
64+
_customInputs,
65+
_customVersion,
66+
)
67+
68+
override fun toString(): String = buildString {
69+
append("ActionBindingV2WithSubAction(")
70+
append("""_customInputs=$_customInputs""")
71+
append(", ")
72+
append("""_customVersion=$_customVersion""")
73+
append(")")
74+
}
75+
76+
/**
77+
* @param _customInputs Type-unsafe map where you can put any inputs that are not yet supported by the binding
78+
* @param _customVersion Allows overriding action's version, for example to use a specific minor version, or a newer version that the binding doesn't yet know about
79+
*/
80+
public fun copy(
81+
vararg pleaseUseNamedArguments: Unit,
82+
_customInputs: Map<String, String> = this._customInputs,
83+
_customVersion: String? = this._customVersion,
84+
): ActionBindingV2WithSubAction = ActionBindingV2WithSubAction(
85+
_customInputs = _customInputs,
86+
_customVersion = _customVersion,
87+
)
88+
6189
override fun buildOutputObject(stepId: String): Action.Outputs = Outputs(stepId)
6290
}

action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/bindingsfromunittests/ActionWithAllTypesOfInputsBindingV2.kt

Lines changed: 207 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
11
// This file was generated using action-binding-generator. Don't change it by hand, otherwise your
22
// changes will be overwritten with the next binding code regeneration.
33
// See https://github.com/typesafegithub/github-workflows-kt for more info.
4-
@file:Suppress(
5-
"DataClassPrivateConstructor",
6-
"UNUSED_PARAMETER",
7-
)
4+
@file:Suppress("UNUSED_PARAMETER")
85

96
package io.github.typesafegithub.workflows.actions.johnsmith
107

118
import io.github.typesafegithub.workflows.domain.actions.Action
129
import io.github.typesafegithub.workflows.domain.actions.RegularAction
1310
import java.util.LinkedHashMap
11+
import java.util.Objects
12+
import kotlin.Any
1413
import kotlin.Boolean
15-
import kotlin.ExposedCopyVisibility
1614
import kotlin.Float
1715
import kotlin.Int
1816
import kotlin.String
@@ -57,8 +55,8 @@ import kotlin.collections.toTypedArray
5755
* @param _customInputs Type-unsafe map where you can put any inputs that are not yet supported by the binding
5856
* @param _customVersion Allows overriding action's version, for example to use a specific minor version, or a newer version that the binding doesn't yet know about
5957
*/
60-
@ExposedCopyVisibility
61-
public data class ActionWithAllTypesOfInputsBindingV2 private constructor(
58+
public class ActionWithAllTypesOfInputsBindingV2(
59+
vararg pleaseUseNamedArguments: Unit,
6260
/**
6361
* &lt;required&gt; Short description
6462
*/
@@ -243,36 +241,6 @@ public data class ActionWithAllTypesOfInputsBindingV2 private constructor(
243241
}
244242
}
245243

246-
public constructor(
247-
vararg pleaseUseNamedArguments: Unit,
248-
fooBar: String? = null,
249-
fooBar_Untyped: String? = null,
250-
bazGoo: Boolean? = null,
251-
bazGoo_Untyped: String? = null,
252-
binKin: Boolean? = null,
253-
binKin_Untyped: String? = null,
254-
intPint: Int? = null,
255-
intPint_Untyped: String? = null,
256-
floPint: Float? = null,
257-
floPint_Untyped: String? = null,
258-
finBin: ActionWithAllTypesOfInputsBindingV2.Bin? = null,
259-
finBin_Untyped: String? = null,
260-
gooZen: ActionWithAllTypesOfInputsBindingV2.Zen? = null,
261-
gooZen_Untyped: String? = null,
262-
bahEnum: ActionWithAllTypesOfInputsBindingV2.BahEnum? = null,
263-
bahEnum_Untyped: String? = null,
264-
listStrings: List<String>? = null,
265-
listStrings_Untyped: String? = null,
266-
listInts: List<Int>? = null,
267-
listInts_Untyped: String? = null,
268-
listEnums: List<ActionWithAllTypesOfInputsBindingV2.MyEnum>? = null,
269-
listEnums_Untyped: String? = null,
270-
listIntSpecial: List<ActionWithAllTypesOfInputsBindingV2.MyInt>? = null,
271-
listIntSpecial_Untyped: String? = null,
272-
_customInputs: Map<String, String> = mapOf(),
273-
_customVersion: String? = null,
274-
) : this(fooBar = fooBar, fooBar_Untyped = fooBar_Untyped, bazGoo = bazGoo, bazGoo_Untyped = bazGoo_Untyped, binKin = binKin, binKin_Untyped = binKin_Untyped, intPint = intPint, intPint_Untyped = intPint_Untyped, floPint = floPint, floPint_Untyped = floPint_Untyped, finBin = finBin, finBin_Untyped = finBin_Untyped, gooZen = gooZen, gooZen_Untyped = gooZen_Untyped, bahEnum = bahEnum, bahEnum_Untyped = bahEnum_Untyped, listStrings = listStrings, listStrings_Untyped = listStrings_Untyped, listInts = listInts, listInts_Untyped = listInts_Untyped, listEnums = listEnums, listEnums_Untyped = listEnums_Untyped, listIntSpecial = listIntSpecial, listIntSpecial_Untyped = listIntSpecial_Untyped, _customInputs = _customInputs, _customVersion = _customVersion)
275-
276244
@Suppress("SpreadOperator")
277245
override fun toYamlArguments(): LinkedHashMap<String, String> = linkedMapOf(
278246
*listOfNotNull(
@@ -304,6 +272,208 @@ public data class ActionWithAllTypesOfInputsBindingV2 private constructor(
304272
).toTypedArray()
305273
)
306274

275+
override fun equals(other: Any?): Boolean {
276+
if (this === other) return true
277+
if (javaClass != other?.javaClass) return false
278+
other as ActionWithAllTypesOfInputsBindingV2
279+
return fooBar == other.fooBar &&
280+
fooBar_Untyped == other.fooBar_Untyped &&
281+
bazGoo == other.bazGoo &&
282+
bazGoo_Untyped == other.bazGoo_Untyped &&
283+
binKin == other.binKin &&
284+
binKin_Untyped == other.binKin_Untyped &&
285+
intPint == other.intPint &&
286+
intPint_Untyped == other.intPint_Untyped &&
287+
floPint == other.floPint &&
288+
floPint_Untyped == other.floPint_Untyped &&
289+
finBin == other.finBin &&
290+
finBin_Untyped == other.finBin_Untyped &&
291+
gooZen == other.gooZen &&
292+
gooZen_Untyped == other.gooZen_Untyped &&
293+
bahEnum == other.bahEnum &&
294+
bahEnum_Untyped == other.bahEnum_Untyped &&
295+
listStrings == other.listStrings &&
296+
listStrings_Untyped == other.listStrings_Untyped &&
297+
listInts == other.listInts &&
298+
listInts_Untyped == other.listInts_Untyped &&
299+
listEnums == other.listEnums &&
300+
listEnums_Untyped == other.listEnums_Untyped &&
301+
listIntSpecial == other.listIntSpecial &&
302+
listIntSpecial_Untyped == other.listIntSpecial_Untyped &&
303+
_customInputs == other._customInputs &&
304+
_customVersion == other._customVersion
305+
}
306+
307+
override fun hashCode(): Int = Objects.hash(
308+
fooBar,
309+
fooBar_Untyped,
310+
bazGoo,
311+
bazGoo_Untyped,
312+
binKin,
313+
binKin_Untyped,
314+
intPint,
315+
intPint_Untyped,
316+
floPint,
317+
floPint_Untyped,
318+
finBin,
319+
finBin_Untyped,
320+
gooZen,
321+
gooZen_Untyped,
322+
bahEnum,
323+
bahEnum_Untyped,
324+
listStrings,
325+
listStrings_Untyped,
326+
listInts,
327+
listInts_Untyped,
328+
listEnums,
329+
listEnums_Untyped,
330+
listIntSpecial,
331+
listIntSpecial_Untyped,
332+
_customInputs,
333+
_customVersion,
334+
)
335+
336+
override fun toString(): String = buildString {
337+
append("ActionWithAllTypesOfInputsBindingV2(")
338+
append("""fooBar=$fooBar""")
339+
append(", ")
340+
append("""fooBar_Untyped=$fooBar_Untyped""")
341+
append(", ")
342+
append("""bazGoo=$bazGoo""")
343+
append(", ")
344+
append("""bazGoo_Untyped=$bazGoo_Untyped""")
345+
append(", ")
346+
append("""binKin=$binKin""")
347+
append(", ")
348+
append("""binKin_Untyped=$binKin_Untyped""")
349+
append(", ")
350+
append("""intPint=$intPint""")
351+
append(", ")
352+
append("""intPint_Untyped=$intPint_Untyped""")
353+
append(", ")
354+
append("""floPint=$floPint""")
355+
append(", ")
356+
append("""floPint_Untyped=$floPint_Untyped""")
357+
append(", ")
358+
append("""finBin=$finBin""")
359+
append(", ")
360+
append("""finBin_Untyped=$finBin_Untyped""")
361+
append(", ")
362+
append("""gooZen=$gooZen""")
363+
append(", ")
364+
append("""gooZen_Untyped=$gooZen_Untyped""")
365+
append(", ")
366+
append("""bahEnum=$bahEnum""")
367+
append(", ")
368+
append("""bahEnum_Untyped=$bahEnum_Untyped""")
369+
append(", ")
370+
append("""listStrings=$listStrings""")
371+
append(", ")
372+
append("""listStrings_Untyped=$listStrings_Untyped""")
373+
append(", ")
374+
append("""listInts=$listInts""")
375+
append(", ")
376+
append("""listInts_Untyped=$listInts_Untyped""")
377+
append(", ")
378+
append("""listEnums=$listEnums""")
379+
append(", ")
380+
append("""listEnums_Untyped=$listEnums_Untyped""")
381+
append(", ")
382+
append("""listIntSpecial=$listIntSpecial""")
383+
append(", ")
384+
append("""listIntSpecial_Untyped=$listIntSpecial_Untyped""")
385+
append(", ")
386+
append("""_customInputs=$_customInputs""")
387+
append(", ")
388+
append("""_customVersion=$_customVersion""")
389+
append(")")
390+
}
391+
392+
/**
393+
* @param fooBar &lt;required&gt; Short description
394+
* @param fooBar_Untyped &lt;required&gt; Short description
395+
* @param bazGoo &lt;required&gt; First boolean input!
396+
* @param bazGoo_Untyped &lt;required&gt; First boolean input!
397+
* @param binKin Boolean and nullable
398+
* @param binKin_Untyped Boolean and nullable
399+
* @param intPint &lt;required&gt; Integer
400+
* @param intPint_Untyped &lt;required&gt; Integer
401+
* @param floPint &lt;required&gt; Float
402+
* @param floPint_Untyped &lt;required&gt; Float
403+
* @param finBin &lt;required&gt; Enumeration
404+
* @param finBin_Untyped &lt;required&gt; Enumeration
405+
* @param gooZen &lt;required&gt; Integer with special value
406+
* @param gooZen_Untyped &lt;required&gt; Integer with special value
407+
* @param bahEnum &lt;required&gt; Enum with custom naming
408+
* @param bahEnum_Untyped &lt;required&gt; Enum with custom naming
409+
* @param listStrings List of strings
410+
* @param listStrings_Untyped List of strings
411+
* @param listInts List of integers
412+
* @param listInts_Untyped List of integers
413+
* @param listEnums List of enums
414+
* @param listEnums_Untyped List of enums
415+
* @param listIntSpecial List of integer with special values
416+
* @param listIntSpecial_Untyped List of integer with special values
417+
* @param _customInputs Type-unsafe map where you can put any inputs that are not yet supported by the binding
418+
* @param _customVersion Allows overriding action's version, for example to use a specific minor version, or a newer version that the binding doesn't yet know about
419+
*/
420+
public fun copy(
421+
vararg pleaseUseNamedArguments: Unit,
422+
fooBar: String? = this.fooBar,
423+
fooBar_Untyped: String? = this.fooBar_Untyped,
424+
bazGoo: Boolean? = this.bazGoo,
425+
bazGoo_Untyped: String? = this.bazGoo_Untyped,
426+
binKin: Boolean? = this.binKin,
427+
binKin_Untyped: String? = this.binKin_Untyped,
428+
intPint: Int? = this.intPint,
429+
intPint_Untyped: String? = this.intPint_Untyped,
430+
floPint: Float? = this.floPint,
431+
floPint_Untyped: String? = this.floPint_Untyped,
432+
finBin: ActionWithAllTypesOfInputsBindingV2.Bin? = this.finBin,
433+
finBin_Untyped: String? = this.finBin_Untyped,
434+
gooZen: ActionWithAllTypesOfInputsBindingV2.Zen? = this.gooZen,
435+
gooZen_Untyped: String? = this.gooZen_Untyped,
436+
bahEnum: ActionWithAllTypesOfInputsBindingV2.BahEnum? = this.bahEnum,
437+
bahEnum_Untyped: String? = this.bahEnum_Untyped,
438+
listStrings: List<String>? = this.listStrings,
439+
listStrings_Untyped: String? = this.listStrings_Untyped,
440+
listInts: List<Int>? = this.listInts,
441+
listInts_Untyped: String? = this.listInts_Untyped,
442+
listEnums: List<ActionWithAllTypesOfInputsBindingV2.MyEnum>? = this.listEnums,
443+
listEnums_Untyped: String? = this.listEnums_Untyped,
444+
listIntSpecial: List<ActionWithAllTypesOfInputsBindingV2.MyInt>? = this.listIntSpecial,
445+
listIntSpecial_Untyped: String? = this.listIntSpecial_Untyped,
446+
_customInputs: Map<String, String> = this._customInputs,
447+
_customVersion: String? = this._customVersion,
448+
): ActionWithAllTypesOfInputsBindingV2 = ActionWithAllTypesOfInputsBindingV2(
449+
fooBar = fooBar,
450+
fooBar_Untyped = fooBar_Untyped,
451+
bazGoo = bazGoo,
452+
bazGoo_Untyped = bazGoo_Untyped,
453+
binKin = binKin,
454+
binKin_Untyped = binKin_Untyped,
455+
intPint = intPint,
456+
intPint_Untyped = intPint_Untyped,
457+
floPint = floPint,
458+
floPint_Untyped = floPint_Untyped,
459+
finBin = finBin,
460+
finBin_Untyped = finBin_Untyped,
461+
gooZen = gooZen,
462+
gooZen_Untyped = gooZen_Untyped,
463+
bahEnum = bahEnum,
464+
bahEnum_Untyped = bahEnum_Untyped,
465+
listStrings = listStrings,
466+
listStrings_Untyped = listStrings_Untyped,
467+
listInts = listInts,
468+
listInts_Untyped = listInts_Untyped,
469+
listEnums = listEnums,
470+
listEnums_Untyped = listEnums_Untyped,
471+
listIntSpecial = listIntSpecial,
472+
listIntSpecial_Untyped = listIntSpecial_Untyped,
473+
_customInputs = _customInputs,
474+
_customVersion = _customVersion,
475+
)
476+
307477
override fun buildOutputObject(stepId: String): Outputs = Outputs(stepId)
308478

309479
public sealed class Bin(

0 commit comments

Comments
 (0)