Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add android instrument tests #46

Merged
merged 5 commits into from
Jun 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 30 additions & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,38 @@ jobs:
if: matrix.os == 'ubuntu-latest' && matrix.job == 'test'
run: >
./gradlew check --stacktrace
-PKMP_TARGETS="JVM,JS,ANDROID,ANDROID_ARM32,ANDROID_ARM64,ANDROID_X64,ANDROID_X86,LINUX_ARM32HFP,LINUX_ARM64,LINUX_MIPS32,LINUX_MIPSEL32,LINUX_X64,WASM,WASM_32"
-PKMP_TARGETS="JVM,JS,ANDROID_ARM32,ANDROID_ARM64,ANDROID_X64,ANDROID_X86,LINUX_ARM32HFP,LINUX_ARM64,LINUX_MIPS32,LINUX_MIPSEL32,LINUX_X64,WASM,WASM_32"
- name: Run Windows Tests
if: matrix.os == 'windows-latest' && matrix.job == 'test'
run: >
./gradlew check --stacktrace
-PKMP_TARGETS="JVM,JS,MINGW_X64,MINGW_X86,WASM,WASM_32"

emulator:
runs-on: macos-latest

strategy:
fail-fast: false
matrix:
api-level: [ 15, 23, 29 ]
steps:
- name: Checkout Repo
uses: actions/checkout@v3

- name: Validate Gradle Wrapper
uses: gradle/wrapper-validation-action@v1

- name: Setup JDK
uses: actions/setup-java@v3.11.0
with:
distribution: 'zulu'
java-version: 19

- name: Build
uses: gradle/gradle-build-action@v2

- name: Run Android Instrumented Tests
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ matrix.api-level }}
script: ./gradlew :test-android:connectedCheck -PKMP_TARGETS="ANDROID,JVM"
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import org.jetbrains.kotlin.gradle.targets.js.yarn.YarnRootExtension
@Suppress("DSL_SCOPE_VIOLATION")
plugins {
alias(libs.plugins.multiplatform) apply(false)
alias(libs.plugins.android.library) apply(false)
alias(libs.plugins.binaryCompat)
alias(libs.plugins.gradleVersions)
}
Expand Down
5 changes: 5 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,13 @@ org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
org.gradle.parallel=true
org.gradle.caching=true

android.useAndroidX=true
android.enableJetifier=true
android.disableAutomaticComponentCreation=true

kotlin.code.style=official
kotlin.js.compiler=both
kotlin.mpp.androidSourceSetLayoutVersion=2
kotlin.mpp.enableCompatibilityMetadataVariant=true
kotlin.mpp.stability.nowarn=true
kotlin.native.binary.memoryModel=experimental
Expand Down
4 changes: 4 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
[versions]
android = "7.4.2"
androidxTestRunner = "1.5.2"
binaryCompat = "0.13.2"
bouncyCastle = "1.73"
configuration = "0.1.0"
Expand All @@ -20,11 +22,13 @@ gradle-kotlin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.
gradle-maven-publish = { module = "com.vanniktech:gradle-maven-publish-plugin", version.ref = "publish" }

# Tests
androidx-test-runner = { module = "androidx.test:runner", version.ref = "androidxTestRunner" }
bouncyCastle = { module = "org.bouncycastle:bcprov-ext-jdk15to18", version.ref = "bouncyCastle" }
encoding-base16 = { module = "io.matthewnelson.kotlin-components:encoding-base16", version.ref = "encoding" }
encoding-base64 = { module = "io.matthewnelson.kotlin-components:encoding-base64", version.ref = "encoding" }

[plugins]
android-library = { id = "com.android.library", version.ref = "android" }
binaryCompat = { id = "org.jetbrains.kotlinx.binary-compatibility-validator", version.ref = "binaryCompat" }
multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
gradleVersions = { id = "com.github.ben-manes.versions", version.ref = "gradleVersions" }
2 changes: 2 additions & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ pluginManagement {
repositories {
mavenCentral()
gradlePluginPortal()
google()
}
}

Expand All @@ -28,4 +29,5 @@ if (CHECK_PUBLICATION != null) {

include(":bom")
include(":tools:testing")
include(":test-android")
}
1 change: 1 addition & 0 deletions test-android/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
Empty file.
67 changes: 67 additions & 0 deletions test-android/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
* Copyright (c) 2023 Toxicity
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
plugins {
id("configuration")
}

repositories {
google()
}

kmpConfiguration {
this.configure {
androidLibrary {
kotlinJvmTarget = JavaVersion.VERSION_11
compileSourceCompatibility = JavaVersion.VERSION_11
compileTargetCompatibility = JavaVersion.VERSION_11

android {
namespace = "org.kotlincrypto.hash"
compileSdk = 33

defaultConfig {
minSdk = 14

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}

libraryVariants.all {
generateBuildConfigProvider.configure {
enabled = false
}
}
}

sourceSetTestInstrumented {
kotlin.srcDir("src/androidInstrumentedTest/md5")
kotlin.srcDir("src/androidInstrumentedTest/sha1")
kotlin.srcDir("src/androidInstrumentedTest/sha2")
kotlin.srcDir("src/androidInstrumentedTest/sha3")

dependencies {
implementation(libs.androidx.test.runner)
implementation(kotlin("test"))

implementation(project(":library:md5"))
implementation(project(":library:sha1"))
implementation(project(":library:sha2"))
implementation(project(":library:sha3"))
implementation(project(":tools:testing"))
}
}
}
}
}
1 change: 1 addition & 0 deletions test-android/src/androidInstrumentedTest/md5
1 change: 1 addition & 0 deletions test-android/src/androidInstrumentedTest/sha1
1 change: 1 addition & 0 deletions test-android/src/androidInstrumentedTest/sha2
1 change: 1 addition & 0 deletions test-android/src/androidInstrumentedTest/sha3
18 changes: 18 additions & 0 deletions test-android/src/androidMain/kotlin/org/kotlincrypto/hash/Stub.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* Copyright (c) 2023 Matthew Nelson
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
package org.kotlincrypto.hash

internal fun stub() { /* no-op */ }
Loading