Skip to content

Commit eeb0a3b

Browse files
authored
Merge branch 'main' into add-smoke-ui-tests
2 parents e1a771e + 2f9c761 commit eeb0a3b

File tree

80 files changed

+542
-15147
lines changed

Some content is hidden

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

80 files changed

+542
-15147
lines changed

.github/workflows/build.main.kts

Lines changed: 48 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,25 @@
11
#!/usr/bin/env kotlin
22
@file:Repository("https://repo1.maven.org/maven2/")
3-
@file:DependsOn("io.github.typesafegithub:github-workflows-kt:1.15.0")
3+
@file:DependsOn("io.github.typesafegithub:github-workflows-kt:3.0.1")
44

5-
@file:Repository("https://github-workflows-kt-bindings.colman.com.br/binding/")
5+
@file:Repository("https://bindings.krzeminski.it")
66
@file:DependsOn("actions:checkout:v4")
7-
@file:DependsOn("gradle:actions__setup-gradle:v3")
7+
@file:DependsOn("gradle:actions__setup-gradle:v4")
88

99
import io.github.typesafegithub.workflows.actions.actions.Checkout
1010
import io.github.typesafegithub.workflows.actions.gradle.ActionsSetupGradle
1111
import io.github.typesafegithub.workflows.domain.RunnerType
1212
import io.github.typesafegithub.workflows.domain.triggers.PullRequest
1313
import io.github.typesafegithub.workflows.domain.triggers.Push
1414
import io.github.typesafegithub.workflows.dsl.workflow
15-
import io.github.typesafegithub.workflows.yaml.writeToFile
1615

1716
workflow(
1817
name = "Build",
1918
on = listOf(
2019
Push(branches = listOf("main")),
2120
PullRequest(),
2221
),
23-
sourceFile = __FILE__.toPath(),
22+
sourceFile = __FILE__,
2423
) {
2524
job(
2625
id = "build",
@@ -30,4 +29,47 @@ workflow(
3029
uses(action = ActionsSetupGradle())
3130
run(command = "./gradlew build")
3231
}
33-
}.writeToFile()
32+
33+
job(
34+
id = "build_kotlin_scripts",
35+
name = "Build Kotlin scripts",
36+
runsOn = RunnerType.UbuntuLatest,
37+
) {
38+
uses(action = Checkout())
39+
run(
40+
command = """
41+
find -name *.main.kts -print0 | while read -d ${'$'}'\0' file
42+
do
43+
echo "Compiling ${'$'}file..."
44+
kotlinc -Werror -Xallow-any-scripts-in-source-roots -Xuse-fir-lt=false "${'$'}file"
45+
done
46+
""".trimIndent()
47+
)
48+
}
49+
50+
51+
job(
52+
id = "workflows_consistency_check",
53+
name = "Run consistency check on all GitHub workflows",
54+
runsOn = RunnerType.UbuntuLatest,
55+
) {
56+
uses(action = Checkout())
57+
run(command = "cd .github/workflows")
58+
run(
59+
name = "Regenerate all workflow YAMLs",
60+
command = """
61+
find -name "*.main.kts" -print0 | while read -d ${'$'}'\0' file
62+
do
63+
if [ -x "${'$'}file" ]; then
64+
echo "Regenerating ${'$'}file..."
65+
(${'$'}file)
66+
fi
67+
done
68+
""".trimIndent(),
69+
)
70+
run(
71+
name = "Check if some file is different after regeneration",
72+
command = "git diff --exit-code .",
73+
)
74+
}
75+
}

.github/workflows/build.yaml

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,44 @@ jobs:
3030
- id: 'step-0'
3131
uses: 'actions/checkout@v4'
3232
- id: 'step-1'
33-
uses: 'gradle/actions/setup-gradle@v3'
33+
uses: 'gradle/actions/setup-gradle@v4'
3434
- id: 'step-2'
3535
run: './gradlew build'
36+
build_kotlin_scripts:
37+
name: 'Build Kotlin scripts'
38+
runs-on: 'ubuntu-latest'
39+
needs:
40+
- 'check_yaml_consistency'
41+
steps:
42+
- id: 'step-0'
43+
uses: 'actions/checkout@v4'
44+
- id: 'step-1'
45+
run: |-
46+
find -name *.main.kts -print0 | while read -d $'\0' file
47+
do
48+
echo "Compiling $file..."
49+
kotlinc -Werror -Xallow-any-scripts-in-source-roots -Xuse-fir-lt=false "$file"
50+
done
51+
workflows_consistency_check:
52+
name: 'Run consistency check on all GitHub workflows'
53+
runs-on: 'ubuntu-latest'
54+
needs:
55+
- 'check_yaml_consistency'
56+
steps:
57+
- id: 'step-0'
58+
uses: 'actions/checkout@v4'
59+
- id: 'step-1'
60+
run: 'cd .github/workflows'
61+
- id: 'step-2'
62+
name: 'Regenerate all workflow YAMLs'
63+
run: |-
64+
find -name "*.main.kts" -print0 | while read -d $'\0' file
65+
do
66+
if [ -x "$file" ]; then
67+
echo "Regenerating $file..."
68+
($file)
69+
fi
70+
done
71+
- id: 'step-3'
72+
name: 'Check if some file is different after regeneration'
73+
run: 'git diff --exit-code .'

