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: compose sdk #149

Open
wants to merge 23 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
d08e504
feat(compose): add compose SDK
CAMOBAP Feb 28, 2024
bb94810
feat(compose): add UI tests and move common plugins to gradle/shared/…
CAMOBAP Apr 10, 2024
9f680d8
ci: do compilation test with compile-api=34
CAMOBAP Apr 17, 2024
0296483
ci: run test-minified after test-ui
CAMOBAP Apr 18, 2024
de37d3f
chore: move compose example activity to separate module and rename co…
CAMOBAP May 16, 2024
1b13fc2
chore: make sdk as transitive dependency for compose-sdk
CAMOBAP May 17, 2024
16fbe35
ci: migrate to arm64 emulator
CAMOBAP May 17, 2024
4ffac7b
ci: switch to ubuntu-runner beause macos-latest arm64 broken
CAMOBAP May 17, 2024
50f5f2b
Merge branch 'main' into feature/compose-sdk
CAMOBAP May 17, 2024
8eeccc0
ci: enable KVM group permissions for emulator run
CAMOBAP May 18, 2024
665eae3
Merge branch 'feature/compose-sdk' of github.com:hCaptcha/hcaptcha-an…
CAMOBAP May 18, 2024
2ce4149
ci: parallel should be preinstalled on ubuntu runner
CAMOBAP May 18, 2024
134ec3f
ci: downgrade emulator api to 28 to check if it affect stability
CAMOBAP May 18, 2024
d21b1b8
chore: move avd creation/run into separate action
CAMOBAP May 19, 2024
3749ce6
ci: use recent avd for benchmark tests
CAMOBAP May 19, 2024
bb38ab2
chore: rename compose-app -> example-compose-app
CAMOBAP May 20, 2024
eff4d65
ci: upload bencmark logs on failure
CAMOBAP May 20, 2024
113ff4b
chore: replace DisposableEffect with Dialog+AndroidView
CAMOBAP Jun 3, 2024
1c4198a
chore: add loading indicator to example-compose-app
CAMOBAP Jun 3, 2024
8521021
test: bench on 28 emulator
CAMOBAP Jun 12, 2024
efd30dc
ci: move back to macos-13 for benchmarking job
CAMOBAP Jun 14, 2024
2654d93
chore: move compose UI tests to test module
CAMOBAP Jun 15, 2024
8c6a782
fix: put back compose-sdk/src/test directory
CAMOBAP Jun 15, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
68 changes: 68 additions & 0 deletions .github/actions/android-emulator-run/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: android-emulator-run
description: Do run script after emulator boot (use cached AVD or create a new one)

inputs:
script:
description: Script to run after emulator booted
required: true
arch:
description: Emulator arch, supported values depends on runner
required: true
default: x86_64
target:
description: Emulator target. Supported `default` or `google_apis` values
required: true
default: default
profile:
description: Emulator profile
required: true
default: Nexus 6
api-level:
description: Emulator API level
required: true
default: '28'
boot-options:
description: Emulator boot options
required: true
default: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none

runs:
using: "composite"
steps:
- name: Cache AVD
uses: actions/cache@v4
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-api-${{ inputs.api-level }}-target-${{ inputs.target }}
- if: runner.os == 'Linux'
name: Enable KVM group perms
shell: bash
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
- name: 'Create AVD'
if: steps.avd-cache.outputs.cache-hit != 'true'
uses: reactivecircus/android-emulator-runner@v2
with:
arch: ${{ inputs.arch }}
target: ${{ inputs.target }}
profile: ${{ inputs.profile }}
api-level: ${{ inputs.api-level }}
emulator-options: ${{ inputs.boot-options }}
force-avd-creation: false
disable-animations: false
script: echo "Generated AVD snapshot for caching."
- uses: reactivecircus/android-emulator-runner@v2
with:
arch: ${{ inputs.arch }}
target: ${{ inputs.target }}
profile: ${{ inputs.profile }}
api-level: ${{ inputs.api-level }}
emulator-options: ${{ inputs.boot-options }}
force-avd-creation: false
disable-animations: true
script: ${{ inputs.script }}
144 changes: 29 additions & 115 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:

