From a2e03e75dee411e915d9e07c953d8e6204640c5f Mon Sep 17 00:00:00 2001 From: Adam <897017+aSemy@users.noreply.github.com> Date: Wed, 9 Nov 2022 21:30:53 +0100 Subject: [PATCH 01/21] bump Gradle 7.5.1 --- build.gradle.kts | 2 +- gradle/wrapper/gradle-wrapper.properties | 2 +- gradlew | 0 3 files changed, 2 insertions(+), 2 deletions(-) mode change 100644 => 100755 gradlew diff --git a/build.gradle.kts b/build.gradle.kts index d5b1326e..a3126359 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -22,7 +22,7 @@ gitVersioning.apply { tasks.wrapper { - gradleVersion = "7.4.2" + gradleVersion = "7.5.1" distributionType = Wrapper.DistributionType.ALL } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 92f06b50..8fad3f5a 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew old mode 100644 new mode 100755 From cd394b15cdb5a09dedc071566b9fe3844199bc50 Mon Sep 17 00:00:00 2001 From: Adam <897017+aSemy@users.noreply.github.com> Date: Wed, 9 Nov 2022 21:31:54 +0100 Subject: [PATCH 02/21] create KxsTsGenBuildSettings, so TSCompile tests can be enabled/disabled with a flag --- .../buildsrc/config/KxsTsGenBuildSettings.kt | 18 ++++++++++++++++++ .../buildsrc/convention/subproject.gradle.kts | 5 ++++- docs/code/build.gradle.kts | 6 ++++-- 3 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 buildSrc/src/main/kotlin/buildsrc/config/KxsTsGenBuildSettings.kt diff --git a/buildSrc/src/main/kotlin/buildsrc/config/KxsTsGenBuildSettings.kt b/buildSrc/src/main/kotlin/buildsrc/config/KxsTsGenBuildSettings.kt new file mode 100644 index 00000000..304138f6 --- /dev/null +++ b/buildSrc/src/main/kotlin/buildsrc/config/KxsTsGenBuildSettings.kt @@ -0,0 +1,18 @@ +package buildsrc.config + +import org.gradle.api.provider.Provider +import org.gradle.api.provider.ProviderFactory + +abstract class KxsTsGenBuildSettings( + private val providers: ProviderFactory +) { + val enableTsCompileTests: Provider = + providers + .gradleProperty("kxs_ts_gen_enableTsCompileTests") + .map { it.toBoolean() } + .orElse(false) + + companion object { + const val NAME = "kxsTsGenSettings" + } +} diff --git a/buildSrc/src/main/kotlin/buildsrc/convention/subproject.gradle.kts b/buildSrc/src/main/kotlin/buildsrc/convention/subproject.gradle.kts index 2da6eb10..bb5c270a 100644 --- a/buildSrc/src/main/kotlin/buildsrc/convention/subproject.gradle.kts +++ b/buildSrc/src/main/kotlin/buildsrc/convention/subproject.gradle.kts @@ -1,6 +1,6 @@ package buildsrc.convention -import org.gradle.kotlin.dsl.base +import buildsrc.config.KxsTsGenBuildSettings plugins { base @@ -10,3 +10,6 @@ if (project != rootProject) { project.group = rootProject.group project.version = rootProject.version } + + +extensions.create(KxsTsGenBuildSettings.NAME) diff --git a/docs/code/build.gradle.kts b/docs/code/build.gradle.kts index 1b8b74c7..62599327 100644 --- a/docs/code/build.gradle.kts +++ b/docs/code/build.gradle.kts @@ -27,7 +27,7 @@ dependencies { testImplementation(libs.kotlinProcess) } -tasks.withType { +tasks.withType().configureEach { mustRunAfter(tasks.knit) kotlinOptions.freeCompilerArgs += listOf( "-opt-in=kotlinx.serialization.ExperimentalSerializationApi", @@ -54,5 +54,7 @@ tasks.withType().configureEach { dependsOn(tasks.knit) } tasks.test { // TSCompile tests are slow, they don't need to run every time - systemProperty("kotest.tags", "!TSCompile") + if (!kxsTsGenSettings.enableTsCompileTests.get()) { + systemProperty("kotest.tags", "!TSCompile") + } } From 5a6561bbd22e1c315a9de539072d4b87304ec4bd Mon Sep 17 00:00:00 2001 From: Adam <897017+aSemy@users.noreply.github.com> Date: Wed, 9 Nov 2022 21:32:09 +0100 Subject: [PATCH 03/21] create github workflows --- .github/workflows/gradle_task.yml | 61 +++++++++++++++++++++++++++++++ .github/workflows/tests.yml | 35 ++++++++++++++++++ 2 files changed, 96 insertions(+) create mode 100644 .github/workflows/gradle_task.yml create mode 100644 .github/workflows/tests.yml diff --git a/.github/workflows/gradle_task.yml b/.github/workflows/gradle_task.yml new file mode 100644 index 00000000..64e72100 --- /dev/null +++ b/.github/workflows/gradle_task.yml @@ -0,0 +1,61 @@ +name: Gradle Task +run-name: "Gradle Task ${{ inputs.gradle-task }} @ ${{ inputs.runs-on }}" + +# Reusable Workflow for running a Gradle task + +on: + workflow_dispatch: + + workflow_call: + inputs: + gradle-task: + description: "The Gradle task to run, including any flags" + required: true + type: string + runs-on: + description: "OSes to run the task on" + required: true + type: string + + +concurrency: + # note: the Workflow inputs are also included in the concurrency group + group: "${{ github.workflow }} ${{ join(inputs.*) }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}" + cancel-in-progress: true + + +permissions: + contents: read + + +jobs: + + run-task: + runs-on: ${{ inputs.runs-on }} + name: "./gradlew ${{ inputs.gradle-task}} @ ${{ inputs.runs-on }}" + timeout-minutes: 60 + steps: + - name: Checkout the repo + uses: actions/checkout@v3 + + - name: Setup JDK + uses: actions/setup-java@v3 + with: + distribution: temurin + java-version: 11 + + - uses: gradle/gradle-build-action@v2 + with: + gradle-home-cache-cleanup: true + + - name: Run ${{ inputs.gradle-task }} + run: >- + ./gradlew ${{ inputs.gradle-task }} + + - name: Upload build reports + if: failure() + uses: actions/upload-artifact@v3 + with: + name: build-report-${{ runner.os }}-${{ github.action }} + path: "**/build/reports/" + if-no-files-found: ignore diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 00000000..9d50bb26 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,35 @@ +name: Tests + +on: + pull_request: + workflow_dispatch: + workflow_call: + +concurrency: + group: "${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}" + cancel-in-progress: true + + +permissions: + contents: read + + +jobs: + + gradle-check: + name: "./gradlew ${{ matrix.target }} @ ${{ matrix.os }}" + strategy: + matrix: + os: [ ubuntu-latest, macos-11, windows-latest ] + uses: ./.github/workflows/gradle_task.yml + with: + runs-on: ${{ matrix.os }} + gradle-task: check + + + test-typescript-compile: + name: "./gradlew ${{ matrix.target }} @ ${{ matrix.os }}" + uses: ./.github/workflows/gradle_task.yml + with: + runs-on: ubuntu-latest + gradle-task: ":docs:code:test -Pkxs_ts_gen_enableTsCompileTests=true" From 7a1d8a4891816a8ae316c7713ffe01ddd2ea5966 Mon Sep 17 00:00:00 2001 From: Adam <897017+aSemy@users.noreply.github.com> Date: Wed, 9 Nov 2022 21:38:27 +0100 Subject: [PATCH 04/21] kotlin.mpp.stability.nowarn=true --- gradle.properties | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gradle.properties b/gradle.properties index 5df20500..aa0e2715 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,3 +5,5 @@ org.gradle.unsafe.configuration-cache-problems=warn # https://github.com/gradle/gradle/issues/20416 org.gradle.kotlin.dsl.precompiled.accessors.strict=true + +kotlin.mpp.stability.nowarn=true From f10f8b6b7b6afdf15161abe7c4bbb64075d8fc6c Mon Sep 17 00:00:00 2001 From: Adam <897017+aSemy@users.noreply.github.com> Date: Wed, 9 Nov 2022 21:40:25 +0100 Subject: [PATCH 05/21] bump kotlinx-kover --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index cb695474..314edde6 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -11,7 +11,7 @@ kotlinCompileTesting = "1.4.8" # https://github.com/tschuchortdev/kotl kotlinx-serialization = "1.4.0" # https://github.com/Kotlin/kotlinx.serialization/releases/ kotlinx-knit = "0.4.0" # https://github.com/Kotlin/kotlinx-knit/releases kotlinx-coroutines = "1.6.4" # https://github.com/Kotlin/kotlinx.coroutines/releases -kotlinx-kover = "0.5.1" # https://github.com/Kotlin/kotlinx-kover/releases +kotlinx-kover = "0.6.1" # https://github.com/Kotlin/kotlinx-kover/releases okio = "3.2.0" # https://search.maven.org/artifact/com.squareup.okio/okio From 67a1b1d6088236302f0017c2e6b31f7df31f276f Mon Sep 17 00:00:00 2001 From: Adam <897017+aSemy@users.noreply.github.com> Date: Wed, 9 Nov 2022 21:50:34 +0100 Subject: [PATCH 06/21] bump kotlin 1.7.21 --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 314edde6..fa2d74c2 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -3,7 +3,7 @@ jvmTarget = "11" kotlinTarget = "1.7" -kotlin = "1.7.20" # https://github.com/JetBrains/kotlin/releases +kotlin = "1.7.21" # https://github.com/JetBrains/kotlin/releases kotlinSymbolProcessing = "1.7.20-1.0.8" # https://github.com/google/ksp/releases kotlinCompileTesting = "1.4.8" # https://github.com/tschuchortdev/kotlin-compile-testing/releases From 1e4eda2979a9a42d11ebb97bd2cb66f4a38f873b Mon Sep 17 00:00:00 2001 From: Adam <897017+aSemy@users.noreply.github.com> Date: Wed, 9 Nov 2022 21:54:08 +0100 Subject: [PATCH 07/21] bump gradle-git-versioning-plugin --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index fa2d74c2..5b32cdee 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -22,7 +22,7 @@ kotlinProcess = "1.3.1" # https://github.com/pgreze/kotlin-proc classgraph = "4.8.147" # https://github.com/classgraph/classgraph/releases gradleNodePlugin = "3.5.0" # https://github.com/node-gradle/gradle-node-plugin/releases -gitVersioningPlugin = "6.3.4" # https://github.com/qoomon/gradle-git-versioning-plugin/releases +gitVersioningPlugin = "6.3.6" # https://github.com/qoomon/gradle-git-versioning-plugin/releases [libraries] From e8c7581a2ea1d7f630dd19ca9554b14d7d82b777 Mon Sep 17 00:00:00 2001 From: Adam <897017+aSemy@users.noreply.github.com> Date: Wed, 9 Nov 2022 21:58:45 +0100 Subject: [PATCH 08/21] tweak gradle props --- gradle.properties | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index aa0e2715..6ba3ec07 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,9 +1,13 @@ +org.gradle.jvmargs=-Dfile.encoding=UTF-8 -Xmx2g + org.gradle.parallel=true org.gradle.caching=true org.gradle.unsafe.configuration-cache=true org.gradle.unsafe.configuration-cache-problems=warn -# https://github.com/gradle/gradle/issues/20416 +# cache accessors - defaults to 'true' in Gradle 8.0 https://github.com/gradle/gradle/issues/20416 org.gradle.kotlin.dsl.precompiled.accessors.strict=true kotlin.mpp.stability.nowarn=true + +kxstsgen_enableTsCompileTests=false From ddc8d07430b7e326be0272dd7cee5ec4f6198556 Mon Sep 17 00:00:00 2001 From: Adam <897017+aSemy@users.noreply.github.com> Date: Wed, 9 Nov 2022 21:59:26 +0100 Subject: [PATCH 09/21] update property name kxstsgen_enableTsCompileTests --- .github/workflows/tests.yml | 2 +- .../src/main/kotlin/buildsrc/config/KxsTsGenBuildSettings.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 9d50bb26..06baba44 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -32,4 +32,4 @@ jobs: uses: ./.github/workflows/gradle_task.yml with: runs-on: ubuntu-latest - gradle-task: ":docs:code:test -Pkxs_ts_gen_enableTsCompileTests=true" + gradle-task: ":docs:code:test -Pkxstsgen_enableTsCompileTests=true" diff --git a/buildSrc/src/main/kotlin/buildsrc/config/KxsTsGenBuildSettings.kt b/buildSrc/src/main/kotlin/buildsrc/config/KxsTsGenBuildSettings.kt index 304138f6..417ee6e4 100644 --- a/buildSrc/src/main/kotlin/buildsrc/config/KxsTsGenBuildSettings.kt +++ b/buildSrc/src/main/kotlin/buildsrc/config/KxsTsGenBuildSettings.kt @@ -8,7 +8,7 @@ abstract class KxsTsGenBuildSettings( ) { val enableTsCompileTests: Provider = providers - .gradleProperty("kxs_ts_gen_enableTsCompileTests") + .gradleProperty("kxstsgen_enableTsCompileTests") .map { it.toBoolean() } .orElse(false) From a1b81012ea67917e330b40123f86a937702f566a Mon Sep 17 00:00:00 2001 From: Adam <897017+aSemy@users.noreply.github.com> Date: Wed, 9 Nov 2022 22:07:53 +0100 Subject: [PATCH 10/21] increase logging, disable fail-fast --- .github/workflows/tests.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 06baba44..5784b318 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -21,10 +21,12 @@ jobs: strategy: matrix: os: [ ubuntu-latest, macos-11, windows-latest ] + fail-fast: false uses: ./.github/workflows/gradle_task.yml with: runs-on: ${{ matrix.os }} - gradle-task: check + gradle-task: >- + check --info --stacktrace test-typescript-compile: @@ -32,4 +34,5 @@ jobs: uses: ./.github/workflows/gradle_task.yml with: runs-on: ubuntu-latest - gradle-task: ":docs:code:test -Pkxstsgen_enableTsCompileTests=true" + gradle-task: >- + :docs:code:test -Pkxstsgen_enableTsCompileTests=true --info --stacktrace From 75f438e323bb4835cdd25f00b1c624dec085c78e Mon Sep 17 00:00:00 2001 From: Adam <897017+aSemy@users.noreply.github.com> Date: Wed, 9 Nov 2022 22:15:21 +0100 Subject: [PATCH 11/21] binaries.executable() -> browser() --- modules/kxs-ts-gen-core/build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/kxs-ts-gen-core/build.gradle.kts b/modules/kxs-ts-gen-core/build.gradle.kts index 797157cd..9a394927 100644 --- a/modules/kxs-ts-gen-core/build.gradle.kts +++ b/modules/kxs-ts-gen-core/build.gradle.kts @@ -8,7 +8,7 @@ plugins { kotlin { js(IR) { - binaries.executable() + browser() nodejs() } From 767ce0c8879f92651cf8a21f19edf1d91fe07f59 Mon Sep 17 00:00:00 2001 From: Adam <897017+aSemy@users.noreply.github.com> Date: Wed, 9 Nov 2022 22:46:48 +0100 Subject: [PATCH 12/21] add rootProject.name to buildSrc Gradle settings --- buildSrc/settings.gradle.kts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/buildSrc/settings.gradle.kts b/buildSrc/settings.gradle.kts index eb552c75..be9ce4fc 100644 --- a/buildSrc/settings.gradle.kts +++ b/buildSrc/settings.gradle.kts @@ -1,3 +1,5 @@ +rootProject.name = "buildSrc" + apply(from = "./repositories.settings.gradle.kts") dependencyResolutionManagement { From ac36d0286bfa3496d366e24270644a1a44a5138e Mon Sep 17 00:00:00 2001 From: Adam <897017+aSemy@users.noreply.github.com> Date: Wed, 9 Nov 2022 22:47:35 +0100 Subject: [PATCH 13/21] bump Kotlin language level to 1.7, standardise Jvm target to 11 --- .../buildsrc/convention/kotlin-jvm.gradle.kts | 8 ++--- .../buildsrc/convention/kotlin-mpp.gradle.kts | 29 +++++++++++++++---- .../buildsrc/convention/node.gradle.kts | 2 +- modules/kxs-ts-gen-core/build.gradle.kts | 8 ----- 4 files changed, 29 insertions(+), 18 deletions(-) diff --git a/buildSrc/src/main/kotlin/buildsrc/convention/kotlin-jvm.gradle.kts b/buildSrc/src/main/kotlin/buildsrc/convention/kotlin-jvm.gradle.kts index d58f6526..102fb78a 100644 --- a/buildSrc/src/main/kotlin/buildsrc/convention/kotlin-jvm.gradle.kts +++ b/buildSrc/src/main/kotlin/buildsrc/convention/kotlin-jvm.gradle.kts @@ -31,11 +31,11 @@ java { withSourcesJar() } -tasks.withType { +tasks.withType().configureEach { kotlinOptions { - jvmTarget = "1.8" - apiVersion = "1.6" - languageVersion = "1.6" + jvmTarget = "11" + apiVersion = "1.7" + languageVersion = "1.7" } kotlinOptions.freeCompilerArgs += listOf( diff --git a/buildSrc/src/main/kotlin/buildsrc/convention/kotlin-mpp.gradle.kts b/buildSrc/src/main/kotlin/buildsrc/convention/kotlin-mpp.gradle.kts index aa900d74..78e70f22 100644 --- a/buildSrc/src/main/kotlin/buildsrc/convention/kotlin-mpp.gradle.kts +++ b/buildSrc/src/main/kotlin/buildsrc/convention/kotlin-mpp.gradle.kts @@ -1,6 +1,9 @@ package buildsrc.convention import buildsrc.config.relocateKotlinJsStore +import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension +import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinJvmCompilation +import org.jetbrains.kotlin.gradle.targets.jvm.KotlinJvmTarget plugins { @@ -13,12 +16,28 @@ plugins { relocateKotlinJsStore() -kotlin { - targets.all { - compilations.all { +//kotlin { +extensions.configure { + targets.configureEach { + compilations.configureEach { kotlinOptions { - languageVersion = "1.6" - apiVersion = "1.6" + languageVersion = "1.7" + apiVersion = "1.7" + } + if (this is KotlinJvmCompilation) { + } + } + } + + targets.withType { + compilations.configureEach { + kotlinOptions { + jvmTarget = "11" + } + } + testRuns.configureEach { + executionTask.configure { + useJUnitPlatform() } } } diff --git a/buildSrc/src/main/kotlin/buildsrc/convention/node.gradle.kts b/buildSrc/src/main/kotlin/buildsrc/convention/node.gradle.kts index 8b8af429..fd0da63f 100644 --- a/buildSrc/src/main/kotlin/buildsrc/convention/node.gradle.kts +++ b/buildSrc/src/main/kotlin/buildsrc/convention/node.gradle.kts @@ -19,7 +19,7 @@ node { yarnWorkDir.set(rootGradleDir.dir("yarn")) } -tasks.withType { +tasks.withType().configureEach { val npmInstallDir = tasks.npmSetup.map { it.npmDir.get().asFile.canonicalPath } inputs.dir(npmInstallDir) diff --git a/modules/kxs-ts-gen-core/build.gradle.kts b/modules/kxs-ts-gen-core/build.gradle.kts index 9a394927..d399804b 100644 --- a/modules/kxs-ts-gen-core/build.gradle.kts +++ b/modules/kxs-ts-gen-core/build.gradle.kts @@ -13,15 +13,7 @@ kotlin { } jvm { - compilations.all { - kotlinOptions { - jvmTarget = "1.8" - } - } withJava() - testRuns["test"].executionTask.configure { - useJUnitPlatform() - } } // publishing { From cd201a4fa361b70551c1f0a26c3651a9558d6d04 Mon Sep 17 00:00:00 2001 From: Adam <897017+aSemy@users.noreply.github.com> Date: Wed, 9 Nov 2022 22:59:40 +0100 Subject: [PATCH 14/21] rm java-library from kotlin-mpp --- .../src/main/kotlin/buildsrc/convention/kotlin-mpp.gradle.kts | 1 - 1 file changed, 1 deletion(-) diff --git a/buildSrc/src/main/kotlin/buildsrc/convention/kotlin-mpp.gradle.kts b/buildSrc/src/main/kotlin/buildsrc/convention/kotlin-mpp.gradle.kts index 78e70f22..d3f0581c 100644 --- a/buildSrc/src/main/kotlin/buildsrc/convention/kotlin-mpp.gradle.kts +++ b/buildSrc/src/main/kotlin/buildsrc/convention/kotlin-mpp.gradle.kts @@ -9,7 +9,6 @@ import org.jetbrains.kotlin.gradle.targets.jvm.KotlinJvmTarget plugins { id("buildsrc.convention.subproject") kotlin("multiplatform") - `java-library` } From 59f4c4c1b4cb2af8575d1ef44ddefafd4abae512 Mon Sep 17 00:00:00 2001 From: Adam <897017+aSemy@users.noreply.github.com> Date: Wed, 9 Nov 2022 23:00:25 +0100 Subject: [PATCH 15/21] setup java-test-fixtures, change 'example' to be in 'main' source set --- docs/code/build.gradle.kts | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/docs/code/build.gradle.kts b/docs/code/build.gradle.kts index 62599327..553a3873 100644 --- a/docs/code/build.gradle.kts +++ b/docs/code/build.gradle.kts @@ -5,26 +5,25 @@ plugins { buildsrc.convention.node kotlin("plugin.serialization") id("org.jetbrains.kotlinx.knit") + `java-test-fixtures` } dependencies { implementation(platform(projects.modules.versionsPlatform)) - implementation(projects.modules.kxsTsGenCore) - implementation(libs.kotlinx.serialization.core) implementation(libs.kotlinx.serialization.json) - implementation(libs.kotlinx.coroutines.core) - implementation(libs.kotlinx.knit) - implementation(kotlin("reflect")) testImplementation(kotlin("test")) - testImplementation(libs.kotlinx.knit.test) - testImplementation(libs.kotlinProcess) + + testFixturesImplementation(platform(projects.modules.versionsPlatform)) + testFixturesImplementation(libs.kotlinProcess) + testFixturesImplementation(libs.kotest.frameworkEngine) + testFixturesImplementation(libs.kotest.assertionsCore) } tasks.withType().configureEach { @@ -34,12 +33,16 @@ tasks.withType().configureEach { ) } +sourceSets.main { + java.srcDirs("example") +} + sourceSets.test { - java.srcDirs( - "example", - "test", - "util", - ) + java.srcDirs("test") +} + +sourceSets.testFixtures { + java.srcDirs("util") } knit { From 391c49f324b423bde5f10830b5beb7a1d0f1cbbd Mon Sep 17 00:00:00 2001 From: Adam <897017+aSemy@users.noreply.github.com> Date: Wed, 9 Nov 2022 23:00:43 +0100 Subject: [PATCH 16/21] only enable NPM setup when TSCompile is enabled --- .../src/main/kotlin/buildsrc/convention/node.gradle.kts | 9 --------- docs/code/build.gradle.kts | 6 +++++- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/buildSrc/src/main/kotlin/buildsrc/convention/node.gradle.kts b/buildSrc/src/main/kotlin/buildsrc/convention/node.gradle.kts index fd0da63f..6a9a1f09 100644 --- a/buildSrc/src/main/kotlin/buildsrc/convention/node.gradle.kts +++ b/buildSrc/src/main/kotlin/buildsrc/convention/node.gradle.kts @@ -18,12 +18,3 @@ node { npmWorkDir.set(rootGradleDir.dir("npm")) yarnWorkDir.set(rootGradleDir.dir("yarn")) } - -tasks.withType().configureEach { - val npmInstallDir = tasks.npmSetup.map { it.npmDir.get().asFile.canonicalPath } - inputs.dir(npmInstallDir) - - doFirst { - environment("NPM_INSTALL_DIR", npmInstallDir.get()) - } -} diff --git a/docs/code/build.gradle.kts b/docs/code/build.gradle.kts index 553a3873..da2b402c 100644 --- a/docs/code/build.gradle.kts +++ b/docs/code/build.gradle.kts @@ -57,7 +57,11 @@ tasks.withType().configureEach { dependsOn(tasks.knit) } tasks.test { // TSCompile tests are slow, they don't need to run every time - if (!kxsTsGenSettings.enableTsCompileTests.get()) { + if (kxsTsGenSettings.enableTsCompileTests.get()) { + val npmInstallDir = tasks.npmSetup.map { it.npmDir.get().asFile.canonicalPath } + inputs.dir(npmInstallDir) + environment("NPM_INSTALL_DIR", npmInstallDir.get()) + } else { systemProperty("kotest.tags", "!TSCompile") } } From 808965bb93b9774442b297f9595d316104282c00 Mon Sep 17 00:00:00 2001 From: Adam <897017+aSemy@users.noreply.github.com> Date: Wed, 9 Nov 2022 23:05:48 +0100 Subject: [PATCH 17/21] update kotlin-process --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 5b32cdee..f2ddda9f 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -17,7 +17,7 @@ okio = "3.2.0" # https://search.maven.org/artifact/com kotest = "5.5.4" # https://github.com/kotest/kotest/releases -kotlinProcess = "1.3.1" # https://github.com/pgreze/kotlin-process/releases +kotlinProcess = "1.4" # https://github.com/pgreze/kotlin-process/releases classgraph = "4.8.147" # https://github.com/classgraph/classgraph/releases From 3205f7b6885c255bb9a13461e7b28344594d24d4 Mon Sep 17 00:00:00 2001 From: Adam <897017+aSemy@users.noreply.github.com> Date: Wed, 9 Nov 2022 23:15:24 +0100 Subject: [PATCH 18/21] disable kotest plugin https://github.com/kotest/kotest/issues/3141 --- modules/kxs-ts-gen-core/build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/kxs-ts-gen-core/build.gradle.kts b/modules/kxs-ts-gen-core/build.gradle.kts index d399804b..17bd6a2a 100644 --- a/modules/kxs-ts-gen-core/build.gradle.kts +++ b/modules/kxs-ts-gen-core/build.gradle.kts @@ -2,7 +2,7 @@ plugins { buildsrc.convention.`kotlin-mpp` buildsrc.convention.`maven-publish` kotlin("plugin.serialization") - id("io.kotest.multiplatform") + // id("io.kotest.multiplatform") // Kotest does not support nested JS tests https://github.com/kotest/kotest/issues/3141 } kotlin { From 8d43c7334e3930a79a65f3f93cd5a29086c561e1 Mon Sep 17 00:00:00 2001 From: Adam <897017+aSemy@users.noreply.github.com> Date: Wed, 9 Nov 2022 23:18:12 +0100 Subject: [PATCH 19/21] use embeddedKotlinVersion shortcut --- buildSrc/build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index 1858ddc4..01f1aad6 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -3,7 +3,7 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile plugins { idea `kotlin-dsl` - kotlin("jvm") version "1.6.21" + kotlin("jvm") version embeddedKotlinVersion } From 30fc3f11ef8a426ed4652428bc4bdaf7fd0c629b Mon Sep 17 00:00:00 2001 From: Adam <897017+aSemy@users.noreply.github.com> Date: Wed, 9 Nov 2022 23:18:33 +0100 Subject: [PATCH 20/21] improve ts compile testing --- .../util/dev/adamko/kxstsgen/util/processMatchers.kt | 9 ++++++--- .../util/dev/adamko/kxstsgen/util/typescriptCompile.kt | 8 +++++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/docs/code/util/dev/adamko/kxstsgen/util/processMatchers.kt b/docs/code/util/dev/adamko/kxstsgen/util/processMatchers.kt index 5cacf484..f47800fd 100644 --- a/docs/code/util/dev/adamko/kxstsgen/util/processMatchers.kt +++ b/docs/code/util/dev/adamko/kxstsgen/util/processMatchers.kt @@ -47,10 +47,13 @@ suspend fun String?.shouldTypeScriptCompile( file.writeText(src) val (process, output) = typescriptCompile(file) - output.joinToString("\n").asClue { log -> + + val outputPretty = output.joinToString("\n").prependIndent(" > ") + + outputPretty.asClue { log -> withClue("exit code should be 0") { process shouldBeExactly 0 } - log.shouldNotBeEmpty() - log shouldContainIgnoringCase "npx: installed" + withClue("log should not be empty") { log.shouldNotBeEmpty() } +// log shouldContainIgnoringCase "npx: installed" log shouldNotContain "error TS" } diff --git a/docs/code/util/dev/adamko/kxstsgen/util/typescriptCompile.kt b/docs/code/util/dev/adamko/kxstsgen/util/typescriptCompile.kt index ef2c9880..659961db 100644 --- a/docs/code/util/dev/adamko/kxstsgen/util/typescriptCompile.kt +++ b/docs/code/util/dev/adamko/kxstsgen/util/typescriptCompile.kt @@ -33,8 +33,8 @@ private val npxCmd: String by lazy { // this is untested on non-Windows val hostOS = System.getProperty("os.name").lowercase() val cmd = when { - "windows" in hostOS -> "npx.cmd" - else -> "npx" + "win" in hostOS -> "npx.cmd" + else -> "bin/npx" } npmInstallDir.resolve(cmd).invariantSeparatorsPathString } @@ -42,5 +42,7 @@ private val npxCmd: String by lazy { // must be set by Gradle private val npmInstallDir: Path by lazy { - Path.of(System.getenv("NPM_INSTALL_DIR")) + Path.of( + System.getenv()["NPM_INSTALL_DIR"] ?: error("NPM_INSTALL_DIR is not set") + ) } From 7dd95b14683774a02dcc21a29c5d3a599e02eebd Mon Sep 17 00:00:00 2001 From: Adam <897017+aSemy@users.noreply.github.com> Date: Wed, 9 Nov 2022 23:27:56 +0100 Subject: [PATCH 21/21] combine TS compile tests in matrix --- .github/workflows/tests.yml | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 5784b318..c5550c7d 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -21,18 +21,10 @@ jobs: strategy: matrix: os: [ ubuntu-latest, macos-11, windows-latest ] + tsCompileTests: [ true, false ] fail-fast: false uses: ./.github/workflows/gradle_task.yml with: runs-on: ${{ matrix.os }} gradle-task: >- - check --info --stacktrace - - - test-typescript-compile: - name: "./gradlew ${{ matrix.target }} @ ${{ matrix.os }}" - uses: ./.github/workflows/gradle_task.yml - with: - runs-on: ubuntu-latest - gradle-task: >- - :docs:code:test -Pkxstsgen_enableTsCompileTests=true --info --stacktrace + check -Pkxstsgen_enableTsCompileTests=${{ matrix.tsCompileTests }} --info --stacktrace