From b29e214427da48127bcdd3512eacfc7357b7d4f7 Mon Sep 17 00:00:00 2001 From: Andrey Kuleshov Date: Sat, 18 Mar 2023 23:07:28 +0100 Subject: [PATCH 1/5] Test to check regression #189 ### What's done: - simple test --- .../akuleshov7/ktoml/file/Regression189.kt | 33 +++++++++++++++++++ .../ktoml/file/TomlFileParserTest.kt | 6 ++-- ...ssion2.toml => class_cast_regression.toml} | 0 .../resources/class_cast_regression1.toml | 4 --- .../commonTest/resources/regression_189.toml | 5 +++ 5 files changed, 41 insertions(+), 7 deletions(-) create mode 100644 ktoml-file/src/commonTest/kotlin/com/akuleshov7/ktoml/file/Regression189.kt rename ktoml-file/src/commonTest/resources/{class_cast_regression2.toml => class_cast_regression.toml} (100%) delete mode 100644 ktoml-file/src/commonTest/resources/class_cast_regression1.toml create mode 100644 ktoml-file/src/commonTest/resources/regression_189.toml diff --git a/ktoml-file/src/commonTest/kotlin/com/akuleshov7/ktoml/file/Regression189.kt b/ktoml-file/src/commonTest/kotlin/com/akuleshov7/ktoml/file/Regression189.kt new file mode 100644 index 00000000..9c3a874b --- /dev/null +++ b/ktoml-file/src/commonTest/kotlin/com/akuleshov7/ktoml/file/Regression189.kt @@ -0,0 +1,33 @@ +package com.akuleshov7.ktoml.file + +import kotlinx.serialization.ExperimentalSerializationApi +import kotlinx.serialization.Serializable +import kotlinx.serialization.serializer +import kotlin.test.Test +import kotlin.test.assertEquals + +class Regression189 { + @Serializable + data class ServerSettings( + val email: String, + val url: String, + val deviceId: String, + val bearerToken: String?, + val refreshToken: String?, + ) + + @ExperimentalSerializationApi + @Test + fun regressionCastTest() { + val file = "src/commonTest/resources/regression_189.toml" + val parsedResult = TomlFileReader.decodeFromFile(serializer(), file) + assertEquals(ServerSettings( + "test5", + "http://localhost:8080", + "50694ed7-a93f-4713-9e55-4d512ce2e4db", + "a8DkRGThvz13cmVubFdgX0CsoLfAtXcBvyxiKCPY34FEt3UDmPBkMKFRk4iKRuRp", + "20NSBgKB2B9C2u2toAuiPqlaZgfEWJ4m50562YK9w575SNt31CWrjcpwqeiDCYhZ"), + parsedResult + ) + } +} \ No newline at end of file diff --git a/ktoml-file/src/commonTest/kotlin/com/akuleshov7/ktoml/file/TomlFileParserTest.kt b/ktoml-file/src/commonTest/kotlin/com/akuleshov7/ktoml/file/TomlFileParserTest.kt index 13cdb215..48089de2 100644 --- a/ktoml-file/src/commonTest/kotlin/com/akuleshov7/ktoml/file/TomlFileParserTest.kt +++ b/ktoml-file/src/commonTest/kotlin/com/akuleshov7/ktoml/file/TomlFileParserTest.kt @@ -92,8 +92,8 @@ class TomlFileParserTest { @ExperimentalSerializationApi @Test - fun regressionCast2Test() { - val file = "src/commonTest/resources/class_cast_regression2.toml" + fun regressionCastTest() { + val file = "src/commonTest/resources/class_cast_regression.toml" val parsedResult = TomlFileReader.decodeFromFile(serializer(), file) assertEquals(RegressionTest(null, 1, 2, null), parsedResult) } @@ -101,7 +101,7 @@ class TomlFileParserTest { @ExperimentalSerializationApi @Test fun regressionPartialTest() { - val file = "src/commonTest/resources/class_cast_regression2.toml" + val file = "src/commonTest/resources/class_cast_regression.toml" val parsedResult = TomlFileReader.decodeFromFile(serializer(), file) assertEquals(RegressionTest(null, 1, 2, null), parsedResult) } diff --git a/ktoml-file/src/commonTest/resources/class_cast_regression2.toml b/ktoml-file/src/commonTest/resources/class_cast_regression.toml similarity index 100% rename from ktoml-file/src/commonTest/resources/class_cast_regression2.toml rename to ktoml-file/src/commonTest/resources/class_cast_regression.toml diff --git a/ktoml-file/src/commonTest/resources/class_cast_regression1.toml b/ktoml-file/src/commonTest/resources/class_cast_regression1.toml deleted file mode 100644 index c3c67301..00000000 --- a/ktoml-file/src/commonTest/resources/class_cast_regression1.toml +++ /dev/null @@ -1,4 +0,0 @@ -a = 1 -b = null -c = 2 -d = null diff --git a/ktoml-file/src/commonTest/resources/regression_189.toml b/ktoml-file/src/commonTest/resources/regression_189.toml new file mode 100644 index 00000000..2929d953 --- /dev/null +++ b/ktoml-file/src/commonTest/resources/regression_189.toml @@ -0,0 +1,5 @@ +email = "test5" +url = "http://localhost:8080" +deviceId = "50694ed7-a93f-4713-9e55-4d512ce2e4db" +bearerToken = "a8DkRGThvz13cmVubFdgX0CsoLfAtXcBvyxiKCPY34FEt3UDmPBkMKFRk4iKRuRp" +refreshToken = "20NSBgKB2B9C2u2toAuiPqlaZgfEWJ4m50562YK9w575SNt31CWrjcpwqeiDCYhZ" From 838e9413ab90cdfece61c933118b6221ef3af7c7 Mon Sep 17 00:00:00 2001 From: Andrey Kuleshov Date: Sat, 8 Apr 2023 23:26:41 +0200 Subject: [PATCH 2/5] Adding an action-script for an automated update of yarn.lock ### What's done: - to control JS depency versions there a special file, called yarn.lock, that check check-sum of the dependencies. Each time the dependency is updated, same should be done with this file. --- .github/workflows/kjs-yarn-update.yml | 51 +++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 .github/workflows/kjs-yarn-update.yml diff --git a/.github/workflows/kjs-yarn-update.yml b/.github/workflows/kjs-yarn-update.yml new file mode 100644 index 00000000..88e4acdd --- /dev/null +++ b/.github/workflows/kjs-yarn-update.yml @@ -0,0 +1,51 @@ +name: Update yarn.lock generated by Kotlin Gradle Plugin + +on: + pull_request: + paths: + - 'gradle/libs.versions.toml' + - 'ktoml-core/build.gradle.kts' + push: + paths: + - 'gradle/libs.versions.toml' + - 'ktoml-core/build.gradle.kts' + +jobs: + update_kjs_yarn_lock: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + if: github.event_name == 'pull_request' + with: + # Checkout source branch directly, without merging base into it + ref: ${{ github.event.pull_request.head.ref }} + - uses: actions/checkout@v3 + if: github.event_name == 'push' + with: + # Checkout source branch directly, without merging base into it + ref: ${{ github.event.push.ref }} + - name: Generate yarn.lock + uses: gradle/gradle-build-action@v2 + with: + gradle-version: wrapper + arguments: | + kotlinStoreYarnLock + --build-cache + -PgprUser=${{ github.actor }} + -PgprKey=${{ secrets.GITHUB_TOKEN }} + - name: Dedupe generated yarn.lock + run: | + npm install -g yarn-deduplicate + yarn-deduplicate + - name: Commit and push if yarn.lock is changed + run: | + git add yarn.lock + if git diff --staged --quiet; then + echo Everything is UP-TO-DATE + else + echo Pushing updated yarn.lock + git config user.name akuleshov7 + git config user.email 'andrewkuleshov7@gmail.com' + git commit -m "Update yarn.lock" + git push + fi From 6d90ec5a7210b37992eecd21dfd4b841cb6fe251 Mon Sep 17 00:00:00 2001 From: Andrey Kuleshov Date: Sat, 15 Apr 2023 17:38:46 +0200 Subject: [PATCH 3/5] Generating yarn.lock --- kotlin-js-store/yarn.lock => yarn.lock | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename kotlin-js-store/yarn.lock => yarn.lock (100%) diff --git a/kotlin-js-store/yarn.lock b/yarn.lock similarity index 100% rename from kotlin-js-store/yarn.lock rename to yarn.lock From aa6496afa963f48547c75f3e5c2d987688181efd Mon Sep 17 00:00:00 2001 From: Andrey Kuleshov Date: Sat, 15 Apr 2023 17:58:34 +0200 Subject: [PATCH 4/5] Generating yarn.lock --- ktoml-core/build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ktoml-core/build.gradle.kts b/ktoml-core/build.gradle.kts index a1834d5b..2c308f4e 100644 --- a/ktoml-core/build.gradle.kts +++ b/ktoml-core/build.gradle.kts @@ -42,7 +42,7 @@ kotlin { val commonMain by getting { dependencies { api("org.jetbrains.kotlinx:kotlinx-serialization-core:${Versions.SERIALIZATION}") - api("org.jetbrains.kotlinx:kotlinx-datetime:0.4.0") + api("org.jetbrains.kotlinx:kotlinx-datetime:0.3.0") implementation("org.jetbrains.kotlin:kotlin-stdlib:${Versions.KOTLIN}") } } From 02444a75006b21bf80cc8bb3007a77a56304fea8 Mon Sep 17 00:00:00 2001 From: Andrey Kuleshov Date: Sat, 15 Apr 2023 18:18:31 +0200 Subject: [PATCH 5/5] Generating yarn.lock --- ktoml-core/build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ktoml-core/build.gradle.kts b/ktoml-core/build.gradle.kts index 2c308f4e..a1834d5b 100644 --- a/ktoml-core/build.gradle.kts +++ b/ktoml-core/build.gradle.kts @@ -42,7 +42,7 @@ kotlin { val commonMain by getting { dependencies { api("org.jetbrains.kotlinx:kotlinx-serialization-core:${Versions.SERIALIZATION}") - api("org.jetbrains.kotlinx:kotlinx-datetime:0.3.0") + api("org.jetbrains.kotlinx:kotlinx-datetime:0.4.0") implementation("org.jetbrains.kotlin:kotlin-stdlib:${Versions.KOTLIN}") } }