Skip to content

Commit 7cf3a6e

Browse files
fix(deps): update dependency org.jmailen.gradle:kotlinter-gradle to v4.4.0 (#1514)
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [org.jmailen.gradle:kotlinter-gradle](https://togithub.com/jeremymailen/kotlinter-gradle) | `4.3.0` -> `4.4.0` | [![age](https://developer.mend.io/api/mc/badges/age/maven/org.jmailen.gradle:kotlinter-gradle/4.4.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/maven/org.jmailen.gradle:kotlinter-gradle/4.4.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/maven/org.jmailen.gradle:kotlinter-gradle/4.3.0/4.4.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/maven/org.jmailen.gradle:kotlinter-gradle/4.3.0/4.4.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | --- > [!WARNING] > Some dependencies could not be looked up. Check the Dependency Dashboard for more information. --- ### Release Notes <details> <summary>jeremymailen/kotlinter-gradle (org.jmailen.gradle:kotlinter-gradle)</summary> ### [`v4.4.0`](https://togithub.com/jeremymailen/kotlinter-gradle/releases/tag/4.4.0) [Compare Source](https://togithub.com/jeremymailen/kotlinter-gradle/compare/4.3.0...4.4.0) - Upgrade to [ktlint 1.3.0](https://togithub.com/pinterest/ktlint/releases/tag/1.3.0) - Upgrade to kotlin 2.0 ktlint 1.3.0 introduces some significant formatting rule changes, so you may find applying this newer version will introduce a lot of changes. </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/typesafegithub/github-workflows-kt). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy40MTMuMiIsInVwZGF0ZWRJblZlciI6IjM3LjQxMy4yIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119--> --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Piotr Krzeminski <[email protected]>
1 parent 05ee84c commit 7cf3a6e

File tree

75 files changed

+4675
-4516
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+4675
-4516
lines changed

action-binding-generator/src/main/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/domain/MetadataRevision.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,6 @@ public data object NewestForVersion : MetadataRevision
66

77
public data object FromLockfile : MetadataRevision
88

9-
public data class CommitHash(val value: String) : MetadataRevision
9+
public data class CommitHash(
10+
val value: String,
11+
) : MetadataRevision

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

Lines changed: 95 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ private fun Metadata.removeDeprecatedInputsIfNameClash(): Metadata {
103103
clashingInputs
104104
.find { it.value.deprecationMessage == null }
105105
?: clashingInputs.first()
106-
}.values.associateBy({ it.key }, { it.value })
106+
}.values
107+
.associateBy({ it.key }, { it.value })
107108
return this.copy(inputs = newInputs)
108109
}
109110

@@ -114,18 +115,17 @@ private fun generateActionBindingSourceCode(
114115
className: String,
115116
): String {
116117
val fileSpec =
117-
FileSpec.builder(
118-
"io.github.typesafegithub.workflows.actions.${coords.owner.toKotlinPackageName()}",
119-
className,
120-
)
121-
.addFileComment(
118+
FileSpec
119+
.builder(
120+
"io.github.typesafegithub.workflows.actions.${coords.owner.toKotlinPackageName()}",
121+
className,
122+
).addFileComment(
122123
"""
123124
This file was generated using action-binding-generator. Don't change it by hand, otherwise your
124125
changes will be overwritten with the next binding code regeneration.
125126
See https://github.com/typesafegithub/github-workflows-kt for more info.
126127
""".trimIndent(),
127-
)
128-
.addType(generateActionClass(metadata, coords, inputTypings, className))
128+
).addType(generateActionClass(metadata, coords, inputTypings, className))
129129
.addSuppressAnnotation(metadata, coords)
130130
.indent(" ")
131131
.build()
@@ -142,15 +142,15 @@ private fun FileSpec.Builder.addSuppressAnnotation(
142142
val addSuppressionForDeprecation = isDeprecatedInputUsed || coords.deprecatedByVersion != null
143143

144144
addAnnotation(
145-
AnnotationSpec.builder(Suppress::class.asClassName())
145+
AnnotationSpec
146+
.builder(Suppress::class.asClassName())
146147
.addMember(CodeBlock.of("%S", "DataClassPrivateConstructor"))
147148
.addMember(CodeBlock.of("%S", "UNUSED_PARAMETER"))
148149
.apply {
149150
if (addSuppressionForDeprecation) {
150151
addMember(CodeBlock.of("%S", "DEPRECATION"))
151152
}
152-
}
153-
.build(),
153+
}.build(),
154154
)
155155
}
156156

