Skip to content

Commit

Permalink
Merge branch 'develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
descorp authored Nov 5, 2023
2 parents 7f3a0e9 + 8fb3bc0 commit cc22e2a
Show file tree
Hide file tree
Showing 60 changed files with 2,669 additions and 706 deletions.
264 changes: 264 additions & 0 deletions .github/workflows/pr_check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,264 @@
name: Scan PR

on:
pull_request:
types: [opened, synchronize, reopened]
push:
branches:
- develop
env:
node-version: 16

jobs:
build-lib:
name: Build Nodes
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version: ${{ env.node-version }}
cache: 'yarn'

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT

- uses: actions/cache@v3
with:
path: |
${{ steps.yarn-cache-dir-path.outputs.dir }}
node_modules
example/node_modules
key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Build library
run: yarn install --frozen-lockfile

- name: Build Example app
working-directory: example
run: yarn install

- name: Archive library
uses: actions/cache/save@v3
with:
path: lib
key: temp-lib-${{ github.sha }}

- name: Archive Node Modules
uses: actions/cache/save@v3
with:
path: |
node_modules
example/node_modules
key: temp-node-${{ github.sha }}

test-iOS:
name: Test iOS
runs-on: macos-13-large
needs: [build-lib]
env:
workspace: AdyenExample.xcworkspace
scheme: AdyenExample
device: iPhone 14
buildFolder: ./DerivedData
steps:
- uses: actions/checkout@v4

- name: Pre-heat iPhone Simulator ${{ env.device }}
id: sets-simulator
run: |
simulator_id=$(xcrun simctl list | grep -E '${{ env.device }}' | grep -Eo '[A-Z0-9-]{36}' | head -n 1)
xcrun simctl boot $simulator_id
open /Applications/Xcode.app/Contents/Developer/Applications/Simulator.app/
echo "id=$simulator_id" >> "$GITHUB_OUTPUT"
- uses: actions/setup-node@v3
with:
node-version: ${{ env.node-version }}
cache: 'yarn'

- uses: actions/cache/restore@v3
with:
path: lib
key: temp-lib-${{ github.sha }}

- uses: actions/cache/restore@v3
id: yarn-cache
with:
path: |
node_modules
example/node_modules
key: temp-node-${{ github.sha }}

- name: Build dependency if needed
if: steps.yarn-cache.outputs.cache-hit != 'true'
run: yarn

- uses: actions/cache@v3
with:
path: example/ios/Pods
key: ${{ runner.os }}-pods-${{ hashFiles('example/ios/Podfile.lock') }}
restore-keys: ${{ runner.os }}-pods-

- name: Pod install
working-directory: example/ios
run: pod install

- name: Run tests
working-directory: example/ios
run: |
xcodebuild test \
-workspace ${{ env.workspace }} \
-scheme ${{ env.scheme }} \
-destination "id=${{ steps.sets-simulator.outputs.id }}" \
-derivedDataPath ${{ env.buildFolder }} \
-enableCodeCoverage YES | xcpretty --utf --color && exit ${PIPESTATUS[0]}
- name: Generate code Coverage
working-directory: example/ios
run: |
mkdir ${{ github.workspace }}/reports
${{ github.workspace }}/scripts/xccov-to-sonarqube-generic.sh $(find . -name "*.xcresult") > ${{ github.workspace }}/reports/sonarqube-generic-coverage.xml
sed -i '' "s#${{ github.workspace }}/example/node_modules/@adyen/react-native/##g" ${{ github.workspace }}/reports/sonarqube-generic-coverage.xml
- name: SwiftLint
working-directory: ios
run: fastlane run swiftlint output_file:"${{ github.workspace }}/reports/swiftlint.json" reporter:"json" ignore_exit_status:"true"

- name: Archive Coverage report
uses: actions/upload-artifact@v3
with:
name: swift-coverage-report
path: reports

test-Android:
name: Test Android
needs: [build-lib]
runs-on: macos-13-large
env:
api-level: 29
target: google_apis
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version: ${{ env.node-version }}
cache: 'yarn'

- name: Setup Java 11
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '11'
cache: 'gradle'

- uses: actions/cache/restore@v3
with:
path: lib
key: temp-lib-${{ github.sha }}

- uses: actions/cache/restore@v3
id: yarn-cache
with:
path: |
node_modules
example\node_modules
key: temp-node-${{ github.sha }}

- name: Build dependency if needed
if: steps.yarn-cache.outputs.cache-hit != 'true'
run: yarn

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

- name: AVD cache
uses: actions/cache@v3
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-${{ env.api-level }}