.github/workflows/deploy.main.kts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#!/usr/bin/env kotlin
22
@file:Repository("https://repo1.maven.org/maven2/")
3-
@file:DependsOn("io.github.typesafegithub:github-workflows-kt:1.15.0")
3+
@file:DependsOn("io.github.typesafegithub:github-workflows-kt:3.0.1")
44

5-
@file:Repository("https://github-workflows-kt-bindings.colman.com.br/binding/")
5+
@file:Repository("https://bindings.krzeminski.it")
66
@file:DependsOn("actions:checkout:v4")
7-
@file:DependsOn("gradle:actions__setup-gradle:v3")
7+
@file:DependsOn("gradle:actions__setup-gradle:v4")
88
@file:DependsOn("actions:configure-pages:v5")
99
@file:DependsOn("actions:upload-pages-artifact:v3")
1010
@file:DependsOn("actions:deploy-pages:v4")
@@ -20,12 +20,11 @@ import io.github.typesafegithub.workflows.domain.Permission
2020
import io.github.typesafegithub.workflows.domain.RunnerType
2121
import io.github.typesafegithub.workflows.domain.triggers.Push
2222
import io.github.typesafegithub.workflows.dsl.workflow
23-
import io.github.typesafegithub.workflows.yaml.writeToFile
2423

2524
workflow(
2625
name = "Deploy",
2726
on = listOf(Push(branches = listOf("main"))),
28-
sourceFile = __FILE__.toPath(),
27+
sourceFile = __FILE__,
2928
permissions = mapOf(
3029
Permission.Contents to Mode.Read,
3130
Permission.Pages to Mode.Write,
@@ -49,4 +48,4 @@ workflow(
4948
))
5049
uses(action = DeployPages())
5150
}
52-
}.writeToFile()
51+
}

.github/workflows/deploy.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
- id: 'step-0'
3636
uses: 'actions/checkout@v4'
3737
- id: 'step-1'
38-
uses: 'gradle/actions/setup-gradle@v3'
38+
uses: 'gradle/actions/setup-gradle@v4'
3939
- id: 'step-2'
4040
run: './gradlew wasmJsBrowserDistribution'
4141
- id: 'step-3'

composeApp/build.gradle.kts

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1+
import org.jetbrains.compose.desktop.application.dsl.TargetFormat
12
import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl
23
import org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpackConfig
34

45
plugins {
56
alias(libs.plugins.kotlinMultiplatform)
67
alias(libs.plugins.composeCompiler)
78
alias(libs.plugins.jetbrainsCompose)
8-
kotlin("plugin.serialization") version "2.0.0"
9+
alias(libs.plugins.kotlinxSerialization)
910
}
1011

