Skip to content

Instantly share code, notes, and snippets.

View krzema12's full-sized avatar

Piotr Krzemiński krzema12

View GitHub Profile
@krzema12
krzema12 / gist:59de5c0508dac8f5d1d27d00de38a06e
Created March 14, 2022 09:54
Popular wrappers left to add
listOf(
WrapperRequest(
ActionCoords("ad-m", "github-push-action", "v0.6.0"),
mapOf()
),
WrapperRequest(
ActionCoords("anmol098", "waka-readme-stats", "v4"),
mapOf(
"SHOW_OS" to StringTyping,
"SHOW_PROJECTS" to StringTyping,
Companion
java.lang.NoSuchFieldError: Companion
at com.charleskorn.kaml.YamlParser.<init>(YamlParser.kt:33)
at com.charleskorn.kaml.Yaml.parseToYamlNode$kaml(Yaml.kt:72)
at com.charleskorn.kaml.Yaml.decodeFromSource(Yaml.kt:62)
at com.charleskorn.kaml.Yaml.decodeFromString(Yaml.kt:55)
at io.github.typesafegithub.workflows.actionbindinggenerator.metadata.MetadataReadingKt.fetchMetadata(MetadataReading.kt:87)
at io.github.typesafegithub.workflows.actionbindinggenerator.metadata.MetadataReadingKt.fetchMetadata$default(MetadataReading.kt:55)
at io.github.typesafegithub.workflows.actionbindinggenerator.generation.GenerationKt.generateBinding$default(Generation.kt:79)
at io.github.typesafegithub.workflows.actionbindinggenerator.generation.GenerationTest$1$10.invokeSuspend(GenerationTest.kt:513)
@krzema12
krzema12 / KotlinPoet.kt
Created November 21, 2024 06:53
Using KotlinPoet to generate a class (top-level function)
fun generateActionClass(
metadata: Metadata,
coords: ActionCoords,
inputTypings: Map<String, Typing>,
className: String,
untypedClass: Boolean,
replaceWith: CodeBlock?,
): TypeSpec =
TypeSpec
.classBuilder(className)
@krzema12
krzema12 / WrapperRequest.kt
Created November 21, 2024 07:12
Defining what action we should build a binding for
WrapperRequest(
ActionCoords("actions", "checkout", "v2", deprecatedByVersion = "v3"),
mapOf(
"ssh-strict" to BooleanTyping,
"persist-credentials" to BooleanTyping,
"clean" to BooleanTyping,
"fetch-depth" to IntegerWithSpecialValueTyping("FetchDepth", mapOf("Infinite" to 0)),
"lfs" to BooleanTyping,
"submodules" to BooleanTyping,
),
@krzema12
krzema12 / workflow.yml
Created November 22, 2024 08:24
An example workflow in YAML
name: Build
on:
push:
branches: [main]
jobs:
build:
runs-on: ubuntu-latest
steps:
uses: actions/cache@v4
with:
path: |
build
.cache
key: build-cache-dirs
enableCrossOsArchive: true
uses: actions/checkout@v4
with:
fetch-depth: 0
uses: gradle/actions/setup-gradle@v4
data class Checkout(
val fetchDepth: FetchDepth,
) : Action(name = "actions/checkout@v2")
sealed interface FetchDepth {
object Infinite : FetchDepth
data class Quantity(val value: Int) : FetchDepth
}
// https://github.com/typesafegithub/github-workflows-kt/blob/4425bea99e8cd35eac5f11232f84df0ca5cd7afb/src/main/kotlin/it/krzeminski/githubactions/actions/Checkout.kt
data class CheckoutV2(
val repository: String? = null,
val ref: String? = null,
val token: String? = null,
val sshKey: String? = null,
val sshKnownHosts: String? = null,
val sshStrict: Boolean? = null,
val persistCredentials: Boolean? = null,
val path: String? = null,
val clean: Boolean? = null,