Skip to content
Draft
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
20 changes: 9 additions & 11 deletions .github/workflows/claude-code-review.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
name: Claude Code Review

on:
pull_request:
types: [opened, synchronize, ready_for_review, reopened]
# Optional: Only run on specific file changes
# paths:
# - "src/**/*.ts"
# - "src/**/*.tsx"
# - "src/**/*.js"
# - "src/**/*.jsx"
workflow_dispatch:
inputs:
pr_number:
description: "Pull request number to review"
required: true
type: number

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
group: ${{ github.workflow }}-${{ inputs.pr_number }}
cancel-in-progress: true

jobs:
Expand Down Expand Up @@ -40,7 +38,7 @@ jobs:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
REPO="${{ github.repository }}"
PR_NUMBER="${{ github.event.pull_request.number }}"
PR_NUMBER="${{ inputs.pr_number }}"

# Minimize issue comments from claude[bot]
gh api "repos/$REPO/issues/$PR_NUMBER/comments" --jq '.[] | select(.user.login == "claude[bot]") | .node_id' | while read -r node_id; do
Expand All @@ -62,6 +60,6 @@ jobs:
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
plugin_marketplaces: 'https://github.com/anthropics/claude-code.git'
plugins: 'code-review@claude-code-plugins'
prompt: '/code-review:code-review --comment ${{ github.repository }}/pull/${{ github.event.pull_request.number }}'
prompt: '/code-review:code-review --comment ${{ github.repository }}/pull/${{ inputs.pr_number }}'
claude_args: |
--allowedTools "Bash(gh pr comment:*),Bash(gh pr diff:*),Bash(gh pr view:*),Bash(gh api:*),Bash(git log:*),Bash(git diff:*),Bash(git blame:*),Read,Glob,Grep"
26 changes: 7 additions & 19 deletions .github/workflows/claude.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,15 @@
name: Claude Code

on:
issue_comment:
types: [created]
pull_request_review_comment:
types: [created]
issues:
types: [opened, assigned]
pull_request_review:
types: [submitted]
workflow_dispatch:
inputs:
prompt:
description: "Prompt for Claude Code"
required: true
type: string