build-matrix:
name: 'Build (target:${{ matrix.target }} compile:${{ matrix.compile }} appcompat: ${{ matrix.appcompat }})'
needs: [ test ]
needs: test
runs-on: ubuntu-latest
strategy:
fail-fast: false
Expand All @@ -50,16 +50,16 @@ jobs:
- compile: 34
target: 34
appcompat: 1.6.1
- compile: 33
- compile: 34
target: 33
appcompat: 1.5.1
- compile: 32
- compile: 34
target: 32
appcompat: 1.4.2
- compile: 32
- compile: 34
target: 30
appcompat: 1.3.1
- compile: 30
- compile: 34
target: 30
appcompat: 1.3.1
steps:
Expand All @@ -78,13 +78,9 @@ jobs:

test-ui:
name: 'Test UI'
runs-on: macos-latest
needs: test
runs-on: ubuntu-latest
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
api-level: [29]
target: [default]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
Expand All @@ -94,39 +90,10 @@ jobs:
- uses: gradle/gradle-build-action@v3
with:
cache-read-only: false
- name: 'Cache AVD'
uses: actions/cache@v4
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-api-${{ matrix.api-level }}-target-${{ matrix.target }}
- name: 'Create AVD'
if: steps.avd-cache.outputs.cache-hit != 'true'
uses: reactivecircus/android-emulator-runner@v2.29.0
with:
api-level: ${{ matrix.api-level }}
target: ${{ matrix.target }}
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
force-avd-creation: false
disable-animations: false
arch: x86_64
profile: Nexus 6
script: echo "Generated AVD snapshot for caching."
- name: 'Tests'
uses: reactivecircus/android-emulator-runner@v2.29.0
- name: Run tests
uses: ./.github/actions/android-emulator-run
with:
api-level: ${{ matrix.api-level }}
target: ${{ matrix.target }}
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
force-avd-creation: false
disable-animations: true
arch: x86_64
profile: Nexus 6
script: |
brew install parallel
parallel --retries 3 ::: "./gradlew test:connectedCheck"
script: "parallel --retries 3 ::: './gradlew test:connectedCheck'"
- if: failure()
uses: actions/upload-artifact@v4
with:
Expand All @@ -137,13 +104,9 @@ jobs:

test-minified:
name: 'Test UI Minified'
runs-on: macos-latest
needs: [ test-ui ]
runs-on: ubuntu-latest
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
api-level: [29]
target: [default]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
Expand All @@ -153,39 +116,10 @@ jobs:
- uses: gradle/gradle-build-action@v3
with:
cache-read-only: false
- name: 'Cache AVD'
uses: actions/cache@v4
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-api-${{ matrix.api-level }}-target-${{ matrix.target }}
- name: 'Create AVD'
if: steps.avd-cache.outputs.cache-hit != 'true'
uses: reactivecircus/android-emulator-runner@v2.29.0
with:
api-level: ${{ matrix.api-level }}
target: ${{ matrix.target }}
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
force-avd-creation: false
disable-animations: false
arch: x86_64
profile: Nexus 6
script: echo "Generated AVD snapshot for caching."
- name: 'Tests'
uses: reactivecircus/android-emulator-runner@v2.29.0
- name: Run tests
uses: ./.github/actions/android-emulator-run
with:
api-level: ${{ matrix.api-level }}
target: ${{ matrix.target }}
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
force-avd-creation: false
disable-animations: true
arch: x86_64
profile: Nexus 6
script: |
brew install parallel
parallel --retries 3 ::: "./gradlew test:connectedCheck -P testingMinimizedBuild=true -P android.enableR8.fullMode=false"
script: "parallel --retries 3 ::: './gradlew test:connectedCheck -P testingMinimizedBuild=true -P android.enableR8.fullMode=false'"
- if: failure()
uses: actions/upload-artifact@v4
with:
Expand All @@ -196,13 +130,11 @@ jobs:

