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

feat: Kotlin unit tests #228

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
39 changes: 39 additions & 0 deletions .github/workflows/unit-tests-android.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: unit-tests-android

on:
pull_request:
branches:
- 'master'
push:
branches:
- 'master'

jobs:
tests-android:
name: Android Unit Tests
runs-on: macos-12

steps:
- uses: actions/checkout@v3

- name: Use Node 18
uses: actions/setup-node@v3
with:
node-version: 18

- name: Install node_modules
working-directory: example
run: yarn install && yarn rn-setup

- name: Use JDK 17
uses: actions/setup-java@v2
with:
java-version: '17'
distribution: 'zulu'

- name: Use Android SDK
uses: android-actions/setup-android@v2

- name: Run Android unit tests
working-directory: lib/android
run: ./gradlew testDebugUnitTest --stacktrace --no-daemon
2 changes: 2 additions & 0 deletions lib/.eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ node_modules
dist
src/protos
example
ios/*
android/*
1 change: 1 addition & 0 deletions lib/android/.java-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
zulu64-11.0.22
17 changes: 14 additions & 3 deletions lib/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,20 @@ buildscript {
google()
mavenCentral()
jcenter()
maven { url = uri("https://plugins.gradle.org/m2/") }
}

dependencies {
classpath 'com.android.tools.build:gradle:3.5.4'
classpath("com.android.tools.build:gradle:7.1.3")
// noinspection DifferentKotlinGradleVersion
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath("com.adarshr:gradle-test-logger-plugin:2.0.0")
}
}

apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'org.jetbrains.kotlin.android'
apply plugin: "com.adarshr.test-logger"

def getExtOrDefault(name) {
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['Ldk_' + name]
Expand Down Expand Up @@ -125,7 +128,15 @@ def kotlin_version = getExtOrDefault('kotlinVersion')
dependencies {
// noinspection GradleDynamicVersion
api 'com.facebook.react:react-native:+'
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation(platform("org.jetbrains.kotlin:kotlin-bom:$kotlin_version"))
// implementation files('libs/ldk-java-javadoc.jar') // Used to get code completion in Kotlin but won't compile with it
compileOnly files('libs/LDK-release.aar')

// Unit testing dependencies
testImplementation project(':')
testImplementation files('libs/ldk-java.jar') // Needs jvm11 aarch64 for tests with LDK references
testImplementation("junit:junit:4.13.2")
testImplementation("org.jetbrains.kotlin:kotlin-test")
testImplementation("org.mockito.kotlin:mockito-kotlin:3.2.0")
testImplementation("org.robolectric:robolectric:4.7.3")
}
3 changes: 2 additions & 1 deletion lib/android/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
Ldk_kotlinVersion=1.6.10
Ldk_kotlinVersion=1.8.0
Ldk_compileSdkVersion=29
Ldk_targetSdkVersion=29
android.useAndroidX=true
Binary file modified lib/android/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion lib/android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading
Loading