@@ -159,8 +159,9 @@ private fun generateActionClass(
159159
coords: ActionCoords,
160160
inputTypings: Map<String, Typing>,
161161
className: String,
162-
): TypeSpec {
163-
return TypeSpec.classBuilder(className)
162+
): TypeSpec =
163+
TypeSpec
164+
.classBuilder(className)
164165
.addModifiers(KModifier.DATA)
165166
.addKdoc(actionKdoc(metadata, coords))
166167
.addMaybeDeprecated(coords)
@@ -173,7 +174,6 @@ private fun generateActionClass(
173174
.addOutputClassIfNecessary(metadata)
174175
.addBuildOutputObjectFunctionIfNecessary(metadata)
175176
.build()
176-
}
177177

178178
private fun TypeSpec.Builder.addCustomTypes(
179179
typings: Map<String, Typing>,
@@ -195,7 +195,8 @@ private fun TypeSpec.Builder.properties(
195195
): TypeSpec.Builder {
196196
metadata.inputs.forEach { (key, input) ->
197197
addProperty(
198-
PropertySpec.builder(key.toCamelCase(), inputTypings.getInputType(key, input, coords, className))
198+
PropertySpec
199+
.builder(key.toCamelCase(), inputTypings.getInputType(key, input, coords, className))
199200
.initializer(key.toCamelCase())
200201
.annotateDeprecated(input)
201202
.build(),
@@ -214,23 +215,26 @@ private fun TypeSpec.Builder.addOutputClassIfNecessary(metadata: Metadata): Type
214215
}
215216

216217
val stepIdConstructorParameter =
217-
ParameterSpec.builder("stepId", String::class)
218+
ParameterSpec
219+
.builder("stepId", String::class)
218220
.build()
219221
val propertiesFromOutputs =
220222
metadata.outputs.map { (key, value) ->
221-
PropertySpec.builder(key.toCamelCase(), String::class)
223+
PropertySpec
224+
.builder(key.toCamelCase(), String::class)
222225
.initializer("\"steps.\$stepId.outputs.$key\"")
223226
.addKdoc(value.description.nestedCommentsSanitized.removeTrailingWhitespacesForEachLine())
224227
.build()
225228
}
226229
addType(
227-
TypeSpec.classBuilder("Outputs")
230+
TypeSpec
231+
.classBuilder("Outputs")
228232
.primaryConstructor(
229-
FunSpec.constructorBuilder()
233+
FunSpec
234+
.constructorBuilder()
230235
.addParameter(stepIdConstructorParameter)
231236
.build(),
232-
)
233-
.superclass(OutputsBase)
237+
).superclass(OutputsBase)
234238
.addSuperclassConstructorParameter("stepId")
235239
.addProperties(propertiesFromOutputs)
236240
.build(),
@@ -241,7 +245,8 @@ private fun TypeSpec.Builder.addOutputClassIfNecessary(metadata: Metadata): Type
241245

242246
private fun TypeSpec.Builder.addBuildOutputObjectFunctionIfNecessary(metadata: Metadata): TypeSpec.Builder {
243247
addFunction(
244-
FunSpec.builder("buildOutputObject")
248+
FunSpec
249+
.builder("buildOutputObject")
245250
.returns(if (metadata.outputs.isEmpty()) OutputsBase else ClassName("", "Outputs"))
246251
.addModifiers(KModifier.OVERRIDE)
247252
.addParameter("stepId", String::class)
@@ -256,50 +261,55 @@ private fun PropertySpec.Builder.annotateDeprecated(input: Input) =
256261
apply {
257262
if (input.deprecationMessage != null) {
258263
addAnnotation(
259-
AnnotationSpec.builder(Deprecated::class.asClassName())
264+
AnnotationSpec
265+
.builder(Deprecated::class.asClassName())
260266
.addMember(CodeBlock.of("%S", input.deprecationMessage))
261267
.build(),
262268
)
263269
}
264270
}
265271

266272
private fun Metadata.buildToYamlArgumentsFunction(inputTypings: Map<String, Typing>) =
267-
FunSpec.builder("toYamlArguments")
273+
FunSpec
274+
.builder("toYamlArguments")
268275
.addModifiers(KModifier.OVERRIDE)
269276
.returns(LinkedHashMap::class.parameterizedBy(String::class, String::class))
270277
.addAnnotation(
271-
AnnotationSpec.builder(Suppress::class)
278+
AnnotationSpec
279+
.builder(Suppress::class)
272280
.addMember("\"SpreadOperator\"")
273281
.build(),
274-
)
275-
.addCode(linkedMapOfInputs(inputTypings))
282+
).addCode(linkedMapOfInputs(inputTypings))
276283
.build()
277284

278285
private fun Metadata.linkedMapOfInputs(inputTypings: Map<String, Typing>): CodeBlock {
279286
if (inputs.isEmpty()) {
280-
return CodeBlock.Builder()
287+
return CodeBlock
288+
.Builder()
281289
.add(CodeBlock.of("return %T($CUSTOM_INPUTS)", LinkedHashMap::class))
282290
.build()
283291
} else {
284-
return CodeBlock.Builder().apply {
285-
add("return linkedMapOf(\n")
286-
indent()
287-
add("*listOfNotNull(\n")
288-
indent()
289-
inputs.forEach { (key, value) ->
290-
val asStringCode = inputTypings.getInputTyping(key).asString()
291-
if (!value.shouldBeNonNullInBinding()) {
292-
add("%N?.let { %S to it$asStringCode },\n", key.toCamelCase(), key)
293-
} else {
294-
add("%S to %N$asStringCode,\n", key, key.toCamelCase())
292+
return CodeBlock
293+
.Builder()
294+
.apply {
295+
add("return linkedMapOf(\n")
296+
indent()
297+
add("*listOfNotNull(\n")
298+
indent()
299+
inputs.forEach { (key, value) ->
300+
val asStringCode = inputTypings.getInputTyping(key).asString()
301+
if (!value.shouldBeNonNullInBinding()) {
302+
add("%N?.let { %S to it$asStringCode },\n", key.toCamelCase(), key)
303+
} else {
304+
add("%S to %N$asStringCode,\n", key, key.toCamelCase())
305+
}
295306
}
296-
}
297-
add("*$CUSTOM_INPUTS.%M().%M(),\n", Types.mapToList, Types.listToArray)
298-
unindent()
299-
add(").toTypedArray()\n")
300-
unindent()
301-
add(")")
302-
}.build()
307+
add("*$CUSTOM_INPUTS.%M().%M(),\n", Types.mapToList, Types.listToArray)
308+
unindent()
309+
add(").toTypedArray()\n")
310+
unindent()
311+
add(")")
312+
}.build()
303313
}
304314
}
305315

@@ -309,7 +319,8 @@ private fun TypeSpec.Builder.addMaybeDeprecated(coords: ActionCoords): TypeSpec.
309319
}
310320
val newerClass = coords.copy(version = coords.deprecatedByVersion)
311321
addAnnotation(
312-
AnnotationSpec.builder(Deprecated::class)
322+
AnnotationSpec
323+
.builder(Deprecated::class)
313324
.addMember("message = %S", "This action has a newer major version: ${newerClass.buildActionClassName()}")
314325
.addMember("replaceWith = ReplaceWith(%S)", newerClass.buildActionClassName())
315326
.build(),
@@ -346,56 +357,58 @@ private fun Metadata.primaryConstructor(
346357
inputTypings: Map<String, Typing>,
347358
coords: ActionCoords,
348359
className: String,
349-
): FunSpec {
350-
return FunSpec.constructorBuilder()
360+
): FunSpec =
361+
FunSpec
362+
.constructorBuilder()
351363
.addModifiers(KModifier.PRIVATE)
352364
.addParameters(buildCommonConstructorParameters(inputTypings, coords, className))
353365
.build()
354-
}
355366

356367
private fun Metadata.secondaryConstructor(
357368
inputTypings: Map<String, Typing>,
358369
coords: ActionCoords,
359370
className: String,
360-
): FunSpec {
361-
return FunSpec.constructorBuilder()
371+
): FunSpec =
372+
FunSpec
373+
.constructorBuilder()
362374
.addParameter(
363-
ParameterSpec.builder("pleaseUseNamedArguments", Unit::class)
375+
ParameterSpec
376+
.builder("pleaseUseNamedArguments", Unit::class)
364377
.addModifiers(KModifier.VARARG)
365378
.build(),
366-
)
367-
.addParameters(buildCommonConstructorParameters(inputTypings, coords, className))
379+
).addParameters(buildCommonConstructorParameters(inputTypings, coords, className))
368380
.callThisConstructor(
369381
(inputs.keys.map { it.toCamelCase() } + CUSTOM_INPUTS + CUSTOM_VERSION)
370382
.map { CodeBlock.of("%N=%N", it, it) },
371-
)
372-
.build()
373-
}
383+
).build()
374384

375385
private fun Metadata.buildCommonConstructorParameters(
376386
inputTypings: Map<String, Typing>,
377387
coords: ActionCoords,
378388
className: String,
379389
): List<ParameterSpec> =
380-
inputs.map { (key, input) ->
381-
ParameterSpec.builder(key.toCamelCase(), inputTypings.getInputType(key, input, coords, className))
382-
.defaultValueIfNullable(input)
383-
.addKdoc(input.description.nestedCommentsSanitized.removeTrailingWhitespacesForEachLine())
384-
.build()
385-
}.plus(
386-
ParameterSpec.builder(CUSTOM_INPUTS, Types.mapStringString)
387-
.defaultValue("mapOf()")
388-
.addKdoc("Type-unsafe map where you can put any inputs that are not yet supported by the binding")
389-
.build(),
390-
).plus(
391-
ParameterSpec.builder(CUSTOM_VERSION, Types.nullableString)
392-
.defaultValue("null")
393-
.addKdoc(
394-
"Allows overriding action's version, for example to use a specific minor version, " +
395-
"or a newer version that the binding doesn't yet know about",
396-
)
397-
.build(),
398-
)
390+
inputs
391+
.map { (key, input) ->
392+
ParameterSpec
393+
.builder(key.toCamelCase(), inputTypings.getInputType(key, input, coords, className))
394+
.defaultValueIfNullable(input)
395+
.addKdoc(input.description.nestedCommentsSanitized.removeTrailingWhitespacesForEachLine())
396+
.build()
397+
}.plus(
398+
ParameterSpec
399+
.builder(CUSTOM_INPUTS, Types.mapStringString)
400+
.defaultValue("mapOf()")
401+
.addKdoc("Type-unsafe map where you can put any inputs that are not yet supported by the binding")
402+
.build(),
403+
).plus(
404+
ParameterSpec
405+
.builder(CUSTOM_VERSION, Types.nullableString)
406+
.defaultValue("null")
407+
.addKdoc(
408+
"Allows overriding action's version, for example to use a specific minor version, " +
409+
"or a newer version that the binding doesn't yet know about",
410+
).build(),
411+
)
399412

400413
private fun ParameterSpec.Builder.defaultValueIfNullable(input: Input): ParameterSpec.Builder {
401414
if (!input.shouldBeNonNullInBinding()) {
@@ -424,7 +437,8 @@ private fun Map<String, Typing>.getInputType(
424437
input: Input,
425438
coords: ActionCoords,
426439
className: String,
427-
) = getInputTyping(key).getClassName(coords.owner.toKotlinPackageName(), className, key)
440+
) = getInputTyping(key)
441+
.getClassName(coords.owner.toKotlinPackageName(), className, key)
428442
.copy(nullable = !input.shouldBeNonNullInBinding())
429443

430444
// Replacing: working around a bug in Kotlin: https://youtrack.jetbrains.com/issue/KT-23333
@@ -438,5 +452,7 @@ private val String.nestedCommentsSanitized
438452
}
439453

440454
private fun ActionCoords.getCommitHashFromFileSystem(): String? =
441-
Path.of("actions", owner, name.substringBefore('/'), version, "commit-hash.txt").toFile()
455+
Path
456+
.of("actions", owner, name.substringBefore('/'), version, "commit-hash.txt")
457+
.toFile()
442458
.let { if (it.exists()) it.readText().trim() else null }

action-binding-generator/src/main/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/metadata/MetadataReading.kt

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,17 +63,22 @@ public fun ActionCoords.fetchMetadata(
6363
}
6464
val list = listOf(actionYmlUrl(gitRef), actionYamlUrl(gitRef))
6565

66-
return list.firstNotNullOfOrNull { url ->
67-
try {
68-
println(" ... from $url")
69-
fetchUri(URI(url))
70-
} catch (e: IOException) {
71-
null
72-
}
73-
}?.let { myYaml.decodeFromString(it) }
66+
return list
67+
.firstNotNullOfOrNull { url ->
68+
try {
69+
println(" ... from $url")
70+
fetchUri(URI(url))
71+
} catch (e: IOException) {
72+
null
73+
}
74+
}?.let { myYaml.decodeFromString(it) }
7475
}
7576

7677
private fun ActionCoords.getCommitHashFromFileSystem(): String =
77-
Path.of("actions", owner, name.substringBefore('/'), version, "commit-hash.txt").toFile().readText().trim()
78+
Path
79+
.of("actions", owner, name.substringBefore('/'), version, "commit-hash.txt")
80+
.toFile()
81+
.readText()
82+
.trim()
7883

7984
internal fun fetchUri(uri: URI): String = uri.toURL().readText()

0 commit comments

Comments
 (0)