test-benchmark:
name: 'Test Benchmark'
runs-on: macos-latest
needs: test
# ubuntu-latest fails with JNI ERROR (app bug): weak global reference table overflow (max=51200)
# macos-latest i.e. macos-14 https://github.com/ReactiveCircus/android-emulator-runner/issues/324
runs-on: macos-13
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
api-level: [29]
target: [default]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
Expand All @@ -212,36 +144,18 @@ jobs:
- uses: gradle/gradle-build-action@v3
with:
cache-read-only: false
- name: 'Cache AVD'
uses: actions/cache@v4
id: avd-cache
- name: Run tests
uses: ./.github/actions/android-emulator-run
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-api-${{ matrix.api-level }}-target-${{ matrix.target }}
- name: 'Create AVD'
if: steps.avd-cache.outputs.cache-hit != 'true'
uses: reactivecircus/android-emulator-runner@v2.29.0
with:
api-level: ${{ matrix.api-level }}
target: ${{ matrix.target }}
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
force-avd-creation: false
disable-animations: false
arch: x86_64
profile: Nexus 6
script: echo "Generated AVD snapshot for caching."
- uses: reactivecircus/android-emulator-runner@v2.29.0
with:
api-level: ${{ matrix.api-level }}
target: ${{ matrix.target }}
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
force-avd-creation: false
disable-animations: true
arch: x86_64
profile: Nexus 6
api-level: 29
script: ./gradlew benchmark:connectedReleaseAndroidTest
- if: failure()
uses: actions/upload-artifact@v4
with:
name: androidTest-benchmark-results
path: |
benchmark/build/outputs/androidTest-results
benchmark/build/reports/androidTests
- name: Diff benchmark result
id: diff-benchmark
uses: ./.github/actions/android-benchmark-diff
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
/sdk/gradle.properties
/.idea
.DS_Store
/build
build
/captures
.externalNativeBuild
.cxx
Expand Down
4 changes: 2 additions & 2 deletions MAINTAINERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ with:
```groovy
dependencies {
// ...
implementation "com.github.hCaptcha:hcaptcha-android-sdk:BRANCH_NAME-SNAPSHOT"
implementation "com.github.hCaptcha.hcaptcha-android-sdk:sdk:BRANCH_NAME-SNAPSHOT"
// or
implementation "com.github.hCaptcha:hcaptcha-android-sdk:pull/PR_NUMBER/head-SNAPSHOT"
implementation "com.github.hCaptcha.hcaptcha-android-sdk:sdk:pull/PR_NUMBER/head-SNAPSHOT"
}
```
1. Build `example-app` for `release` variant
Expand Down
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,28 @@ repositories {
}
// Add hCaptcha sdk dependency inside the app's build.gradle file
dependencies {
<b>implementation 'com.github.hcaptcha:hcaptcha-android-sdk:x.y.z'</b>
// For Android View
<b>implementation 'com.github.hCaptcha.hcaptcha-android-sdk:sdk:x.y.z'</b>
// For Jetpack Compose
<b>implementation 'com.github.hCaptcha.hcaptcha-android-sdk:compose-sdk:x.y.z'</b>
}
</pre>

*Note: replace `x.y.z` with one from [Release](https://github.com/hCaptcha/hcaptcha-android-sdk/releases) (e.g. `1.0.0`).*

### Legacy (versions < 5.0)

<pre>
// Register JitPack Repository inside the root build.gradle file
repositories {
<b>maven { url 'https://jitpack.io' }</b>
}
// Add hCaptcha sdk dependency inside the app's build.gradle file
dependencies {
<b>implementation 'com.github.hcaptcha:hcaptcha-android-sdk:x.y.z'</b>
}
</pre>

## Requirements

| Platform | Requirements |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ public void onLoaded() {
latch.countDown();
}
},
new TestHCaptchaStateListener(),
webView
);
});
Expand Down
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ buildscript {
classpath 'com.android.tools.build:gradle:8.1.3'
classpath 'androidx.benchmark:benchmark-gradle-plugin:1.2.0'
classpath 'com.slack.keeper:keeper:0.15.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}

Expand Down
1 change: 1 addition & 0 deletions compose-sdk/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build