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/di xendit #127

Open
wants to merge 27 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
100 changes: 100 additions & 0 deletions .github/workflows/sdk_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
name: SDK Test

on:
pull_request:

jobs:
unit-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Gradle cache
uses: gradle/gradle-build-action@v2

- name: Enable KVM
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: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'

- name: Touch local properties
run: touch local.properties

- name: AVD cache
uses: actions/cache@v4
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-30

- name: create AVD and generate snapshot for caching
if: steps.avd-cache.outputs.cache-hit != 'true'
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 30
arch: x86_64
force-avd-creation: false
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: false
ram-size: 4096M
script: echo "Generated AVD snapshot for caching."

- name: Setup Gradle
uses: gradle/gradle-build-action@v2

- name: Print environment info
run: |
java -version
./gradlew --version
echo "Free space:"
df -h

- name: Run Coverage
run: ./gradlew :xendit-android:jacocoReport

- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Run Instrumentation Test
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 30
arch: x86_64
force-avd-creation: false
disable-animations: true
ram-size: 4096M
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
script: ./gradlew :xendit-android:connectedCheck --stacktrace

- name: Add coverage to PR
id: jacoco
uses: madrapps/[email protected]
with:
paths: |
${{ github.workspace }}/**/build/reports/coverage/androidTest/debug/connected/report.xml
token: ${{ secrets.GITHUB_TOKEN }}
min-coverage-overall: 40
min-coverage-changed-files: 60

# notify-slack:
# needs: unit-test
# runs-on: ubuntu-latest
# if: always()
# steps:
# - name: Notify Slack
# uses: ravsamhq/notify-slack-action@v1
# with:
# status: ${{ needs.unit-test.result }}
# footer: 'Linked Repo <{repo_url}|{repo}> {branch}'
# notify_when: 'failure'
# env:
# SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import com.google.gson.Gson;
import com.xendit.AuthenticationCallback;
import com.xendit.Models.Authentication;
import com.xendit.Models.CardInfo;
import com.xendit.Models.XenditError;
import com.xendit.Xendit;
import com.xendit.example.models.AuthenticationResponse;
Expand Down Expand Up @@ -84,7 +83,7 @@ private void setActionBarTitle(String title) {
@Override
public void onClick(View view) {

Xendit xendit = new Xendit(getApplicationContext(), CreateTokenActivity.PUBLISHABLE_KEY, this);
Xendit xendit = Xendit.create(getApplicationContext(), CreateTokenActivity.PUBLISHABLE_KEY, this);

String tokenId = tokenIdEditText.getText().toString();
String amount = amountEditText.getText().toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ private void setActionBarTitle(String title) {

@Override
public void onClick(View view) {
final Xendit xendit = new Xendit(getApplicationContext(), apiKeyEditText.getText().toString(), this);
final Xendit xendit = Xendit.create(getApplicationContext(), apiKeyEditText.getText().toString(), this);

final ProgressBar progressBar = findViewById(R.id.progressBar);
progressBar.setVisibility(View.VISIBLE);
Expand Down
3 changes: 1 addition & 2 deletions app/src/main/java/com/xendit/example/StoreCvnActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import com.xendit.Models.XenditError;
import com.xendit.Xendit;
import com.xendit.example.models.StoreCVNResponse;
import com.xendit.example.models.TokenizationResponse;
import com.xendit.utils.StoreCVNCallback;

public class StoreCvnActivity extends AppCompatActivity implements View.OnClickListener {
Expand Down Expand Up @@ -62,7 +61,7 @@ private void setActionBarTitle(String title) {

@Override
public void onClick(View view) {
final Xendit xendit = new Xendit(getApplicationContext(), DUMMY_PUBLISHABLE_KEY, this);
final Xendit xendit = Xendit.create(getApplicationContext(), DUMMY_PUBLISHABLE_KEY, this);

final ProgressBar progressBar = findViewById(R.id.progressBar);
progressBar.setVisibility(View.VISIBLE);
Expand Down
2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ buildscript {
classpath 'com.android.tools.build:gradle:8.2.2'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'
classpath 'io.codearte.gradle.nexus:gradle-nexus-staging-plugin:0.30.0'
//Jacoco Plugin
classpath "org.jacoco:org.jacoco.core:0.8.10"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
Expand Down
26 changes: 26 additions & 0 deletions jacoco.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
apply plugin: 'jacoco'

task jacocoReport(type: JacocoReport, dependsOn: 'testDebugUnitTest') {
reports {
csv { enabled false } // change if needed
xml { enabled true } // change if needed
html {
enabled true
destination file("${buildDir}/coverage-report")
}
}

// Setup the .class, source, and execution directories
final fileFilter = ['**/R.class', '**/R$*.class', '**/BuildConfig.*', '**/Manifest*.*', 'android/**/*.*']

// Include this if you use Kotlin
final kotlinTree = fileTree(dir: "${project.buildDir}/tmp/kotlin-classes/debug", excludes: fileFilter)
final javacTree = fileTree(dir: "${project.buildDir}/intermediates/javac/debug", excludes: fileFilter)
final mainSrc = "${project.projectDir}/src/main/java"

sourceDirectories.setFrom files([mainSrc])
classDirectories.setFrom files([kotlinTree, javacTree])
executionData.setFrom fileTree(dir: project.buildDir, includes: [
'jacoco/testDebugUnitTest.exec', 'outputs/code-coverage/connected/*coverage.ec'
])
}
8 changes: 8 additions & 0 deletions xendit-android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
apply plugin: 'com.android.library'
apply plugin: 'maven-publish'
apply plugin: 'signing'
apply plugin: 'jacoco'
apply from: "$project.rootDir/jacoco.gradle"

group 'com.xendit'
version '4.2.2'
Expand Down Expand Up @@ -49,6 +51,8 @@ android {
}
debug {
minifyEnabled false
enableUnitTestCoverage true
testCoverageEnabled true
consumerProguardFiles 'proguard-rules.pro'
buildConfigField('long', 'VERSION_CODE', "${defaultConfig.versionCode}")
buildConfigField('String','VERSION_NAME', "\"${defaultConfig.versionName}\"")
Expand Down Expand Up @@ -104,6 +108,10 @@ dependencies {
//Logging Network Calls
api 'com.squareup.okhttp3:logging-interceptor:3.6.0'

androidTestImplementation('org.awaitility:awaitility:4.2.2') {
transitive = false
}

}


Expand Down
Loading
Loading