From eb313a7a71bdcd99807eb5b886f0a599aaec6c30 Mon Sep 17 00:00:00 2001 From: Joseph Ivie Date: Fri, 13 Jan 2023 13:48:23 -0700 Subject: [PATCH 1/6] Updated workflows and packages to be local --- .github/workflows/ci-main.yml | 4 ++-- .github/workflows/ci-publish.yml | 4 ++-- build.gradle.kts | 4 ++-- gradle.properties | 2 +- library/build.gradle.kts | 13 +++++++++---- 5 files changed, 16 insertions(+), 11 deletions(-) diff --git a/.github/workflows/ci-main.yml b/.github/workflows/ci-main.yml index 77b3d3b..ec37d7d 100644 --- a/.github/workflows/ci-main.yml +++ b/.github/workflows/ci-main.yml @@ -31,8 +31,8 @@ jobs: - name: Publish SNAPSHOT env: - ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_CENTRAL_USERNAME }} - ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_CENTRAL_PASSWORD }} + ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.OSSRH_USERNAME }} + ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.OSSRH_PASSWORD }} ORG_GRADLE_PROJECT_signingKey: ${{ secrets.SIGNING_KEY }} ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.SIGNING_PASSWORD }} ORG_GRADLE_PROJECT_useSnapshot: true diff --git a/.github/workflows/ci-publish.yml b/.github/workflows/ci-publish.yml index 1c43ee1..083c9e2 100644 --- a/.github/workflows/ci-publish.yml +++ b/.github/workflows/ci-publish.yml @@ -22,8 +22,8 @@ jobs: - name: Publish RELEASE to Maven Central env: - ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_CENTRAL_USERNAME }} - ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_CENTRAL_PASSWORD }} + ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.OSSRH_USERNAME }} + ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.OSSRH_PASSWORD }} ORG_GRADLE_PROJECT_signingKey: ${{ secrets.SIGNING_KEY }} ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.SIGNING_PASSWORD }} run: ./gradlew publishRelease diff --git a/build.gradle.kts b/build.gradle.kts index ce9f5d2..b1bb62a 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,7 +8,7 @@ plugins { val serializationVersion = "1.0.0" allprojects { - group = "de.brudaswen.kotlinx.serialization" + group = "com.lightningkite" extra["serializationVersion"] = serializationVersion @@ -32,7 +32,7 @@ release { val mavenCentralUsername: String? by project val mavenCentralPassword: String? by project nexusStaging { - packageGroup = "de.brudaswen" + packageGroup = "com.lightningkite" username = mavenCentralUsername password = mavenCentralPassword numberOfRetries = 60 diff --git a/gradle.properties b/gradle.properties index bb4235e..2712fe8 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -version=2.0.1-SNAPSHOT +version=2.0.2-SNAPSHOT kotlin.code.style=official # Disable generation of metadata sha256/sha512 checksum diff --git a/library/build.gradle.kts b/library/build.gradle.kts index 1a8e6f0..f38e2ae 100644 --- a/library/build.gradle.kts +++ b/library/build.gradle.kts @@ -94,6 +94,11 @@ publishing { } } developers { + developer { + id.set("LightningKiteJoseph") + name.set("Joseph Ivie") + email.set("joseph@lightningkite.com") + } developer { id.set("brudaswen") name.set("Sven Obser") @@ -101,13 +106,13 @@ publishing { } } scm { - connection.set("scm:git:git://github.com/brudaswen/kotlinx-serialization-csv.git") - developerConnection.set("scm:git:ssh://git@github.com:brudaswen/kotlinx-serialization-csv.git") - url.set("https://github.com/brudaswen/kotlinx-serialization-csv/") + connection.set("scm:git:git://github.com/lightningkite/kotlinx-serialization-csv.git") + developerConnection.set("scm:git:ssh://git@github.com:lightningkite/kotlinx-serialization-csv.git") + url.set("https://github.com/lightningkite/kotlinx-serialization-csv/") } issueManagement { system.set("GitHub Issues") - url.set("https://github.com/brudaswen/kotlinx-serialization-csv/issues/") + url.set("https://github.com/lightningkite/kotlinx-serialization-csv/issues/") } } From e55c3674f238ceebbfbd15d8d9cdbea9710238cb Mon Sep 17 00:00:00 2001 From: Joseph Ivie Date: Fri, 13 Jan 2023 13:49:59 -0700 Subject: [PATCH 2/6] Development meta data update --- library/build.gradle.kts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/library/build.gradle.kts b/library/build.gradle.kts index f38e2ae..c587bc6 100644 --- a/library/build.gradle.kts +++ b/library/build.gradle.kts @@ -98,6 +98,8 @@ publishing { id.set("LightningKiteJoseph") name.set("Joseph Ivie") email.set("joseph@lightningkite.com") + organization.set("Lightning Kite") + organizationUrl.set("https://lightningkite.com") } developer { id.set("brudaswen") From 4731777d0f3eaeddf2609769e1b9ee87612d906b Mon Sep 17 00:00:00 2001 From: Joseph Ivie Date: Fri, 13 Jan 2023 13:51:40 -0700 Subject: [PATCH 3/6] Removed code coverage in CI --- .github/workflows/ci-main.yml | 8 -------- .github/workflows/ci-pulls.yml | 8 -------- 2 files changed, 16 deletions(-) diff --git a/.github/workflows/ci-main.yml b/.github/workflows/ci-main.yml index ec37d7d..1e4c4d9 100644 --- a/.github/workflows/ci-main.yml +++ b/.github/workflows/ci-main.yml @@ -21,14 +21,6 @@ jobs: - name: Build with Gradle run: ./gradlew build - - name: Upload report to codecov.io - uses: codecov/codecov-action@v1 - with: - token: ${{ secrets.CODECOV_TOKEN }} - file: library/build/reports/jacoco/test/jacocoTestReport.xml - flags: unittests - fail_ci_if_error: true - - name: Publish SNAPSHOT env: ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.OSSRH_USERNAME }} diff --git a/.github/workflows/ci-pulls.yml b/.github/workflows/ci-pulls.yml index 5f8493c..602c3c5 100644 --- a/.github/workflows/ci-pulls.yml +++ b/.github/workflows/ci-pulls.yml @@ -18,11 +18,3 @@ jobs: - name: Build with Gradle run: ./gradlew build - - - name: Upload report to codecov.io - uses: codecov/codecov-action@v1 - with: - token: ${{ secrets.CODECOV_TOKEN }} - file: library/build/reports/jacoco/test/jacocoTestReport.xml - flags: unittests - fail_ci_if_error: true From 0be44c4acc21874d10d642f855d13a144e460e00 Mon Sep 17 00:00:00 2001 From: Joseph Ivie Date: Fri, 13 Jan 2023 14:31:38 -0700 Subject: [PATCH 4/6] Publishing fix --- library/build.gradle.kts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/library/build.gradle.kts b/library/build.gradle.kts index c587bc6..200c024 100644 --- a/library/build.gradle.kts +++ b/library/build.gradle.kts @@ -1,4 +1,5 @@ import java.time.Duration +import java.net.URI plugins { kotlin("jvm") @@ -126,7 +127,10 @@ publishing { nexusPublishing { repositories { - sonatype() + sonatype() { + this.nexusUrl.set(URI("https://s01.oss.sonatype.org/content/repositories/releases/")) + this.snapshotRepositoryUrl.set(URI("https://s01.oss.sonatype.org/content/repositories/snapshots")) + } } clientTimeout.set(Duration.ofMinutes(30)) From 32a56fdb0aa5adf5074270169fd0d1c053ef887a Mon Sep 17 00:00:00 2001 From: Joseph Ivie Date: Fri, 13 Jan 2023 16:07:20 -0700 Subject: [PATCH 5/6] Version bump --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 2712fe8..0b2d442 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -version=2.0.2-SNAPSHOT +version=2.0.3-SNAPSHOT kotlin.code.style=official # Disable generation of metadata sha256/sha512 checksum From df707d847afc3d8c6abae319b76cfe641cb33921 Mon Sep 17 00:00:00 2001 From: Joseph Ivie Date: Thu, 23 Feb 2023 16:13:33 -0700 Subject: [PATCH 6/6] Streaming serialization bug fix --- gradle.properties | 2 +- .../kotlin/kotlinx/serialization/csv/Csv.kt | 18 +++------- .../serialization/csv/example/ExampleTest.kt | 33 +++++++++++++++++++ 3 files changed, 38 insertions(+), 15 deletions(-) diff --git a/gradle.properties b/gradle.properties index 0b2d442..8a12f99 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -version=2.0.3-SNAPSHOT +version=2.0.4-SNAPSHOT kotlin.code.style=official # Disable generation of metadata sha256/sha512 checksum diff --git a/library/src/main/kotlin/kotlinx/serialization/csv/Csv.kt b/library/src/main/kotlin/kotlinx/serialization/csv/Csv.kt index 7376a9e..15fea40 100644 --- a/library/src/main/kotlin/kotlinx/serialization/csv/Csv.kt +++ b/library/src/main/kotlin/kotlinx/serialization/csv/Csv.kt @@ -64,14 +64,7 @@ sealed class Csv(internal val config: CsvConfig) : SerialFormat, StringFormat { * @param appendable The output where the CSV will be written. */ fun encodeSequenceToAppendable(serializer: KSerializer, values: Sequence, appendable: Appendable) { - val encoder = RecordListCsvEncoder(this, CsvWriter(appendable, config)) - val listDescriptor = ListSerializer(serializer).descriptor - encoder.encodeStructure(listDescriptor) { - var index = 0 - for (value in values) { - encodeSerializableElement(listDescriptor, index++, serializer, value) - } - } + values.forEach(beginEncodingToAppendable(serializer, appendable)) } /** @@ -84,11 +77,9 @@ sealed class Csv(internal val config: CsvConfig) : SerialFormat, StringFormat { @ExperimentalSerializationApi fun beginEncodingToAppendable(serializer: KSerializer, appendable: Appendable): (T) -> Unit { val encoder = RecordListCsvEncoder(this, CsvWriter(appendable, config)) - val listDescriptor = ListSerializer(serializer).descriptor - encoder.beginStructure(listDescriptor) var index = 0 return { - encoder.encodeSerializableElement(listDescriptor, index++, serializer, it) + encoder.encodeSerializableValue(serializer, it) } } @@ -136,14 +127,13 @@ sealed class Csv(internal val config: CsvConfig) : SerialFormat, StringFormat { val csv = CsvReader(FetchSource(reader), config) val listDescriptor = ListSerializer(deserializer).descriptor val input = RecordListCsvDecoder(this, csv) - val structure = input.beginStructure(listDescriptor) var previousValue: T? = null return generateSequence { - val decodedIndex = structure.decodeElementIndex(listDescriptor) + val decodedIndex = input.decodeElementIndex(listDescriptor) if (decodedIndex == DECODE_DONE) return@generateSequence null val nextValue = - structure.decodeSerializableElement(listDescriptor, decodedIndex, deserializer, previousValue) + input.decodeSerializableElement(listDescriptor, decodedIndex, deserializer, previousValue) previousValue = nextValue nextValue } diff --git a/library/src/test/kotlin/kotlinx/serialization/csv/example/ExampleTest.kt b/library/src/test/kotlin/kotlinx/serialization/csv/example/ExampleTest.kt index 9ad2691..8df7c19 100644 --- a/library/src/test/kotlin/kotlinx/serialization/csv/example/ExampleTest.kt +++ b/library/src/test/kotlin/kotlinx/serialization/csv/example/ExampleTest.kt @@ -185,4 +185,37 @@ class ExampleTest { } assertEquals(testData, result) } + + @Test + fun testStreamingHeaders() { + val csv = Csv { + hasHeaderRecord = true + } + val testData = listOf( + Tire(FRONT, LEFT, 245, 35, 21), + Tire(FRONT, RIGHT, 245, 35, 21), + Tire(REAR, LEFT, 265, 35, 21), + Tire(REAR, RIGHT, 265, 35, 21), + Tire(FRONT, LEFT, 265, 35, 20), + Tire(FRONT, RIGHT, 265, 35, 20), + Tire(REAR, LEFT, 265, 35, 20), + Tire(REAR, RIGHT, 265, 35, 20) + ) + + val input = PipedReader() + val out = PipedWriter(input) + Thread( + Runnable { + csv.encodeSequenceToAppendable(Tire.serializer(), testData.asSequence(), out) + out.close() + } + ).start() + val result = ArrayList() + csv.decodeFromReaderUsingSequence(Tire.serializer(), input) { + it.forEach { + result.add(it) + } + } + assertEquals(testData, result) + } }