From 151bb6c0a0802da9f85539495360b92669169521 Mon Sep 17 00:00:00 2001 From: Ugljesa Jovanovic Date: Wed, 7 Oct 2020 19:41:29 +0200 Subject: [PATCH 1/6] Improve padding tests a bit, add readme note for browser tests --- README.md | 1 + .../com/ionspin/kotlin/crypto/util/LibsodiumUtilTest.kt | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/README.md b/README.md index 92df90e..3b65475 100644 --- a/README.md +++ b/README.md @@ -138,6 +138,7 @@ Currently supported native platforms: - Complete the bindings list - Samples - Android testing +- Fix browser testing, both locally and in CI/CD diff --git a/multiplatform-crypto-libsodium-bindings/src/commonTest/kotlin/com/ionspin/kotlin/crypto/util/LibsodiumUtilTest.kt b/multiplatform-crypto-libsodium-bindings/src/commonTest/kotlin/com/ionspin/kotlin/crypto/util/LibsodiumUtilTest.kt index 52b97f9..ed6ec89 100644 --- a/multiplatform-crypto-libsodium-bindings/src/commonTest/kotlin/com/ionspin/kotlin/crypto/util/LibsodiumUtilTest.kt +++ b/multiplatform-crypto-libsodium-bindings/src/commonTest/kotlin/com/ionspin/kotlin/crypto/util/LibsodiumUtilTest.kt @@ -78,7 +78,9 @@ class LibsodiumUtilTest { val input = ubyteArrayOf(1U, 2U) val blocksize = 2 val padded = LibsodiumUtil.pad(input, blocksize) + val expected = ubyteArrayOf(1U, 2U, 0x80U, 0x00U) println(padded.hexColumsPrint()) + assertTrue { padded.contentEquals(expected) } val unpadded = LibsodiumUtil.unpad(padded, blocksize) println(unpadded.hexColumsPrint()) @@ -94,7 +96,9 @@ class LibsodiumUtilTest { val input = ubyteArrayOf(1U, 2U, 3U, 4U, 5U, 6U) val blocksize = 4 val padded = LibsodiumUtil.pad(input, blocksize) + val expected = ubyteArrayOf(1U, 2U, 3U, 4U, 5U, 6U, 0x80U, 0x00U) println(padded.hexColumsPrint()) + assertTrue { padded.contentEquals(expected) } val unpadded = LibsodiumUtil.unpad(padded, blocksize) println(unpadded.hexColumsPrint()) From 345ddc563ecbb69454aed82c689de65fc1346b45 Mon Sep 17 00:00:00 2001 From: Ugljesa Jovanovic Date: Wed, 7 Oct 2020 19:44:40 +0200 Subject: [PATCH 2/6] First attempt at mac build --- .gitlab-ci.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index eb018e8..2cb92e0 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -30,7 +30,9 @@ buildMac: stage: build when: manual allow_failure: false - script: echo TEST_PULL_REQUEST_MAC + script: + - echo TEST_PULL_REQUEST_MAC + - ./macBuild.sh tags: - macos buildWindows: From 887c52a319ebd9bf2289bf6d974e856793054ba7 Mon Sep 17 00:00:00 2001 From: Ugljesa Jovanovic Date: Wed, 7 Oct 2020 20:13:14 +0200 Subject: [PATCH 3/6] Don't run android tasks on mac/windows --- buildSrc/src/main/kotlin/Utils.kt | 8 +++++- .../build.gradle.kts | 27 ++++++++++--------- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/buildSrc/src/main/kotlin/Utils.kt b/buildSrc/src/main/kotlin/Utils.kt index 719f874..c20d987 100644 --- a/buildSrc/src/main/kotlin/Utils.kt +++ b/buildSrc/src/main/kotlin/Utils.kt @@ -37,6 +37,12 @@ fun getHostArchitecture(): String { return resolvedArch } +fun rootRunningOnLinuxx86_64(block: () -> Unit) { + if (getHostOsName() == "linux" && getHostArchitecture() == "x86-64") { + block() + } +} + fun KotlinMultiplatformExtension.isRunningInIdea(block: KotlinMultiplatformExtension.() -> Unit) { if (isInIdea()) { block(this) @@ -109,4 +115,4 @@ fun NamedDomainObjectContainer.createWorkaroundNativeMainSource } } -} \ No newline at end of file +} diff --git a/multiplatform-crypto-libsodium-bindings/build.gradle.kts b/multiplatform-crypto-libsodium-bindings/build.gradle.kts index db6e92a..b076ab3 100644 --- a/multiplatform-crypto-libsodium-bindings/build.gradle.kts +++ b/multiplatform-crypto-libsodium-bindings/build.gradle.kts @@ -57,19 +57,20 @@ version = ReleaseInfo.version val ideaActive = isInIdea() println("Idea active: $ideaActive") - -android { - compileSdkVersion(29) - defaultConfig { - minSdkVersion(24) - targetSdkVersion(29) - versionCode = 1 - versionName = "1.0" - testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" - } - buildTypes { - getByName("release") { - isMinifyEnabled = false +rootRunningOnLinuxx86_64 { + android { + compileSdkVersion(29) + defaultConfig { + minSdkVersion(24) + targetSdkVersion(29) + versionCode = 1 + versionName = "1.0" + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + } + buildTypes { + getByName("release") { + isMinifyEnabled = false + } } } } From 2e71214914dfda4503e8a67e25d1728bfcdadb6d Mon Sep 17 00:00:00 2001 From: Ugljesa Jovanovic Date: Wed, 7 Oct 2020 20:46:24 +0200 Subject: [PATCH 4/6] Revert android exclusion, we'll just point sdk to nonexisting folder and that should be enough --- buildSrc/src/main/kotlin/Utils.kt | 6 +---- .../build.gradle.kts | 27 +++++++++---------- 2 files changed, 14 insertions(+), 19 deletions(-) diff --git a/buildSrc/src/main/kotlin/Utils.kt b/buildSrc/src/main/kotlin/Utils.kt index c20d987..ff092c9 100644 --- a/buildSrc/src/main/kotlin/Utils.kt +++ b/buildSrc/src/main/kotlin/Utils.kt @@ -37,11 +37,7 @@ fun getHostArchitecture(): String { return resolvedArch } -fun rootRunningOnLinuxx86_64(block: () -> Unit) { - if (getHostOsName() == "linux" && getHostArchitecture() == "x86-64") { - block() - } -} + fun KotlinMultiplatformExtension.isRunningInIdea(block: KotlinMultiplatformExtension.() -> Unit) { if (isInIdea()) { diff --git a/multiplatform-crypto-libsodium-bindings/build.gradle.kts b/multiplatform-crypto-libsodium-bindings/build.gradle.kts index b076ab3..f91c1bd 100644 --- a/multiplatform-crypto-libsodium-bindings/build.gradle.kts +++ b/multiplatform-crypto-libsodium-bindings/build.gradle.kts @@ -57,25 +57,24 @@ version = ReleaseInfo.version val ideaActive = isInIdea() println("Idea active: $ideaActive") -rootRunningOnLinuxx86_64 { - android { - compileSdkVersion(29) - defaultConfig { - minSdkVersion(24) - targetSdkVersion(29) - versionCode = 1 - versionName = "1.0" - testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" - } - buildTypes { - getByName("release") { - isMinifyEnabled = false - } +android { + compileSdkVersion(29) + defaultConfig { + minSdkVersion(24) + targetSdkVersion(29) + versionCode = 1 + versionName = "1.0" + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + } + buildTypes { + getByName("release") { + isMinifyEnabled = false } } } + kotlin { val hostOsName = getHostOsName() runningOnLinuxx86_64 { From 750387e14f10743ccc5d6cbc6d16d38a4ca20601 Mon Sep 17 00:00:00 2001 From: Ugljesa Jovanovic Date: Wed, 7 Oct 2020 21:01:31 +0200 Subject: [PATCH 5/6] Print out enviroment --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2cb92e0..9757873 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -31,7 +31,7 @@ buildMac: when: manual allow_failure: false script: - - echo TEST_PULL_REQUEST_MAC + - env - ./macBuild.sh tags: - macos From 985cd71d2e1b582e12a33264e5c3bc2e09bd0830 Mon Sep 17 00:00:00 2001 From: Ugljesa Jovanovic Date: Wed, 7 Oct 2020 22:39:02 +0200 Subject: [PATCH 6/6] Remove env --- .gitlab-ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9757873..c1e6426 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -31,7 +31,6 @@ buildMac: when: manual allow_failure: false script: - - env - ./macBuild.sh tags: - macos