diff --git a/.github/workflows/android-lint.yml b/.github/workflows/android-lint.yml new file mode 100644 index 000000000..8ecf2bb0a --- /dev/null +++ b/.github/workflows/android-lint.yml @@ -0,0 +1,14 @@ +on: + workflow_call: + inputs: + module: + description: 'Module to run' + required: true + type: string +jobs: + android-lint: + uses: ./.github/workflows/gradle-task.yml + with: + module: ${{ inputs.module }} + task: lint + task-name: Run Android Lint Check diff --git a/.github/workflows/assemble-module.yml b/.github/workflows/assemble-module.yml new file mode 100644 index 000000000..0b3969845 --- /dev/null +++ b/.github/workflows/assemble-module.yml @@ -0,0 +1,18 @@ +on: + workflow_call: + inputs: + module: + description: 'Module to run' + required: true + type: string + variant: + description: 'Variant to build' + required: true + type: string +jobs: + assemble: + uses: ./.github/workflows/gradle-task.yml + with: + module: ${{ inputs.module }} + task: assemble${{inputs.variant}} + task-name: Assemble ${{inputs.module}} - ${{inputs.variant}} diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index fce8dab35..8c995d86e 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -7,6 +7,13 @@ on: # The branches below must be a subset of the branches above types: [ opened, synchronize, reopened ] branches: [ master, "bugfix/*", "feature/*", "release/*" ] + paths: + - 'checkout/**' + - 'example_app_frames/**' + - 'app/**' + - 'frames/**' + - 'buildSrc/**' + - 'build.gradle.kt' schedule: - cron: '34 2 * * 0' @@ -34,11 +41,11 @@ jobs: with: submodules: recursive - - name: Set up JDK 11 + - name: Set up JDK 17 uses: actions/setup-java@v3 with: - java-version: '11' - distribution: corretto + java-version: '17' + distribution: 'temurin' cache: gradle - name: Grant execute permission for gradlew diff --git a/.github/workflows/gradle-task.yml b/.github/workflows/gradle-task.yml new file mode 100644 index 000000000..157961b80 --- /dev/null +++ b/.github/workflows/gradle-task.yml @@ -0,0 +1,40 @@ +on: + workflow_call: + inputs: + module: + description: 'Module to run' + required: true + type: string + task: + description: 'Task to run' + required: true + type: string + task-name: + description: 'Task Name' + required: true + type: string + +jobs: + task: + name: ${{ inputs.task-name }} + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v3 + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'temurin' + cache: gradle + - name: Grant execute permission for gradlew + run: chmod +x gradlew + - name: Cache Gradle and wrapper + uses: actions/cache@v3 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }} + - name: Run unit tests with Gradle + run: ./gradlew :${{ inputs.module }}:${{ inputs.task }} diff --git a/.github/workflows/ktlint.yml b/.github/workflows/ktlint.yml new file mode 100644 index 000000000..796918e10 --- /dev/null +++ b/.github/workflows/ktlint.yml @@ -0,0 +1,14 @@ +on: + workflow_call: + inputs: + module: + description: 'Module to run' + required: true + type: string +jobs: + ktlint: + uses: ./.github/workflows/gradle-task.yml + with: + module: ${{ inputs.module }} + task: ktlint + task-name: Run Ktlint Check diff --git a/.github/workflows/ui-test.yml b/.github/workflows/ui-test.yml new file mode 100644 index 000000000..16e3106dd --- /dev/null +++ b/.github/workflows/ui-test.yml @@ -0,0 +1,47 @@ +name: UI Test + +on: + workflow_call: + inputs: + module: + description: 'Module to run' + required: true + type: string + +jobs: + connected-android-tests: + name: Run Connected Android Tests + # Run on macOS because we need to run the emulator and the emulator is not supported on Linux + runs-on: macos-latest + strategy: + fail-fast: true + + steps: + - name: Checkout Code + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'temurin' + cache: gradle + + - name: Grant execute permission for gradlew + run: chmod +x gradlew + + - name: Cache Gradle and wrapper + uses: actions/cache@v3 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }} + + - name: Launch Emulator + run: chmod +x ./scripts/launch-emulator.sh && ./scripts/launch-emulator.sh + + - name: Run UI Test on ${{ inputs.module }} + run: ./gradlew :${{ inputs.module }}:connectedAndroidTest --stacktrace \ No newline at end of file diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml new file mode 100644 index 000000000..ef2e5a3c6 --- /dev/null +++ b/.github/workflows/unit-test.yml @@ -0,0 +1,14 @@ +on: + workflow_call: + inputs: + module: + description: 'Module to run' + required: true + type: string +jobs: + unit-test: + uses: ./.github/workflows/gradle-task.yml + with: + module: ${{ inputs.module }} + task: test + task-name: Run Unit Tests diff --git a/.github/workflows/verification-flow.yml b/.github/workflows/verification-flow.yml new file mode 100644 index 000000000..7195c1503 --- /dev/null +++ b/.github/workflows/verification-flow.yml @@ -0,0 +1,73 @@ +name: Verification + +on: + workflow_call: + inputs: + module: + description: 'Module to run' + required: true + type: string + run-android-lint: + description: 'Should Run Android Lint' + required: false + type: boolean + default: false + run-ktlint: + description: 'Should Run Ktlint' + required: false + type: boolean + default: false + run-assemble: + description: 'Should Run Assemble' + required: false + type: boolean + default: false + assemble-variant: + description: 'Variant to Run Assemble' + required: false + type: string + default: '' + run-unit-test: + description: 'Should Run Unit Tests' + required: false + type: boolean + default: false + run-ui-test: + description: 'Should Run UI Tests' + required: false + type: boolean + default: false + +jobs: + android-lint: + if: ${{ inputs.run-android-lint }} + uses: ./.github/workflows/android-lint.yml + with: + module: ${{ inputs.module }} + ktlint: + if: ${{ inputs.run-ktlint }} + uses: ./.github/workflows/ktlint.yml + with: + module: ${{ inputs.module }} + assemble: + if: ${{ inputs.run-assemble }} + uses: ./.github/workflows/assemble-module.yml + # Add ktlint after ktlint is applied to all modules + needs: android-lint + with: + module: ${{ inputs.module }} + variant: ${{ inputs.assemble-variant }} + unit-test: + if: ${{ inputs.run-unit-test }} + uses: ./.github/workflows/unit-test.yml + # Add ktlint after ktlint is applied to all modules + needs: android-lint + with: + module: ${{ inputs.module }} + ui-test: + if: ${{ inputs.run-ui-test }} + uses: ./.github/workflows/ui-test.yml + # Add ktlint after ktlint is applied to all modules + needs: android-lint + with: + module: ${{ inputs.module }} diff --git a/.github/workflows/verify-app.yml b/.github/workflows/verify-app.yml new file mode 100644 index 000000000..5d5d003e5 --- /dev/null +++ b/.github/workflows/verify-app.yml @@ -0,0 +1,28 @@ +name: Verify App + +on: + push: + branches: [ master ] + pull_request: + # The branches below must be a subset of the branches above + types: [ opened, synchronize, reopened ] + branches: [ master, "bugfix/*", "feature/*", "release/*" ] + paths: + - 'app/**' + - 'checkout/**' + - 'frames/**' + - 'buildSrc/**' + - 'build.gradle.kt' + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +jobs: + verify-module: + uses: ./.github/workflows/verification-flow.yml + with: + module: app + run-android-lint: true + run-assemble: true + run-unit-test: true diff --git a/.github/workflows/verify-checkout.yml b/.github/workflows/verify-checkout.yml new file mode 100644 index 000000000..6ceb0c37f --- /dev/null +++ b/.github/workflows/verify-checkout.yml @@ -0,0 +1,27 @@ +name: Verify Checkout + +on: + push: + branches: [ master ] + pull_request: + # The branches below must be a subset of the branches above + types: [ opened, synchronize, reopened ] + branches: [ master, "bugfix/*", "feature/*", "release/*" ] + paths: + - 'checkout/**' + - 'buildSrc/**' + - 'build.gradle.kt' + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +jobs: + verify-module: + uses: ./.github/workflows/verification-flow.yml + with: + module: checkout + run-android-lint: true + run-ktlint: true + run-assemble: true + run-unit-test: true diff --git a/.github/workflows/verify-example-app-frames.yml b/.github/workflows/verify-example-app-frames.yml new file mode 100644 index 000000000..12dd8fcfe --- /dev/null +++ b/.github/workflows/verify-example-app-frames.yml @@ -0,0 +1,29 @@ +name: Verify Example App Frames + +on: + push: + branches: [ master ] + pull_request: + # The branches below must be a subset of the branches above + types: [ opened, synchronize, reopened ] + branches: [ master, "bugfix/*", "feature/*", "release/*" ] + paths: + - 'checkout/**' + - 'frames/**' + - 'example_app_frames/**' + - 'buildSrc/**' + - 'build.gradle.kt' + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +jobs: + verify-module: + uses: ./.github/workflows/verification-flow.yml + with: + module: example_app_frames + run-android-lint: true + run-ktlint: true + run-assemble: true + run-unit-test: true diff --git a/.github/workflows/verify-frames.yml b/.github/workflows/verify-frames.yml new file mode 100644 index 000000000..5a6f87c0f --- /dev/null +++ b/.github/workflows/verify-frames.yml @@ -0,0 +1,29 @@ +name: Verify Frames + +on: + push: + branches: [ master ] + pull_request: + # The branches below must be a subset of the branches above + types: [ opened, synchronize, reopened ] + branches: [ master, "bugfix/*", "feature/*", "release/*" ] + paths: + - 'checkout/**' + - 'frames/**' + - 'buildSrc/**' + - 'build.gradle.kt' + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +jobs: + verify-module: + uses: ./.github/workflows/verification-flow.yml + with: + module: frames + run-android-lint: true + run-ktlint: true + run-assemble: true + run-unit-test: true + run-ui-test: true diff --git a/.github/workflows/verify-pr.yml b/.github/workflows/verify-pr.yml deleted file mode 100644 index a8c535cfa..000000000 --- a/.github/workflows/verify-pr.yml +++ /dev/null @@ -1,62 +0,0 @@ -name: Verify Pull Request - -on: - push: - branches: [ master ] - pull_request: - # The branches below must be a subset of the branches above - types: [ opened, synchronize, reopened ] - branches: [ master, "bugfix/*", "feature/*", "release/*" ] - -concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: true - -jobs: - lint: - name: Code Lint - runs-on: ubuntu-latest - permissions: - pull-requests: read - steps: - - name: Checkout Code - uses: actions/checkout@v3 - - name: Set up JDK 11 - uses: actions/setup-java@v3 - with: - java-version: 11 - distribution: corretto - cache: gradle - - name: Grant execute permission for gradlew - run: chmod +x gradlew - - name: Cache Gradle and wrapper - uses: actions/cache@v3 - with: - path: | - ~/.gradle/caches - ~/.gradle/wrapper - key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }} - - name: Run Android Lint - run: ./gradlew lint - - name: Run KtLint - run: ./gradlew ktlint - - test: - name: Unit Tests - runs-on: ubuntu-latest - permissions: - pull-requests: read - needs: lint - steps: - - name: Checkout Code - uses: actions/checkout@v3 - - name: Set up JDK 11 - uses: actions/setup-java@v3 - with: - java-version: 11 - distribution: corretto - cache: gradle - - name: Grant execute permission for gradlew - run: chmod +x gradlew - - name: Run unit tests - run: ./gradlew test diff --git a/app/build.gradle b/app/build.gradle index df579d935..4d99286a0 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,11 +1,14 @@ -apply plugin: 'com.android.application' +plugins { + id("com.android.application") +} android { - compileSdkVersion 33 + namespace = "checkout.checkout_android" + compileSdk = 34 defaultConfig { applicationId "checkout.checkout_android" minSdkVersion 24 - targetSdkVersion 33 + targetSdkVersion 34 versionCode 1 versionName "1.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" @@ -24,8 +27,8 @@ android { } compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 + sourceCompatibility JavaVersion.VERSION_17 + targetCompatibility JavaVersion.VERSION_17 } buildTypes { @@ -43,17 +46,17 @@ android { } dependencies { - implementation'androidx.activity:activity:1.6.1' + implementation 'androidx.activity:activity:1.8.0' testImplementation 'junit:junit:4.13.2' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' - androidTestImplementation 'androidx.test:runner:1.4.0' - androidTestImplementation 'androidx.test:rules:1.4.0' - androidTestImplementation 'androidx.test.espresso:espresso-intents:3.4.0' - androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.4.0' - androidTestImplementation 'androidx.test.ext:junit:1.1.3' - androidTestUtil 'androidx.test:orchestrator:1.4.1' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' + androidTestImplementation 'androidx.test:runner:1.5.2' + androidTestImplementation 'androidx.test:rules:1.5.0' + androidTestImplementation 'androidx.test.espresso:espresso-intents:3.5.1' + androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.5.1' + androidTestImplementation 'androidx.test.ext:junit:1.1.5' + androidTestUtil 'androidx.test:orchestrator:1.4.2' - ext.okHttpVersion = '4.9.0' + ext.okHttpVersion = '4.11.0' implementation 'com.squareup.okhttp3:okhttp:' + ext.okHttpVersion implementation 'com.squareup.okhttp3:logging-interceptor:' + ext.okHttpVersion diff --git a/app/lint-baseline.xml b/app/lint-baseline.xml index a958d384e..0286a78c1 100644 --- a/app/lint-baseline.xml +++ b/app/lint-baseline.xml @@ -1,110 +1,66 @@ - + - - + errorLine1=" targetSdkVersion 31" errorLine2=" ~~~~~~~~~~~~~~~~~~~"> + - - + - - + - - + - - + - - + - - + - - + - - + - - + + diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index d77607cc1..7834839c7 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,6 +1,6 @@ + xmlns:tools="http://schemas.android.com/tools"> @@ -11,7 +11,8 @@ android:roundIcon="@mipmap/ic_launcher_round" android:fullBackupContent="true" android:supportsRtl="true" - android:theme="@style/AppTheme"> + android:theme="@style/AppTheme" + tools:ignore="MonochromeLauncherIcon"> Log.d("okhttp", message)); @@ -96,8 +94,7 @@ public void onResponse(@NotNull Call call, @NotNull Response response) { } } catch (Exception e) { e.printStackTrace(); - } - finally { + } finally { postResponse(result, redirectUrl); } } diff --git a/app/src/main/res/drawable/ic_launcher_foreground.xml b/app/src/main/res/drawable/ic_launcher_foreground.xml new file mode 100644 index 000000000..c7bd21dbd --- /dev/null +++ b/app/src/main/res/drawable/ic_launcher_foreground.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml index eca70cfe5..2742e7c04 100644 --- a/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -1,5 +1,7 @@ - + \ No newline at end of file diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 96a07fe9c..cfc9ef93c 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -1,4 +1,5 @@ - + + -