From f887082b039bc918bfc4d3f6c6936e743e3d08b8 Mon Sep 17 00:00:00 2001 From: alexanderwiederin Date: Wed, 8 Nov 2023 14:38:31 +0100 Subject: [PATCH] add github workflow for kotlin --- .github/workflows/kotlin.yml | 47 +++++++++++++++++++ bindings/kotlin/ldk-node-jvm/lib/.env.ci | 4 ++ bindings/kotlin/ldk-node-jvm/lib/.env.local | 4 ++ .../kotlin/ldk-node-jvm/lib/build.gradle.kts | 22 +++++++-- 4 files changed, 72 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/kotlin.yml create mode 100644 bindings/kotlin/ldk-node-jvm/lib/.env.ci create mode 100644 bindings/kotlin/ldk-node-jvm/lib/.env.local diff --git a/.github/workflows/kotlin.yml b/.github/workflows/kotlin.yml new file mode 100644 index 000000000..ef783e735 --- /dev/null +++ b/.github/workflows/kotlin.yml @@ -0,0 +1,47 @@ +name: Continuous Integration Checks - Kotlin + +on: [push, pull_request] + +jobs: + check-kotlin: + runs-on: ubuntu-latest + + env: + LDK_NODE_JVM_DIR: bindings/kotlin/ldk-node-jvm + LDK_NODE_ANDROID_DIR: bindings/kotlin/ldk-node-android + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up JDK + uses: actions/setup-java@v3 + with: + distribution: temurin + java-version: 11 + + - name: Run ktlintCheck on ldk-node-jvm + run: | + cd $LDK_NODE_JVM_DIR + ./gradlew ktlintCheck + + - name: Run ktlintCheck on ldk-node-android + run: | + cd $LDK_NODE_ANDROID_DIR + ./gradlew ktlintCheck + + - name: Generate Kotlin JVM + run: ./scripts/uniffi_bindgen_generate_kotlin.sh + + - name: Start bitcoin and electrs + run: docker compose up -d + + - name: Run ldk-node-jvm tests + run: | + cd $LDK_NODE_JVM_DIR + ./gradlew test -Penv=ci + + - name: Run ldk-node-android tests + run: | + cd $LDK_NODE_ANDROID_DIR + ./gradlew test diff --git a/bindings/kotlin/ldk-node-jvm/lib/.env.ci b/bindings/kotlin/ldk-node-jvm/lib/.env.ci new file mode 100644 index 000000000..5af895f95 --- /dev/null +++ b/bindings/kotlin/ldk-node-jvm/lib/.env.ci @@ -0,0 +1,4 @@ +BITCOIN_CLI_BIN=docker exec ldk-node-bitcoin-1 bitcoin-cli +BITCOIND_RPC_USER=user +BITCOIND_RPC_PASSWORD=pass +ESPLORA_ENDPOINT=http://127.0.0.1:3002 diff --git a/bindings/kotlin/ldk-node-jvm/lib/.env.local b/bindings/kotlin/ldk-node-jvm/lib/.env.local new file mode 100644 index 000000000..8a5db1087 --- /dev/null +++ b/bindings/kotlin/ldk-node-jvm/lib/.env.local @@ -0,0 +1,4 @@ +BITCOIN_CLI_BIN=bitcoin-cli +BITCOIND_RPC_USER= +BITCOIND_RPC_PASSWORD= +ESPLORA_ENDPOINT=http://127.0.0.1:3002 diff --git a/bindings/kotlin/ldk-node-jvm/lib/build.gradle.kts b/bindings/kotlin/ldk-node-jvm/lib/build.gradle.kts index dee746c9b..82804806e 100644 --- a/bindings/kotlin/ldk-node-jvm/lib/build.gradle.kts +++ b/bindings/kotlin/ldk-node-jvm/lib/build.gradle.kts @@ -62,12 +62,24 @@ tasks.named("test") { showStackTraces = true showStandardStreams = true } +} + +tasks.test { + doFirst { + val envFile = if (project.hasProperty("env") && project.property("env") == "ci") { + file(".env.ci") + } else { + file(".env.local") + } - // Adapt the variables to run the tests in your local environment - environment("BITCOIN_CLI_BIN", "bitcoin-cli") - environment("BITCOIND_RPC_USER", "user") - environment("BITCOIND_RPC_PASSWORD", "pass") - environment("ESPLORA_ENDPOINT", "http://127.0.0.1:3002") + if (envFile.exists()) { + envFile.forEachLine { line -> + val (key, value) = line.split("=") + println("Setting environment variable: $key=$value") + environment(key, value) + } + } + } } afterEvaluate {