-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbuild.gradle.kts
170 lines (150 loc) · 5.81 KB
/
build.gradle.kts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
import org.gradle.api.tasks.PathSensitivity.NAME_ONLY
import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootPlugin.Companion.kotlinNodeJsRootExtension
import org.jetbrains.kotlin.gradle.targets.js.yarn.yarn
plugins {
kotlin("multiplatform") version "2.1.10"
kotlin("plugin.serialization") version "2.1.10"
id("io.kotest.multiplatform") version "6.0.0.M1"
distribution
}
val collectCatalogTypings by tasks.registering(Sync::class) {
from("../github-actions-typing-catalog/typings")
include("**/action-types.yml")
into(layout.buildDirectory.dir("catalog-typings"))
eachFile {
relativePath = RelativePath(
relativePath.isFile,
relativePath
.segments
.joinToString("_")
.replace("_action-types", "")
)
}
includeEmptyDirs = false
}
val collectExternalTypings by tasks.registering(Sync::class) {
mapOf(
"Vampire_setup-wsl_v4.yml" to "Vampire/setup-wsl/refs/heads/v4/action-types.yml",
"Vampire_setup-wsl_master.yml" to "Vampire/setup-wsl/refs/heads/master/action-types.yml",
"typesafegithub_github-actions-typing_v1.yml" to "typesafegithub/github-actions-typing/refs/heads/v1/action-types.yml",
"typesafegithub_github-actions-typing_main.yml" to "typesafegithub/github-actions-typing/refs/heads/main/action-types.yml",
).forEach { (name, location) ->
from(resources.text.fromUri("https://raw.githubusercontent.com/$location")) {
rename { name }
}
}
into(layout.buildDirectory.dir("external-typings"))
}
val schemaFile = file("github-actions-typing.schema.json")
val goodDir = file("src/test/resources/good-typings")
val badDir = file("src/test/resources/bad-typings")
kotlin {
jvmToolchain(21)
jvm {
mainRun {
mainClass = "it.krzeminski.githubactionstyping.MainKt"
}
val test by testRuns.existing {
executionTask {
useJUnitPlatform()
configureInputsForSchemaTest()
systemProperty("schemaFile", schemaFile.absolutePath)
systemProperty("catalogDir", collectCatalogTypings.get().destinationDir.absolutePath)
systemProperty("externalDir", collectExternalTypings.get().destinationDir.absolutePath)
systemProperty("goodDir", goodDir.absolutePath)
systemProperty("badDir", badDir.absolutePath)
}
}
}
js {
useEsModules()
nodejs {
testTask {
configureInputsForSchemaTest()
environment("schemaFile", schemaFile.absolutePath)
environment("catalogDir", collectCatalogTypings.get().destinationDir.absolutePath)
environment("externalDir", collectExternalTypings.get().destinationDir.absolutePath)
environment("goodDir", goodDir.absolutePath)
environment("badDir", badDir.absolutePath)
}
}
}
sourceSets {
jvmMain {
dependencies {
implementation("com.charleskorn.kaml:kaml:0.67.1")
}
}
jvmTest {
dependencies {
runtimeOnly("org.junit.platform:junit-platform-launcher")
implementation(dependencies.platform("io.kotest:kotest-bom:5.9.1"))
runtimeOnly("io.kotest:kotest-runner-junit5")
implementation("io.kotest:kotest-framework-api")
implementation("io.kotest:kotest-framework-datatest")
implementation("io.kotest:kotest-assertions-core")
implementation("it.krzeminski:snakeyaml-engine-kmp:3.1.0")
implementation("io.github.optimumcode:json-schema-validator:0.3.1")
}
}
jsTest {
dependencies {
implementation(dependencies.platform("io.kotest:kotest-bom:5.9.1"))
implementation("io.kotest:kotest-framework-engine")
implementation("io.kotest:kotest-framework-api")
implementation("io.kotest:kotest-framework-datatest")
implementation("io.kotest:kotest-assertions-core")
implementation(kotlinWrappers.js)
implementation(kotlinWrappers.node)
implementation(kotlinWrappers.ajv)
implementation(kotlinWrappers.yaml)
implementation(kotlinWrappers.prantlf.jsonlint)
}
}
}
}
kotlinNodeJsRootExtension.version = "20.18.1"
// disable the KMP plugin adding custom repositories which is bad practice
// and promotes supply chain attacks
// instead we define the repositories ourselves in the settings script
kotlinNodeJsRootExtension.downloadBaseUrl = null
yarn.downloadBaseUrl = null
distributions {
main {
contents {
into("lib") {
val jvmJar by tasks.existing
from(jvmJar)
val jvmRuntimeClasspath by configurations
from(jvmRuntimeClasspath)
}
}
}
}
fun AbstractTestTask.configureInputsForSchemaTest() {
inputs
.file(schemaFile)
.withPropertyName("schemaFile")
.normalizeLineEndings()
.withPathSensitivity(NAME_ONLY)
inputs
.files(collectCatalogTypings)
.withPropertyName("catalogDir")
.normalizeLineEndings()
.withPathSensitivity(NAME_ONLY)
inputs
.files(collectExternalTypings)
.withPropertyName("externalDir")
.normalizeLineEndings()
.withPathSensitivity(NAME_ONLY)
inputs
.dir(goodDir)
.withPropertyName("goodDir")
.normalizeLineEndings()
.withPathSensitivity(NAME_ONLY)
inputs
.dir(badDir)
.withPropertyName("badDir")
.normalizeLineEndings()
.withPathSensitivity(NAME_ONLY)
}