From 09fec7f0712e8991a0dd4179aea8d3238534cdd4 Mon Sep 17 00:00:00 2001 From: Mikhail Belyaev Date: Tue, 31 Mar 2020 23:10:20 +0300 Subject: [PATCH] v.0.0.0.7 --- .github/bintray-settings.xml | 12 +++++ .github/workflows/deployment.yml | 53 ++++++++++++++++++++ .github/workflows/integration.yml | 17 +++++++ pom.xml | 4 +- src/main/kotlin/ru/spbstu/wheels/Bits.kt | 6 +-- src/main/kotlin/ru/spbstu/wheels/Expando.kt | 1 + src/main/kotlin/ru/spbstu/wheels/Hash.kt | 32 +++++++----- src/test/kotlin/ru/spbstu/wheels/BitsTest.kt | 1 - 8 files changed, 107 insertions(+), 19 deletions(-) create mode 100644 .github/bintray-settings.xml create mode 100644 .github/workflows/deployment.yml create mode 100644 .github/workflows/integration.yml diff --git a/.github/bintray-settings.xml b/.github/bintray-settings.xml new file mode 100644 index 0000000..85f42df --- /dev/null +++ b/.github/bintray-settings.xml @@ -0,0 +1,12 @@ + + + + + bintray-vorpal-research-kotlin-maven + ${env.BINTRAY_USERNAME} + ${env.BINTRAY_PASSWORD} + + + diff --git a/.github/workflows/deployment.yml b/.github/workflows/deployment.yml new file mode 100644 index 0000000..3b4aea5 --- /dev/null +++ b/.github/workflows/deployment.yml @@ -0,0 +1,53 @@ +name: Java CD + +on: + release: + types: published + +jobs: + publish: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v1 + - name: Set up JDK 1.8 + uses: actions/setup-java@v1 + with: + java-version: 1.8 + - name: Deploy to Bintray + id: deploy-to-bintray + run: | + mvn versions:set -DnewVersion=${{ github.event.release.tag_name }} + mvn deploy -s .github/bintray-settings.xml || echo "deploy failed" >&2 + env: + BINTRAY_USERNAME: ${{ secrets.bintray_username }} + BINTRAY_PASSWORD: ${{ secrets.bintray_password }} + + - name: Move sources jar file + run: mv target/*-sources.jar sources.jar + + - name: Move target jar file + run: mv target/*.jar target.jar + + - name: Attach source jar to release + id: upload-source-asset + uses: actions/upload-release-asset@v1.0.1 + env: + GITHUB_TOKEN: ${{ github.token }} + with: + upload_url: ${{ github.event.release.upload_url }} + asset_path: sources.jar + asset_name: ${{ github.event.repository.name }}-${{ github.event.release.tag_name }}-sources.jar + asset_content_type: application/zip + + - name: Attach target jar to release + id: upload-release-asset + uses: actions/upload-release-asset@v1.0.1 + env: + GITHUB_TOKEN: ${{ github.token }} + with: + upload_url: ${{ github.event.release.upload_url }} + asset_path: target.jar + asset_name: ${{ github.event.repository.name }}-${{ github.event.release.tag_name }}.jar + asset_content_type: application/zip \ No newline at end of file diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml new file mode 100644 index 0000000..a02111a --- /dev/null +++ b/.github/workflows/integration.yml @@ -0,0 +1,17 @@ +name: Java CI + +on: [push] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v1 + - name: Set up JDK 1.8 + uses: actions/setup-java@v1 + with: + java-version: 1.8 + - name: Build with Maven + run: mvn -B package diff --git a/pom.xml b/pom.xml index b9d7c6d..5b37cd9 100644 --- a/pom.xml +++ b/pom.xml @@ -6,11 +6,11 @@ ru.spbstu kotlin-wheels - 0.0.0.6 + 0.0.0.8-SNAPSHOT 1.8 - 1.3.61 + 1.3.71 UTF-8 diff --git a/src/main/kotlin/ru/spbstu/wheels/Bits.kt b/src/main/kotlin/ru/spbstu/wheels/Bits.kt index 8c624e4..49624ac 100644 --- a/src/main/kotlin/ru/spbstu/wheels/Bits.kt +++ b/src/main/kotlin/ru/spbstu/wheels/Bits.kt @@ -1,5 +1,5 @@ @file: Suppress(Warnings.NOTHING_TO_INLINE) -@file: UseExperimental(ExperimentalStdlibApi::class, ExperimentalUnsignedTypes::class) +@file: OptIn(ExperimentalStdlibApi::class, ExperimentalUnsignedTypes::class) package ru.spbstu.wheels @@ -20,7 +20,7 @@ val IntBits.Companion.SIZE get() = Int.SIZE_BITS fun IntBits.Companion.fromString(s: String): IntBits = IntBits(s.toUInt(2).toInt()) -@UseExperimental(ExperimentalStdlibApi::class) +@OptIn(ExperimentalStdlibApi::class) inline class IntBits constructor(val data: Int) { companion object {} @@ -113,7 +113,7 @@ val LongBits.Companion.SIZE get() = Long.SIZE_BITS fun LongBits.Companion.fromString(s: String): LongBits = bits(s.toULong(2).toLong()) -@UseExperimental(ExperimentalStdlibApi::class) +@OptIn(ExperimentalStdlibApi::class) inline class LongBits constructor(val data: Long) { companion object {} diff --git a/src/main/kotlin/ru/spbstu/wheels/Expando.kt b/src/main/kotlin/ru/spbstu/wheels/Expando.kt index b3860d7..47fc3c6 100644 --- a/src/main/kotlin/ru/spbstu/wheels/Expando.kt +++ b/src/main/kotlin/ru/spbstu/wheels/Expando.kt @@ -29,5 +29,6 @@ open class Expando { inline class Expansion(val map: MutableMap = mutableMapOf()) { + @Suppress(Warnings.OVERRIDE_BY_INLINE, Warnings.NOTHING_TO_INLINE) override inline fun toString(): String = map.entries.joinToString(", ") { (k, v) -> "$k=$v" } } diff --git a/src/main/kotlin/ru/spbstu/wheels/Hash.kt b/src/main/kotlin/ru/spbstu/wheels/Hash.kt index 2414f5f..ef48713 100644 --- a/src/main/kotlin/ru/spbstu/wheels/Hash.kt +++ b/src/main/kotlin/ru/spbstu/wheels/Hash.kt @@ -1,30 +1,36 @@ +@file: Suppress(Warnings.NOTHING_TO_INLINE) package ru.spbstu.wheels +import kotlinx.warnings.Warnings + // == values.toSet().hashCode() fun setHashCode(values: Iterable): Int = values.fold(0) { acc, c -> acc + c.hashCode() } // == values.toList().hashCode() fun orderedHashCode(values: Iterable): Int = values.fold(1) { acc, c -> 31 * acc + c.hashCode() } -fun hashCombine(a: A, b: B): Int { - var result = a?.hashCode() ?: 0 - result = 31 * result + (b?.hashCode() ?: 0) +inline fun hashCombine(a: A, b: B): Int { + var result = 1 + result = 31 * result + a.hashCode() + result = 31 * result + b.hashCode() return result } -fun hashCombine(a: A, b: B, c: C): Int { - var result = a?.hashCode() ?: 0 - result = 31 * result + (b?.hashCode() ?: 0) - result = 31 * result + (c?.hashCode() ?: 0) +inline fun hashCombine(a: A, b: B, c: C): Int { + var result = 1 + result = 31 * result + a.hashCode() + result = 31 * result + b.hashCode() + result = 31 * result + c.hashCode() return result } -fun hashCombine(a: A, b: B, c: C, d: D): Int { - var result = a?.hashCode() ?: 0 - result = 31 * result + (b?.hashCode() ?: 0) - result = 31 * result + (c?.hashCode() ?: 0) - result = 31 * result + (d?.hashCode() ?: 0) +inline fun hashCombine(a: A, b: B, c: C, d: D): Int { + var result = 1 + result = 31 * result + a.hashCode() + result = 31 * result + b.hashCode() + result = 31 * result + c.hashCode() + result = 31 * result + d.hashCode() return result } -fun hashCombine(vararg t: T): Int { +inline fun hashCombine(vararg t: T): Int { var result = 1 for(e in t) result = 31 * result + e.hashCode() return result diff --git a/src/test/kotlin/ru/spbstu/wheels/BitsTest.kt b/src/test/kotlin/ru/spbstu/wheels/BitsTest.kt index 8bb399d..2afca3e 100644 --- a/src/test/kotlin/ru/spbstu/wheels/BitsTest.kt +++ b/src/test/kotlin/ru/spbstu/wheels/BitsTest.kt @@ -4,7 +4,6 @@ import org.junit.Test import kotlin.test.assertEquals import kotlin.test.assertFailsWith -@ExperimentalStdlibApi class BitsTest { @Test fun boringOps() {