1112
kotlin {
@@ -25,17 +26,33 @@ kotlin {
2526
}
2627
binaries.executable()
2728
}
28-
29+
30+
jvm("desktop")
31+
2932
sourceSets {
33+
val wasmJsMain by getting {
34+
dependencies {
35+
implementation(libs.ktor.client.js)
36+
}
37+
}
38+
39+
val desktopMain by getting {
40+
dependencies {
41+
implementation(compose.desktop.currentOs)
42+
implementation(libs.kotlinx.coroutines.swing)
43+
implementation(libs.ktor.client.cio)
44+
}
45+
}
46+
3047
commonMain.dependencies {
3148
implementation(compose.runtime)
3249
implementation(compose.foundation)
3350
implementation(compose.material)
3451
implementation(compose.ui)
3552
implementation(compose.components.resources)
3653
implementation(compose.components.uiToolingPreview)
37-
implementation("io.ktor:ktor-client-core:3.0.0-wasm2")
38-
implementation("com.charleskorn.kaml:kaml")
54+
implementation(libs.ktor.client.core)
55+
implementation(libs.kaml)
3956
}
4057

4158
commonTest.dependencies {
@@ -50,3 +67,14 @@ kotlin {
5067
compose.experimental {
5168
web.application {}
5269
}
70+
compose.desktop {
71+
application {
72+
mainClass = "MainKt"
73+
74+
nativeDistributions {
75+
targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb)
76+
packageName = "it.krzeminski.githubactionstypingeditor"
77+
packageVersion = "1.0.0"
78+
}
79+
}
80+
}
Lines changed: 53 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import androidx.compose.foundation.layout.Column
2+
import androidx.compose.foundation.layout.Row
23
import androidx.compose.foundation.layout.Spacer
34
import androidx.compose.foundation.layout.fillMaxWidth
45
import androidx.compose.foundation.layout.height
@@ -12,25 +13,22 @@ import androidx.compose.ui.Alignment
1213
import androidx.compose.ui.Modifier
1314
import androidx.compose.ui.text.font.FontWeight
1415
import androidx.compose.ui.unit.dp
15-
import com.charleskorn.kaml.Yaml
1616
import io.ktor.client.HttpClient
17-
import io.ktor.client.call.body
18-
import io.ktor.client.request.get
19-
import kotlinx.serialization.Serializable
20-
import kotlinx.serialization.decodeFromString
2117

2218
val client = HttpClient()
2319

2420
@Composable
2521
fun App() {
2622
MaterialTheme {
2723
var actionCoords by remember { mutableStateOf("actions/checkout@v4") }
28-
var manifestYaml by remember { mutableStateOf("<manifest>") }
24+
var manifest: Metadata? by remember { mutableStateOf(null) }
25+
var typingFromAction: Typing? by remember { mutableStateOf(null) }
26+
var typingFromCatalog: Typing? by remember { mutableStateOf(null) }
2927

3028
LaunchedEffect(actionCoords) {
31-
val actionManifestYaml = client.get(urlString = "https://raw.githubusercontent.com/${actionCoords.replace("@", "/")}/action.yml")
32-
.body<String>()
33-
manifestYaml = actionManifestYaml
29+
manifest = fetchManifest(actionCoords)
30+
typingFromAction = fetchTypingFromAction(actionCoords)
31+
typingFromCatalog = fetchTypingFromCatalog(actionCoords)
3432
}
3533

3634
Column(Modifier.fillMaxWidth(), horizontalAlignment = Alignment.CenterHorizontally) {
@@ -41,54 +39,59 @@ fun App() {
4139
)
4240
Spacer(Modifier.height(10.dp))
4341

44-
val myYaml = Yaml(configuration = Yaml.default.configuration.copy(strictMode = false))
45-
val parsedYaml = try {
46-
myYaml.decodeFromString<Metadata>(manifestYaml)
47-
} catch (e: Exception) {
48-
println("Exception: $e")
49-
null
42+
Row {
43+
manifest(manifest)
44+
typing(typingFromAction, source = "action")
45+
typing(typingFromCatalog, source = "catalog")
5046
}
47+
}
48+
}
49+
}
5150

52-
Column(Modifier.verticalScroll(rememberScrollState())) {
53-
Text("Inputs", fontWeight = FontWeight.Bold)
54-
if (parsedYaml?.inputs?.isEmpty() == true) {
55-
Text("<none>")
56-
}
57-
parsedYaml?.inputs?.forEach {
58-
Text(it.key)
59-
}
51+
@Composable
52+
private fun manifest(manifest: Metadata?) {
53+
Column(Modifier.verticalScroll(rememberScrollState())) {
54+
Text("Manifest:")
55+
Text("Inputs", fontWeight = FontWeight.Bold)
56+
if (manifest?.inputs?.isEmpty() == true) {
57+
Text("<none>")
58+
}
59+
manifest?.inputs?.forEach {
60+
Text(it.key)
61+
}
6062

61-
Spacer(Modifier.height(10.dp))
63+
Spacer(Modifier.height(10.dp))
6264

63-
Text("Outputs", fontWeight = FontWeight.Bold)
64-
if (parsedYaml?.outputs?.isEmpty() == true) {
65-
Text("<none>")
66-
}
67-
parsedYaml?.outputs?.forEach {
68-
Text(it.key)
69-
}
70-
}
65+
Text("Outputs", fontWeight = FontWeight.Bold)
66+
if (manifest?.outputs?.isEmpty() == true) {
67+
Text("<none>")
68+
}
69+
manifest?.outputs?.forEach {
70+
Text(it.key)
7171
}
7272
}
7373
}
7474

75-
@Serializable
76-
data class Metadata(
77-
val name: String,
78-
val description: String,
79-
val inputs: Map<String, Input> = emptyMap(),
80-
val outputs: Map<String, Output> = emptyMap(),
81-
)
75+
@Composable
76+
private fun typing(typing: Typing?, source: String) {
77+
Column(Modifier.verticalScroll(rememberScrollState())) {
78+
Text("Typing from $source:")
79+
Text("Inputs", fontWeight = FontWeight.Bold)
80+
if (typing?.inputs?.isEmpty() == true) {
81+
Text("<none>")
82+
}
83+
typing?.inputs?.forEach {
84+
Text("${it.key}: ${it.value.type}")
85+
}
8286

83-
@Serializable
84-
data class Input(
85-
val description: String = "",
86-
val default: String? = null,
87-
val required: Boolean? = null,
88-
val deprecationMessage: String? = null,
89-
)
87+
Spacer(Modifier.height(10.dp))
9088

91-
@Serializable
92-
data class Output(
93-
val description: String = "",
94-
)
89+
Text("Outputs", fontWeight = FontWeight.Bold)
90+
if (typing?.outputs?.isEmpty() == true) {
91+
Text("<none>")
92+
}
93+
typing?.outputs?.forEach {
94+
Text("${it.key}: ${it.value.type}")
95+
}
96+
}
97+
}

0 commit comments

Comments
 (0)