- 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: ${{ env.api-level }}
target: ${{ env.target }}
force-avd-creation: false
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: false
script: echo "Generated AVD snapshot for caching."

- name: Run tests
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ env.api-level }}
target: ${{ env.target }}
force-avd-creation: false
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: true
working-directory: ./example/android
pre-emulator-launch-script: |
sdkmanager --list
script: |
echo "::group::Running Android app"
yarn android
echo "::endgroup::"
echo "::group::Running Gradle Build"
./gradlew connectedCheck
echo "::endgroup::"
run-sonar:
name: Collect Sonar reports
needs: [build-lib, test-iOS]
runs-on: macos-latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
steps:
- uses: actions/checkout@v4

- name: Install Tools
run: |
brew install sonar-scanner
- uses: actions/cache/restore@v3
id: lib-cache
with:
path: lib
key: temp-lib-${{ github.sha }}

- name: Build dependency if needed
if: steps.lib-cache.outputs.cache-hit != 'true'
run: yarn

- name: Download Swift coverage report
uses: actions/download-artifact@v3
with:
name: swift-coverage-report
path: reports

- name: Run Sonar
run: |
git fetch --unshallow --no-tags
sonar-scanner -Dsonar.token=${{ secrets.SONAR_TOKEN }}
delete-chach:
name: Clean up
runs-on: ubuntu-latest
needs: [run-sonar, test-Android]
if: always()
steps:
- uses: actions/checkout@v4
- name: Delete temporary cache
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh cache delete temp-lib-${{ github.sha }}
gh cache delete temp-node-${{ github.sha }}
5 changes: 1 addition & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,4 @@ android/app/libs
android/keystores/debug.keystore

# yarn
example/yarn.lock

# Cocoapods
Podfile.lock
example/yarn.lock
6 changes: 3 additions & 3 deletions .swiftformat
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
--disable blankLinesAtStartOfScope,blankLinesAtEndOfScope,unusedArguments,redundantSelf,wrapMultilineStatementBraces,extensionAccessControl,redundantClosure
--swiftversion "5.5"
--disable blankLinesAtStartOfScope,blankLinesAtEndOfScope,unusedArguments,redundantSelf,wrapMultilineStatementBraces,extensionAccessControl,redundantClosure,redundantInternal
--swiftversion "5.7"
--commas inline
--ranges nospace
--trimwhitespace nonblank-lines
--decimalgrouping none
--decimalgrouping none

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright (c) 2021 Adyen N.V.
*
* This file is open source and available under the MIT license. See the LICENSE file for more info.
*/
package com.adyenreactnativesdk

import com.adyenreactnativesdk.component.applepay.AdyenApplePayMock
import com.adyenreactnativesdk.component.dropin.AdyenDropInComponent
import com.adyenreactnativesdk.component.googlepay.AdyenGooglePayComponent
import com.adyenreactnativesdk.component.instant.AdyenInstantComponent
import com.adyenreactnativesdk.cse.AdyenCSEModule
import com.facebook.react.ReactPackage
import com.facebook.react.bridge.NativeModule
import com.facebook.react.bridge.ReactApplicationContext
import com.facebook.react.uimanager.ViewManager

class AdyenPaymentPackage : ReactPackage {
override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
return emptyList()
}

override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> {
val modules: MutableList<NativeModule> = ArrayList()
modules.add(AdyenDropInComponent(reactContext))
modules.add(AdyenInstantComponent(reactContext))
modules.add(AdyenGooglePayComponent(reactContext))
modules.add(AdyenApplePayMock(reactContext))
modules.add(AdyenCSEModule(reactContext))
return modules
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import com.facebook.react.bridge.ReactContextBaseJavaModule
import com.facebook.react.bridge.ReadableMap
import com.facebook.react.modules.core.DeviceEventManagerModule.RCTDeviceEventEmitter
import org.json.JSONException
import org.json.JSONObject
import java.util.*

abstract class BaseModule(context: ReactApplicationContext?) : ReactContextBaseJavaModule(context) {
Expand All @@ -30,6 +31,16 @@ abstract class BaseModule(context: ReactApplicationContext?) : ReactContextBaseJ
.emit(eventName, map)
}

protected fun sendEvent(eventName: String, jsonObject: JSONObject) {
try {
reactApplicationContext
.getJSModule(RCTDeviceEventEmitter::class.java)
.emit(eventName, ReactNativeJson.convertJsonToMap(jsonObject))
} catch (e: JSONException) {
sendErrorEvent(e)
}
}

protected fun sendErrorEvent(error: Exception) {
reactApplicationContext
.getJSModule(RCTDeviceEventEmitter::class.java)
Expand Down
Loading

0 comments on commit cc22e2a

Please sign in to comment.