jobs:
claude:
if: |
(github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude') &&
contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR"]'), github.event.comment.author_association)) ||
(github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude') &&
contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR"]'), github.event.comment.author_association)) ||
(github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude') &&
contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR"]'), github.event.review.author_association)) ||
(github.event_name == 'issues' && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude')) &&
contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR"]'), github.event.issue.author_association))
runs-on: ubuntu-latest
permissions:
contents: write # Allow creating branches/commits
Expand All @@ -44,8 +33,7 @@ jobs:
additional_permissions: |
actions: read

# Optional: Give a custom prompt to Claude. If this is not specified, Claude will perform the instructions specified in the comment that tagged it.
# prompt: 'Update the pull request description to include a summary of changes.'
prompt: ${{ inputs.prompt }}

# Optional: Add claude_args to customize behavior and configuration
# See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md
Expand Down
27 changes: 26 additions & 1 deletion .github/workflows/ui-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ on:
branches: [ "master" ]

workflow_dispatch:
inputs:
suites:
description: "Android test annotations: all or comma-separated simple annotation names"
required: false
default: "all"
type: string

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand Down Expand Up @@ -81,6 +87,8 @@ jobs:

- name: Run UI tests on Android Emulator
uses: reactivecircus/android-emulator-runner@v2
env:
ANDROID_TEST_SUITES: ${{ github.event.inputs.suites || 'all' }}
with:
api-level: 30
arch: x86_64
Expand All @@ -101,7 +109,24 @@ jobs:

# Install and run tests
./gradlew installDevDebug
./gradlew connectedDevDebugAndroidTest

suites="${ANDROID_TEST_SUITES:-all}"
suites="$(echo "$suites" | tr -d '[:space:]')"

if [[ -z "$suites" || "$suites" == "all" ]]; then
./gradlew connectedDevDebugAndroidTest
exit 0
fi

IFS=',' read -ra requested_suites <<< "$suites"
for suite in "${requested_suites[@]}"; do
if [[ "$suite" == *.* || ! "$suite" =~ ^[A-Z][A-Za-z0-9]*AndroidTest$ ]]; then
echo "::error::Invalid Android test annotation '$suite'. Use all or comma-separated simple annotation names such as DeviceUiIntegrationAndroidTest."
exit 1
fi

./gradlew connectedDevDebugAndroidTest -PbitkitAndroidTestAnnotation="$suite"
done

- name: Upload UI test report
if: always()
Expand Down
53 changes: 53 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,48 @@ val bcp47Locales = listOf(
)
val e2eBackendEnv = System.getenv("E2E_BACKEND") ?: "local"
val e2eHomegateUrlEnv = System.getenv("E2E_HOMEGATE_URL") ?: "http://127.0.0.1:6288"
val androidTestAnnotationPackage = "to.bitkit.test.annotations"
val androidTestAnnotationSuffix = "AndroidTest"
val androidTestTaskPrefix = "connectedDevDebug"
val androidTestTaskSuffix = "AndroidTest"
val androidTestAnnotationNames = file("src/androidTest/java/to/bitkit/test/annotations")
.listFiles()
?.mapNotNull { file ->
file.nameWithoutExtension.takeIf {
file.isFile &&
file.extension == "kt" &&
it.endsWith(androidTestAnnotationSuffix)
}
}
?.sorted()
.orEmpty()
val requestedTaskNames = gradle.startParameter.taskNames.map { it.substringAfterLast(":") }

fun androidTestTaskName(annotationName: String): String {
val taskInfix = annotationName.removeSuffix(androidTestAnnotationSuffix)
return "$androidTestTaskPrefix$taskInfix$androidTestTaskSuffix"
}

val requestedAndroidTestAnnotation = providers.gradleProperty("bitkitAndroidTestAnnotation")
.orNull
?.trim()
?.takeIf { it.isNotEmpty() }
?.also {
require('.' !in it) {
"Use a simple Android test annotation name, e.g. 'DeviceUiIntegrationAndroidTest'."
}
require(it in androidTestAnnotationNames) {
"Unsupported bitkitAndroidTestAnnotation '$it'. Supported annotations: " +
androidTestAnnotationNames.joinToString(", ")
}
}
val bitkitAndroidTestAnnotationName = requestedAndroidTestAnnotation
?: requestedTaskNames.firstNotNullOfOrNull { taskName ->
androidTestAnnotationNames.firstOrNull { androidTestTaskName(it) == taskName }
}
val bitkitAndroidTestAnnotation = bitkitAndroidTestAnnotationName?.let {
"$androidTestAnnotationPackage.$it"
}

android {
namespace = "to.bitkit"
Expand All @@ -59,6 +101,9 @@ android {
versionCode = 181
versionName = "2.2.0"
testInstrumentationRunner = "to.bitkit.test.HiltTestRunner"
bitkitAndroidTestAnnotation?.let {
testInstrumentationRunnerArguments["annotation"] = it
}
vectorDrawables {
useSupportLibrary = true
}
Expand Down Expand Up @@ -363,4 +408,12 @@ tasks.withType<Test>().configureEach {
jvmArgs("-XX:+EnableDynamicAgentLoading")
}

androidTestAnnotationNames.forEach { annotationName ->
tasks.register(androidTestTaskName(annotationName)) {
group = "verification"
description = "Runs devDebug Android tests annotated with '$annotationName'."
dependsOn("connectedDevDebugAndroidTest")
}
}

// endregion
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,16 @@ import org.junit.runner.RunWith
import to.bitkit.data.AppDb
import to.bitkit.data.entities.ConfigEntity
import to.bitkit.test.BaseAndroidTest
import to.bitkit.test.annotations.DeviceIntegrationAndroidTest
import to.bitkit.test.annotations.DeviceStorageIntegrationAndroidTest
import kotlin.test.assertEquals
import kotlin.test.assertFailsWith
import kotlin.test.assertNull
import kotlin.test.assertTrue

@RunWith(AndroidJUnit4::class)
@DeviceIntegrationAndroidTest
@DeviceStorageIntegrationAndroidTest
class KeychainTest : BaseAndroidTest() {

private val appContext by lazy { ApplicationProvider.getApplicationContext<Context>() }
Expand Down
4 changes: 4 additions & 0 deletions app/src/androidTest/java/to/bitkit/services/BlocktankTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,17 @@ import org.junit.Before
import org.junit.Rule
import org.junit.Test
import to.bitkit.env.Env
import to.bitkit.test.annotations.CoreServiceIntegrationAndroidTest
import to.bitkit.test.annotations.DeviceIntegrationAndroidTest
import javax.inject.Inject
import kotlin.test.assertEquals
import kotlin.test.assertNotEquals
import kotlin.test.assertNotNull
import kotlin.test.assertTrue

@HiltAndroidTest
@DeviceIntegrationAndroidTest
@CoreServiceIntegrationAndroidTest
class BlocktankTest {
@get:Rule
var hiltRule = HiltAndroidRule(this)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,15 @@ import org.junit.Test
import org.junit.runner.RunWith
import org.lightningdevkit.ldknode.Network
import to.bitkit.models.toDerivationPath
import to.bitkit.test.annotations.CoreServiceIntegrationAndroidTest
import to.bitkit.test.annotations.DeviceIntegrationAndroidTest
import kotlin.test.assertEquals
import kotlin.test.assertNotNull
import kotlin.test.assertTrue

@RunWith(AndroidJUnit4::class)
@DeviceIntegrationAndroidTest
@CoreServiceIntegrationAndroidTest
class OnchainServiceTests {
private lateinit var onchainService: OnchainService

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import to.bitkit.data.CacheStore
import to.bitkit.data.keychain.Keychain
import to.bitkit.env.Env
import to.bitkit.repositories.WalletRepo
import to.bitkit.test.annotations.CoreServiceIntegrationAndroidTest
import to.bitkit.test.annotations.DeviceIntegrationAndroidTest
import to.bitkit.utils.LdkError
import javax.inject.Inject
import kotlin.test.assertEquals
Expand All @@ -27,6 +29,8 @@ import kotlin.test.assertTrue

@HiltAndroidTest
@RunWith(AndroidJUnit4::class)
@DeviceIntegrationAndroidTest
@CoreServiceIntegrationAndroidTest
class RoutingFeeEstimationTest {

companion object {
Expand Down
4 changes: 4 additions & 0 deletions app/src/androidTest/java/to/bitkit/services/TxBumpingTests.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import org.junit.runner.RunWith
import to.bitkit.data.keychain.Keychain
import to.bitkit.env.Env
import to.bitkit.repositories.WalletRepo
import to.bitkit.test.annotations.CoreServiceIntegrationAndroidTest
import to.bitkit.test.annotations.DeviceIntegrationAndroidTest
import javax.inject.Inject
import kotlin.test.assertEquals
import kotlin.test.assertFalse
Expand All @@ -23,6 +25,8 @@ import kotlin.test.assertTrue

@HiltAndroidTest
@RunWith(AndroidJUnit4::class)
@DeviceIntegrationAndroidTest
@CoreServiceIntegrationAndroidTest
class TxBumpingTests {

@get:Rule
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import org.lightningdevkit.ldknode.CoinSelectionAlgorithm
import to.bitkit.data.keychain.Keychain
import to.bitkit.env.Env
import to.bitkit.repositories.WalletRepo
import to.bitkit.test.annotations.CoreServiceIntegrationAndroidTest
import to.bitkit.test.annotations.DeviceIntegrationAndroidTest
import javax.inject.Inject
import kotlin.test.assertEquals
import kotlin.test.assertFalse
Expand All @@ -25,6 +27,8 @@ import kotlin.test.fail

@HiltAndroidTest
@RunWith(AndroidJUnit4::class)
@DeviceIntegrationAndroidTest
@CoreServiceIntegrationAndroidTest
class UtxoSelectionTests {

@get:Rule
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package to.bitkit.test.annotations

@Retention(AnnotationRetention.RUNTIME)
@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION)
annotation class ComposeUiAndroidTest
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package to.bitkit.test.annotations

@Retention(AnnotationRetention.RUNTIME)
@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION)
annotation class CoreServiceIntegrationAndroidTest
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package to.bitkit.test.annotations

@Retention(AnnotationRetention.RUNTIME)
@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION)
annotation class DeviceIntegrationAndroidTest
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package to.bitkit.test.annotations

@Retention(AnnotationRetention.RUNTIME)
@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION)
annotation class DeviceStorageIntegrationAndroidTest
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package to.bitkit.test.annotations

@Retention(AnnotationRetention.RUNTIME)
@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION)
annotation class DeviceUiIntegrationAndroidTest
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ import androidx.compose.ui.test.performClick
import org.junit.Rule
import org.junit.Test
import to.bitkit.models.NodeLifecycleState
import to.bitkit.test.annotations.ComposeUiAndroidTest
import to.bitkit.viewmodels.SendMethod
import to.bitkit.viewmodels.SendUiState
import to.bitkit.viewmodels.previewAmountInputViewModel

@ComposeUiAndroidTest
class SendAmountContentTest {

@get:Rule
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.test.onNodeWithTag
import org.junit.Rule
import org.junit.Test
import to.bitkit.test.annotations.ComposeUiAndroidTest
import to.bitkit.ui.theme.AppThemeSurface

@ComposeUiAndroidTest
class BlockCardTest {

@get:Rule
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.test.onNodeWithTag
import org.junit.Rule
import org.junit.Test
import to.bitkit.test.annotations.ComposeUiAndroidTest
import to.bitkit.ui.theme.AppThemeSurface

@ComposeUiAndroidTest
class FactsCardTest {

@get:Rule
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ import androidx.compose.ui.test.onNodeWithTag
import androidx.compose.ui.test.performClick
import org.junit.Rule
import org.junit.Test
import to.bitkit.test.annotations.ComposeUiAndroidTest
import to.bitkit.ui.theme.AppThemeSurface

@ComposeUiAndroidTest
class FactsPreviewContentTest {

@get:Rule
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.test.onNodeWithTag
import org.junit.Rule
import org.junit.Test
import to.bitkit.test.annotations.ComposeUiAndroidTest
import to.bitkit.ui.theme.AppThemeSurface

@ComposeUiAndroidTest
class HeadlineCardTest {

@get:Rule
Expand Down
Loading
Loading