From efaea9bb89cedff8213804dd2724a42e114d1156 Mon Sep 17 00:00:00 2001 From: Evan Sims Date: Wed, 20 Sep 2023 21:25:42 -0500 Subject: [PATCH 01/36] test: Migrate CI to GitHub --- .github/actions/setup/action.yml | 27 ++++++++++ .github/dependabot.yml | 6 +++ .github/workflows/codeql.yml | 53 +++++++++++++++++++ .../workflows/gradle-wrapper-validation.yml | 10 ---- .github/workflows/matrix.json | 7 +++ .github/workflows/publish.yml | 30 +++++++++++ .github/workflows/semgrep.yml | 44 +++++++++++---- .github/workflows/snyk.yml | 47 ++++++++++++++++ .github/workflows/test.yml | 37 +++++++++++++ 9 files changed, 241 insertions(+), 20 deletions(-) create mode 100644 .github/actions/setup/action.yml create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/codeql.yml delete mode 100644 .github/workflows/gradle-wrapper-validation.yml create mode 100644 .github/workflows/matrix.json create mode 100644 .github/workflows/publish.yml create mode 100644 .github/workflows/snyk.yml create mode 100644 .github/workflows/test.yml diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml new file mode 100644 index 00000000..203401ba --- /dev/null +++ b/.github/actions/setup/action.yml @@ -0,0 +1,27 @@ +name: Configure CI +description: Performs the initial configuration of the CI environment + +inputs: + java: + description: The Java version to use + required: false + default: | # https://github.com/actions/setup-java#install-multiple-jdks + 8 + distribution: + description: The distribution to use + required: false + default: 'temurin' + +runs: + using: composite + + steps: + - name: Set up JDK + uses: actions/setup-java@v3 + with: + java-version: ${{ inputs.java }} + distribution: ${{ inputs.distribution }} + cache: 'gradle' + + - name: Setup Android SDK + uses: android-actions/setup-android@7c5672355aaa8fde5f97a91aa9a99616d1ace6bc # pin@2.0.10 diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000..6778b049 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,6 @@ +version: 2 +updates: + - package-ecosystem: 'github-actions' + directory: '/' + schedule: + interval: 'daily' diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml new file mode 100644 index 00000000..7b17bd96 --- /dev/null +++ b/.github/workflows/codeql.yml @@ -0,0 +1,53 @@ +name: CodeQL + +on: + merge_group: + pull_request: + types: + - opened + - synchronize + push: + branches: + - main + schedule: + - cron: "37 10 * * 2" + +permissions: + actions: read + contents: read + security-events: write + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} + +jobs: + analyze: + name: Check for Vulnerabilities + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + language: [java] + + steps: + - if: github.actor == 'dependabot[bot]' || github.event_name == 'merge_group' + run: exit 0 # Skip unnecessary test runs for dependabot and merge queues. Artifically flag as successful, as this is a required check for branch protection. + + - name: Checkout + uses: actions/checkout@v4 + + - name: Initialize CodeQL + uses: github/codeql-action/init@v2 + with: + languages: ${{ matrix.language }} + queries: +security-and-quality + + - name: Autobuild + uses: github/codeql-action/autobuild@v2 + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v2 + with: + category: "/language:${{ matrix.language }}" diff --git a/.github/workflows/gradle-wrapper-validation.yml b/.github/workflows/gradle-wrapper-validation.yml deleted file mode 100644 index 51a7d1a7..00000000 --- a/.github/workflows/gradle-wrapper-validation.yml +++ /dev/null @@ -1,10 +0,0 @@ -name: "Validate Gradle Wrapper" -on: [push, pull_request] - -jobs: - validation: - name: "validation/gradlew" - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: gradle/wrapper-validation-action@8d49e559aae34d3e0eb16cde532684bc9702762b # pin@1.0.6 diff --git a/.github/workflows/matrix.json b/.github/workflows/matrix.json new file mode 100644 index 00000000..a70a772f --- /dev/null +++ b/.github/workflows/matrix.json @@ -0,0 +1,7 @@ +{ + "include": [ + { "android": "30" }, + { "android": "31" }, + { "android": "32" } + ] +} diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 00000000..270d2e67 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,30 @@ +name: Publish Release + +on: + workflow_dispatch: + inputs: + branch: + description: The branch to release from. + required: true + default: main + +permissions: + contents: read + +jobs: + publish: + name: Publish to Maven Central + runs-on: ubuntu-latest + environment: release + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + ref: ${{ github.event.inputs.branch }} + + - uses: ./.github/actions/setup + + - uses: gradle/gradle-build-action@ef76a971e2fa3f867b617efd72f2fbd72cf6f8bc + with: + arguments: build diff --git a/.github/workflows/semgrep.yml b/.github/workflows/semgrep.yml index 10e8f8fb..59f1c7f2 100644 --- a/.github/workflows/semgrep.yml +++ b/.github/workflows/semgrep.yml @@ -1,24 +1,48 @@ - name: Semgrep on: - pull_request: {} - + merge_group: + pull_request_target: + types: + - opened + - synchronize push: - branches: ["master", "main"] - + branches: + - main schedule: - - cron: '30 0 1,15 * *' + - cron: "30 0 1,15 * *" + +permissions: + contents: read + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} jobs: - semgrep: - name: Scan + authorize: + name: Authorize + environment: ${{ github.actor != 'dependabot[bot]' && github.event_name == 'pull_request_target' && github.event.pull_request.head.repo.full_name != github.repository && 'external' || 'internal' }} + runs-on: ubuntu-latest + steps: + - run: true + + run: + needs: authorize # Require approval before running on forked pull requests + + name: Check for Vulnerabilities runs-on: ubuntu-latest + container: image: returntocorp/semgrep - if: (github.actor != 'dependabot[bot]') + steps: - - uses: actions/checkout@v3 + - if: github.actor == 'dependabot[bot]' || github.event_name == 'merge_group' + run: exit 0 # Skip unnecessary test runs for dependabot and merge queues. Artifically flag as successful, as this is a required check for branch protection. + + - uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha || github.ref }} - run: semgrep ci env: diff --git a/.github/workflows/snyk.yml b/.github/workflows/snyk.yml new file mode 100644 index 00000000..cd4d5868 --- /dev/null +++ b/.github/workflows/snyk.yml @@ -0,0 +1,47 @@ +name: Snyk + +on: + merge_group: + workflow_dispatch: + pull_request_target: + types: + - opened + - synchronize + push: + branches: + - main + schedule: + - cron: "30 0 1,15 * *" + +permissions: + contents: read + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} + +jobs: + authorize: + name: Authorize + environment: ${{ github.actor != 'dependabot[bot]' && github.event_name == 'pull_request_target' && github.event.pull_request.head.repo.full_name != github.repository && 'external' || 'internal' }} + runs-on: ubuntu-latest + steps: + - run: true + + check: + needs: authorize + + name: Check for Vulnerabilities + runs-on: ubuntu-latest + + steps: + - if: github.actor == 'dependabot[bot]' || github.event_name == 'merge_group' + run: exit 0 # Skip unnecessary test runs for dependabot and merge queues. Artifically flag as successful, as this is a required check for branch protection. + + - uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha || github.ref }} + + - uses: snyk/actions/php@b98d498629f1c368650224d6d212bf7dfa89e4bf # pin@0.4.0 + env: + SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 00000000..be91eb6c --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,37 @@ +name: Build and Test + +on: + merge_group: + workflow_dispatch: + pull_request: + branches: + - main + push: + branches: + - main + +permissions: + contents: read + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} + +env: + CACHE_KEY: "${{ github.ref }}-${{ github.run_id }}-${{ github.run_attempt }}" + +jobs: + unit: + name: Run Unit Tests + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - uses: ./.github/actions/setup + + - uses: gradle/wrapper-validation-action@56b90f209b02bf6d1deae490e9ef18b21a389cd4 # pin@1.1.0 + + - run: ./gradlew clean test jacocoTestReport lint --continue --console=plain --max-workers=1 --no-daemon + + - uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d # pin@3.1.4 From c5aeef537451a975d46d32117995d769fffdd1ce Mon Sep 17 00:00:00 2001 From: Evan Sims Date: Wed, 20 Sep 2023 21:40:32 -0500 Subject: [PATCH 02/36] Update action.yml --- .github/actions/setup/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml index 203401ba..ae890aa7 100644 --- a/.github/actions/setup/action.yml +++ b/.github/actions/setup/action.yml @@ -6,7 +6,7 @@ inputs: description: The Java version to use required: false default: | # https://github.com/actions/setup-java#install-multiple-jdks - 8 + 11 distribution: description: The distribution to use required: false From 67cd7f0c8d07a64bc0bf9b48fcf3a7ea333662d9 Mon Sep 17 00:00:00 2001 From: Evan Sims Date: Wed, 20 Sep 2023 21:40:35 -0500 Subject: [PATCH 03/36] Update test.yml --- .github/workflows/test.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index be91eb6c..72e0b531 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -17,9 +17,6 @@ concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} -env: - CACHE_KEY: "${{ github.ref }}-${{ github.run_id }}-${{ github.run_attempt }}" - jobs: unit: name: Run Unit Tests From caae760baa7053dd8f617cbf04ffcfd800ec6712 Mon Sep 17 00:00:00 2001 From: Evan Sims Date: Wed, 20 Sep 2023 21:57:18 -0500 Subject: [PATCH 04/36] Update publish.yml --- .github/workflows/publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 270d2e67..3b112a71 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -25,6 +25,6 @@ jobs: - uses: ./.github/actions/setup - - uses: gradle/gradle-build-action@ef76a971e2fa3f867b617efd72f2fbd72cf6f8bc + - uses: gradle/gradle-build-action@ef76a971e2fa3f867b617efd72f2fbd72cf6f8bc # pin@2.8.0 with: arguments: build From 41d8d35bdea08a94b21710b8d47d419bb5fec303 Mon Sep 17 00:00:00 2001 From: Evan Sims Date: Wed, 20 Sep 2023 21:57:21 -0500 Subject: [PATCH 05/36] Update test.yml --- .github/workflows/test.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 72e0b531..90d111bd 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -29,6 +29,9 @@ jobs: - uses: gradle/wrapper-validation-action@56b90f209b02bf6d1deae490e9ef18b21a389cd4 # pin@1.1.0 - - run: ./gradlew clean test jacocoTestReport lint --continue --console=plain --max-workers=1 --no-daemon + - uses: gradle/gradle-build-action@ef76a971e2fa3f867b617efd72f2fbd72cf6f8bc # pin@2.8.0 + with: + gradle-version: 6.9 + arguments: clean test jacocoTestReport lint --continue --console=plain --max-workers=1 --no-daemon - uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d # pin@3.1.4 From 52f9ff15bda7c1623ec12bc92c208dcd3d783d9e Mon Sep 17 00:00:00 2001 From: Evan Sims Date: Wed, 20 Sep 2023 22:03:48 -0500 Subject: [PATCH 06/36] Use larger runner --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 90d111bd..e917c341 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -20,7 +20,7 @@ concurrency: jobs: unit: name: Run Unit Tests - runs-on: ubuntu-latest + runs-on: ubuntu-latest-16-cores steps: - uses: actions/checkout@v4 From d4d2cb2af58363aefa82001cbdbb46e00a91bd0a Mon Sep 17 00:00:00 2001 From: Evan Sims Date: Wed, 20 Sep 2023 22:10:00 -0500 Subject: [PATCH 07/36] Update test.yml --- .github/workflows/test.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e917c341..9e151e92 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -20,7 +20,9 @@ concurrency: jobs: unit: name: Run Unit Tests - runs-on: ubuntu-latest-16-cores + runs-on: + group: ubuntu-runners + labels: ubuntu-20.04-16core steps: - uses: actions/checkout@v4 From 7f956ab7e26b00678c729f1d17dae2601f465ab3 Mon Sep 17 00:00:00 2001 From: Evan Sims Date: Wed, 20 Sep 2023 22:10:30 -0500 Subject: [PATCH 08/36] Update test.yml --- .github/workflows/test.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9e151e92..90d111bd 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -20,9 +20,7 @@ concurrency: jobs: unit: name: Run Unit Tests - runs-on: - group: ubuntu-runners - labels: ubuntu-20.04-16core + runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 From a29c7558120b26b7c4a7d0f0f597e3d0c1ec686d Mon Sep 17 00:00:00 2001 From: Evan Sims Date: Wed, 20 Sep 2023 22:19:56 -0500 Subject: [PATCH 09/36] Update action.yml --- .github/actions/setup/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml index ae890aa7..0d821761 100644 --- a/.github/actions/setup/action.yml +++ b/.github/actions/setup/action.yml @@ -6,7 +6,7 @@ inputs: description: The Java version to use required: false default: | # https://github.com/actions/setup-java#install-multiple-jdks - 11 + 1.8 distribution: description: The distribution to use required: false From 91bad2007d7fc186d13b4ef1607d2721ab0d89f5 Mon Sep 17 00:00:00 2001 From: Evan Sims Date: Wed, 20 Sep 2023 22:21:29 -0500 Subject: [PATCH 10/36] Update action.yml --- .github/actions/setup/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml index 0d821761..ae890aa7 100644 --- a/.github/actions/setup/action.yml +++ b/.github/actions/setup/action.yml @@ -6,7 +6,7 @@ inputs: description: The Java version to use required: false default: | # https://github.com/actions/setup-java#install-multiple-jdks - 1.8 + 11 distribution: description: The distribution to use required: false From bf2f2652073850a4702338cf0d241676128417bf Mon Sep 17 00:00:00 2001 From: Evan Sims Date: Wed, 20 Sep 2023 22:38:18 -0500 Subject: [PATCH 11/36] Update publish.yml --- .github/workflows/publish.yml | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 3b112a71..a0562cd1 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -27,4 +27,18 @@ jobs: - uses: gradle/gradle-build-action@ef76a971e2fa3f867b617efd72f2fbd72cf6f8bc # pin@2.8.0 with: - arguments: build + arguments: clean assemble -PisSnapshot=false + + - uses: gradle/gradle-build-action@ef76a971e2fa3f867b617efd72f2fbd72cf6f8bc # pin@2.8.0 + with: + arguments: exportVersion -PisSnapshot=false + + - uses: gradle/gradle-build-action@ef76a971e2fa3f867b617efd72f2fbd72cf6f8bc # pin@2.8.0 + with: + arguments: | + publishAndroidLibraryPublicationToMavenRepository + -PossrhUsername="${{ secrets.OSSR_USERNAME }}" + -PossrhPassword="${{ secrets.OSSR_PASSWORD }}" + -PsigningKey="${{ secrets.SIGNING_KEY }}" + -PsigningPassword="${{ secrets.SIGNING_PASSWORD }}" + -PisSnapshot=false" From 4cda1c3906480feea91e8e78cb42d7ca141ba0ab Mon Sep 17 00:00:00 2001 From: Evan Sims Date: Wed, 20 Sep 2023 22:46:31 -0500 Subject: [PATCH 12/36] Update action.yml --- .github/actions/setup/action.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml index ae890aa7..5fb7e71d 100644 --- a/.github/actions/setup/action.yml +++ b/.github/actions/setup/action.yml @@ -25,3 +25,8 @@ runs: - name: Setup Android SDK uses: android-actions/setup-android@7c5672355aaa8fde5f97a91aa9a99616d1ace6bc # pin@2.0.10 + + - name: Install Kotlin + uses: fwilhe2/setup-kotlin@main + with: + version: 1.6.0 From 816a8b428e3fae44132c0c16a9026d287d513e11 Mon Sep 17 00:00:00 2001 From: Evan Sims Date: Wed, 20 Sep 2023 22:55:50 -0500 Subject: [PATCH 13/36] Update action.yml --- .github/actions/setup/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml index 5fb7e71d..9faadb40 100644 --- a/.github/actions/setup/action.yml +++ b/.github/actions/setup/action.yml @@ -29,4 +29,4 @@ runs: - name: Install Kotlin uses: fwilhe2/setup-kotlin@main with: - version: 1.6.0 + version: 1.4 From a171ff5388959ca42db523b09751e621fb051868 Mon Sep 17 00:00:00 2001 From: Evan Sims Date: Wed, 20 Sep 2023 22:56:46 -0500 Subject: [PATCH 14/36] Update action.yml --- .github/actions/setup/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml index 9faadb40..0c7da14e 100644 --- a/.github/actions/setup/action.yml +++ b/.github/actions/setup/action.yml @@ -29,4 +29,4 @@ runs: - name: Install Kotlin uses: fwilhe2/setup-kotlin@main with: - version: 1.4 + version: 1.6 From 1fb6b99faf5296e36cc515cadee73cce10fb6209 Mon Sep 17 00:00:00 2001 From: Evan Sims Date: Wed, 20 Sep 2023 22:56:48 -0500 Subject: [PATCH 15/36] Update test.yml --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 90d111bd..a3e44226 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -31,7 +31,7 @@ jobs: - uses: gradle/gradle-build-action@ef76a971e2fa3f867b617efd72f2fbd72cf6f8bc # pin@2.8.0 with: - gradle-version: 6.9 + gradle-version: 4.2 arguments: clean test jacocoTestReport lint --continue --console=plain --max-workers=1 --no-daemon - uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d # pin@3.1.4 From e15082d935acb4ed84cb79eeaebd0e85001e343a Mon Sep 17 00:00:00 2001 From: Evan Sims Date: Wed, 20 Sep 2023 22:59:35 -0500 Subject: [PATCH 16/36] Update action.yml --- .github/actions/setup/action.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml index 0c7da14e..14707c40 100644 --- a/.github/actions/setup/action.yml +++ b/.github/actions/setup/action.yml @@ -30,3 +30,4 @@ runs: uses: fwilhe2/setup-kotlin@main with: version: 1.6 + install-native: true From 20033c92a5cfbe37e36b3168b29460bc3a4f324f Mon Sep 17 00:00:00 2001 From: Evan Sims Date: Wed, 20 Sep 2023 23:00:37 -0500 Subject: [PATCH 17/36] Update action.yml --- .github/actions/setup/action.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml index 14707c40..8c0ffd9d 100644 --- a/.github/actions/setup/action.yml +++ b/.github/actions/setup/action.yml @@ -26,6 +26,10 @@ runs: - name: Setup Android SDK uses: android-actions/setup-android@7c5672355aaa8fde5f97a91aa9a99616d1ace6bc # pin@2.0.10 + - uses: gradle/gradle-build-action@ef76a971e2fa3f867b617efd72f2fbd72cf6f8bc # pin@2.8.0 + with: + gradle-version: 4.2 + - name: Install Kotlin uses: fwilhe2/setup-kotlin@main with: From 763b6381c85f447ec12b3524454584bc18501b6a Mon Sep 17 00:00:00 2001 From: Evan Sims Date: Wed, 20 Sep 2023 23:00:39 -0500 Subject: [PATCH 18/36] Update test.yml --- .github/workflows/test.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a3e44226..53a5f0ff 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -31,7 +31,6 @@ jobs: - uses: gradle/gradle-build-action@ef76a971e2fa3f867b617efd72f2fbd72cf6f8bc # pin@2.8.0 with: - gradle-version: 4.2 arguments: clean test jacocoTestReport lint --continue --console=plain --max-workers=1 --no-daemon - uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d # pin@3.1.4 From 04c2c55d693d4cda312f655f9cc31d2b3fe02d56 Mon Sep 17 00:00:00 2001 From: Evan Sims Date: Wed, 20 Sep 2023 23:09:08 -0500 Subject: [PATCH 19/36] Update action.yml --- .github/actions/setup/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml index 8c0ffd9d..f0212215 100644 --- a/.github/actions/setup/action.yml +++ b/.github/actions/setup/action.yml @@ -33,5 +33,5 @@ runs: - name: Install Kotlin uses: fwilhe2/setup-kotlin@main with: - version: 1.6 + version: 1.6.21 install-native: true From 18797b7d6e40cb09ba1141879f0c0298d6b01678 Mon Sep 17 00:00:00 2001 From: Evan Sims Date: Wed, 20 Sep 2023 23:23:08 -0500 Subject: [PATCH 20/36] Update test.yml --- .github/workflows/test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 53a5f0ff..a3e44226 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -31,6 +31,7 @@ jobs: - uses: gradle/gradle-build-action@ef76a971e2fa3f867b617efd72f2fbd72cf6f8bc # pin@2.8.0 with: + gradle-version: 4.2 arguments: clean test jacocoTestReport lint --continue --console=plain --max-workers=1 --no-daemon - uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d # pin@3.1.4 From ecea1e5eda7b38206fca6904c54e2734a57497cf Mon Sep 17 00:00:00 2001 From: Evan Sims Date: Wed, 20 Sep 2023 23:36:56 -0500 Subject: [PATCH 21/36] Update test.yml --- .github/workflows/test.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a3e44226..72e0b531 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -29,9 +29,6 @@ jobs: - uses: gradle/wrapper-validation-action@56b90f209b02bf6d1deae490e9ef18b21a389cd4 # pin@1.1.0 - - uses: gradle/gradle-build-action@ef76a971e2fa3f867b617efd72f2fbd72cf6f8bc # pin@2.8.0 - with: - gradle-version: 4.2 - arguments: clean test jacocoTestReport lint --continue --console=plain --max-workers=1 --no-daemon + - run: ./gradlew clean test jacocoTestReport lint --continue --console=plain --max-workers=1 --no-daemon - uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d # pin@3.1.4 From ed9272489844ac03987e28a40ce24b6f50193e71 Mon Sep 17 00:00:00 2001 From: Evan Sims Date: Wed, 20 Sep 2023 23:36:58 -0500 Subject: [PATCH 22/36] Update action.yml --- .github/actions/setup/action.yml | 55 ++++++++++++++++++++------------ 1 file changed, 34 insertions(+), 21 deletions(-) diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml index f0212215..9b2d7840 100644 --- a/.github/actions/setup/action.yml +++ b/.github/actions/setup/action.yml @@ -5,33 +5,46 @@ inputs: java: description: The Java version to use required: false - default: | # https://github.com/actions/setup-java#install-multiple-jdks - 11 - distribution: - description: The distribution to use + default: 2021.07.07-tem + gradle: + description: The Gradle version to use required: false - default: 'temurin' + default: 4.2 + kotlin: + description: The Kotlin version to use + required: false + default: 1.6.21 runs: using: composite steps: - - name: Set up JDK - uses: actions/setup-java@v3 - with: - java-version: ${{ inputs.java }} - distribution: ${{ inputs.distribution }} - cache: 'gradle' + # - name: Set up JDK + # uses: actions/setup-java@v3 + # with: + # java-version: ${{ inputs.java }} + # distribution: ${{ inputs.distribution }} + # cache: 'gradle' + + - run: | + curl -s "https://get.sdkman.io" | bash + sdk install java ${{ inputs.java }} + sdk default java ${{ inputs.java }} + sdk install gradle ${{ inputs.gradle }} + sdk default gradle ${{ inputs.gradle }} + sdk install kotlin ${{ inputs.kotlin }} + sdk default kotlin ${{ inputs.kotlin }} + shell: bash - - name: Setup Android SDK - uses: android-actions/setup-android@7c5672355aaa8fde5f97a91aa9a99616d1ace6bc # pin@2.0.10 + # - name: Setup Android SDK + # uses: android-actions/setup-android@7c5672355aaa8fde5f97a91aa9a99616d1ace6bc # pin@2.0.10 - - uses: gradle/gradle-build-action@ef76a971e2fa3f867b617efd72f2fbd72cf6f8bc # pin@2.8.0 - with: - gradle-version: 4.2 + # - uses: gradle/gradle-build-action@ef76a971e2fa3f867b617efd72f2fbd72cf6f8bc # pin@2.8.0 + # with: + # gradle-version: 4.2 - - name: Install Kotlin - uses: fwilhe2/setup-kotlin@main - with: - version: 1.6.21 - install-native: true + # - name: Install Kotlin + # uses: fwilhe2/setup-kotlin@main + # with: + # version: 1.6.21 + # install-native: true From c3e30e3c1a44b8677f8f8e4ed03c95dc79fa212e Mon Sep 17 00:00:00 2001 From: Evan Sims Date: Wed, 20 Sep 2023 23:37:55 -0500 Subject: [PATCH 23/36] Update action.yml --- .github/actions/setup/action.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml index 9b2d7840..63e2a704 100644 --- a/.github/actions/setup/action.yml +++ b/.github/actions/setup/action.yml @@ -28,6 +28,7 @@ runs: - run: | curl -s "https://get.sdkman.io" | bash + source "/home/runner/.sdkman/bin/sdkman-init.sh" sdk install java ${{ inputs.java }} sdk default java ${{ inputs.java }} sdk install gradle ${{ inputs.gradle }} From 5810a599414d8d49742bfa23e8fd381836225ab7 Mon Sep 17 00:00:00 2001 From: Evan Sims Date: Wed, 20 Sep 2023 23:38:38 -0500 Subject: [PATCH 24/36] Update action.yml --- .github/actions/setup/action.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml index 63e2a704..b5e2ce8b 100644 --- a/.github/actions/setup/action.yml +++ b/.github/actions/setup/action.yml @@ -29,6 +29,7 @@ runs: - run: | curl -s "https://get.sdkman.io" | bash source "/home/runner/.sdkman/bin/sdkman-init.sh" + sdk list java sdk install java ${{ inputs.java }} sdk default java ${{ inputs.java }} sdk install gradle ${{ inputs.gradle }} From 870bada884288f6b0c124178b0ddefdc51e90471 Mon Sep 17 00:00:00 2001 From: Evan Sims Date: Wed, 20 Sep 2023 23:39:39 -0500 Subject: [PATCH 25/36] Update action.yml --- .github/actions/setup/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml index b5e2ce8b..f55983e3 100644 --- a/.github/actions/setup/action.yml +++ b/.github/actions/setup/action.yml @@ -5,7 +5,7 @@ inputs: java: description: The Java version to use required: false - default: 2021.07.07-tem + default: 8.0.382-tem gradle: description: The Gradle version to use required: false From a753a3f16672e008cf965d54effe09e1bf805262 Mon Sep 17 00:00:00 2001 From: Evan Sims Date: Wed, 20 Sep 2023 23:55:29 -0500 Subject: [PATCH 26/36] Update action.yml --- .github/actions/setup/action.yml | 29 ++++------------------------- 1 file changed, 4 insertions(+), 25 deletions(-) diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml index f55983e3..ba444a76 100644 --- a/.github/actions/setup/action.yml +++ b/.github/actions/setup/action.yml @@ -19,34 +19,13 @@ runs: using: composite steps: - # - name: Set up JDK - # uses: actions/setup-java@v3 - # with: - # java-version: ${{ inputs.java }} - # distribution: ${{ inputs.distribution }} - # cache: 'gradle' - - run: | curl -s "https://get.sdkman.io" | bash source "/home/runner/.sdkman/bin/sdkman-init.sh" sdk list java - sdk install java ${{ inputs.java }} - sdk default java ${{ inputs.java }} - sdk install gradle ${{ inputs.gradle }} - sdk default gradle ${{ inputs.gradle }} - sdk install kotlin ${{ inputs.kotlin }} - sdk default kotlin ${{ inputs.kotlin }} + sdk install java ${{ inputs.java }} && sdk default java ${{ inputs.java }} + sdk install gradle ${{ inputs.gradle }} && sdk default gradle ${{ inputs.gradle }} + sdk install kotlin ${{ inputs.kotlin }} && sdk default kotlin ${{ inputs.kotlin }} shell: bash - # - name: Setup Android SDK - # uses: android-actions/setup-android@7c5672355aaa8fde5f97a91aa9a99616d1ace6bc # pin@2.0.10 - - # - uses: gradle/gradle-build-action@ef76a971e2fa3f867b617efd72f2fbd72cf6f8bc # pin@2.8.0 - # with: - # gradle-version: 4.2 - - # - name: Install Kotlin - # uses: fwilhe2/setup-kotlin@main - # with: - # version: 1.6.21 - # install-native: true + - uses: gradle/wrapper-validation-action@56b90f209b02bf6d1deae490e9ef18b21a389cd4 # pin@1.1.0 From 7c7c0a23f3865fb76a00a3a7d49437e1721959dc Mon Sep 17 00:00:00 2001 From: Evan Sims Date: Wed, 20 Sep 2023 23:55:31 -0500 Subject: [PATCH 27/36] Update publish.yml --- .github/workflows/publish.yml | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index a0562cd1..80123c0f 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -25,20 +25,15 @@ jobs: - uses: ./.github/actions/setup - - uses: gradle/gradle-build-action@ef76a971e2fa3f867b617efd72f2fbd72cf6f8bc # pin@2.8.0 - with: - arguments: clean assemble -PisSnapshot=false - - - uses: gradle/gradle-build-action@ef76a971e2fa3f867b617efd72f2fbd72cf6f8bc # pin@2.8.0 - with: - arguments: exportVersion -PisSnapshot=false - - - uses: gradle/gradle-build-action@ef76a971e2fa3f867b617efd72f2fbd72cf6f8bc # pin@2.8.0 - with: - arguments: | - publishAndroidLibraryPublicationToMavenRepository - -PossrhUsername="${{ secrets.OSSR_USERNAME }}" - -PossrhPassword="${{ secrets.OSSR_PASSWORD }}" - -PsigningKey="${{ secrets.SIGNING_KEY }}" - -PsigningPassword="${{ secrets.SIGNING_PASSWORD }}" - -PisSnapshot=false" + - run: ./gradlew clean assemble -PisSnapshot=false + + - run: ./gradlew exportVersion -PisSnapshot=false + + - run: | + ./gradlew \ + publishAndroidLibraryPublicationToMavenRepository \ + -PossrhUsername="${{ secrets.OSSR_USERNAME }}" \ + -PossrhPassword="${{ secrets.OSSR_PASSWORD }}" \ + -PsigningKey="${{ secrets.SIGNING_KEY }}" \ + -PsigningPassword="${{ secrets.SIGNING_PASSWORD }}" \ + -PisSnapshot=false" From 8ab8c846a2e189d10e9328dd8dc429b183f0ceea Mon Sep 17 00:00:00 2001 From: Evan Sims Date: Wed, 20 Sep 2023 23:55:35 -0500 Subject: [PATCH 28/36] Update test.yml --- .github/workflows/test.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 72e0b531..f4901ae7 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -27,8 +27,6 @@ jobs: - uses: ./.github/actions/setup - - uses: gradle/wrapper-validation-action@56b90f209b02bf6d1deae490e9ef18b21a389cd4 # pin@1.1.0 - - run: ./gradlew clean test jacocoTestReport lint --continue --console=plain --max-workers=1 --no-daemon - uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d # pin@3.1.4 From 8060fc193b2bba8d3b825e25ba2d2b62b787b307 Mon Sep 17 00:00:00 2001 From: Evan Sims Date: Wed, 20 Sep 2023 23:56:55 -0500 Subject: [PATCH 29/36] Update publish.yml --- .github/workflows/publish.yml | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 80123c0f..505b1783 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -29,11 +29,4 @@ jobs: - run: ./gradlew exportVersion -PisSnapshot=false - - run: | - ./gradlew \ - publishAndroidLibraryPublicationToMavenRepository \ - -PossrhUsername="${{ secrets.OSSR_USERNAME }}" \ - -PossrhPassword="${{ secrets.OSSR_PASSWORD }}" \ - -PsigningKey="${{ secrets.SIGNING_KEY }}" \ - -PsigningPassword="${{ secrets.SIGNING_PASSWORD }}" \ - -PisSnapshot=false" + - run: ./gradlew publishAndroidLibraryPublicationToMavenRepository -PossrhUsername="${{ secrets.OSSR_USERNAME }}" -PossrhPassword="${{ secrets.OSSR_PASSWORD }}" -PsigningKey="${{ secrets.SIGNING_KEY }}" -PsigningPassword="${{ secrets.SIGNING_PASSWORD }}" -PisSnapshot=false" From c2dac58391fa58e29aeb6aec2106aad56bab2db2 Mon Sep 17 00:00:00 2001 From: Evan Sims Date: Wed, 20 Sep 2023 23:57:34 -0500 Subject: [PATCH 30/36] Update action.yml --- .github/actions/setup/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml index ba444a76..6e0d1342 100644 --- a/.github/actions/setup/action.yml +++ b/.github/actions/setup/action.yml @@ -28,4 +28,4 @@ runs: sdk install kotlin ${{ inputs.kotlin }} && sdk default kotlin ${{ inputs.kotlin }} shell: bash - - uses: gradle/wrapper-validation-action@56b90f209b02bf6d1deae490e9ef18b21a389cd4 # pin@1.1.0 + - uses: gradle/wrapper-validation-action@56b90f209b02bf6d1deae490e9ef18b21a389cd4 # pin@1.1.0 From cc22b6319eebe51563849c423a24e1d2de5abf6f Mon Sep 17 00:00:00 2001 From: Evan Sims Date: Thu, 21 Sep 2023 00:02:20 -0500 Subject: [PATCH 31/36] Delete matrix.json --- .github/workflows/matrix.json | 7 ------- 1 file changed, 7 deletions(-) delete mode 100644 .github/workflows/matrix.json diff --git a/.github/workflows/matrix.json b/.github/workflows/matrix.json deleted file mode 100644 index a70a772f..00000000 --- a/.github/workflows/matrix.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "include": [ - { "android": "30" }, - { "android": "31" }, - { "android": "32" } - ] -} From 008a8211e60e5858b7034c5b5523c9983c3c944a Mon Sep 17 00:00:00 2001 From: Evan Sims Date: Thu, 21 Sep 2023 00:14:05 -0500 Subject: [PATCH 32/36] Update action.yml --- .github/actions/setup/action.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml index 6e0d1342..72b4dc9b 100644 --- a/.github/actions/setup/action.yml +++ b/.github/actions/setup/action.yml @@ -28,4 +28,6 @@ runs: sdk install kotlin ${{ inputs.kotlin }} && sdk default kotlin ${{ inputs.kotlin }} shell: bash + - run: ./gradlew androidDependencies + - uses: gradle/wrapper-validation-action@56b90f209b02bf6d1deae490e9ef18b21a389cd4 # pin@1.1.0 From 2f00e34a5d79518083fc2536d8f3ac6d096db372 Mon Sep 17 00:00:00 2001 From: Evan Sims Date: Thu, 21 Sep 2023 00:14:32 -0500 Subject: [PATCH 33/36] Update action.yml --- .github/actions/setup/action.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml index 72b4dc9b..1379297e 100644 --- a/.github/actions/setup/action.yml +++ b/.github/actions/setup/action.yml @@ -29,5 +29,6 @@ runs: shell: bash - run: ./gradlew androidDependencies + shell: bash - uses: gradle/wrapper-validation-action@56b90f209b02bf6d1deae490e9ef18b21a389cd4 # pin@1.1.0 From f58d9457d85277162a0fd179dda05698970c6ed5 Mon Sep 17 00:00:00 2001 From: Evan Sims Date: Thu, 21 Sep 2023 00:16:24 -0500 Subject: [PATCH 34/36] Update action.yml --- .github/actions/setup/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml index 1379297e..98e09c7c 100644 --- a/.github/actions/setup/action.yml +++ b/.github/actions/setup/action.yml @@ -9,7 +9,7 @@ inputs: gradle: description: The Gradle version to use required: false - default: 4.2 + default: 6.7.1 kotlin: description: The Kotlin version to use required: false From efcd00d881398473d8bd6929d47c59c4e804605c Mon Sep 17 00:00:00 2001 From: Poovamraj T T Date: Thu, 21 Sep 2023 20:03:13 +0530 Subject: [PATCH 35/36] Run failing test in isolation Update CustomTabsControllerTest.java Update CustomTabsController.java Update CustomTabsController.java Update test.yml Update test.yml Update test.yml Run test without thread Use runtime call to run gc Try to call GC after clear Run entire test file Update test.yml Update test.yml Update test.yml --- .github/workflows/test.yml | 15 +++++++- .../provider/CustomTabsController.java | 4 +-- .../provider/CustomTabsControllerTest.java | 34 ++++++++++++++++--- 3 files changed, 45 insertions(+), 8 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f4901ae7..effd8ad2 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -27,6 +27,19 @@ jobs: - uses: ./.github/actions/setup - - run: ./gradlew clean test jacocoTestReport lint --continue --console=plain --max-workers=1 --no-daemon + - run: ./gradlew testReleaseUnitTest --console=plain --max-workers=1 --no-daemon - uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d # pin@3.1.4 + + - uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce + if: ${{ failure() }} + with: + name: 'Test Result' + path: /home/runner/work/Auth0.Android/Auth0.Android/auth0/build/reports/tests/testDebugUnitTest/index.html + + + - uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce + if: ${{ failure() }} + with: + name: 'Test Result' + path: /home/runner/work/Auth0.Android/Auth0.Android/auth0/build/reports/tests/testReleaseUnitTest/index.html \ No newline at end of file diff --git a/auth0/src/main/java/com/auth0/android/provider/CustomTabsController.java b/auth0/src/main/java/com/auth0/android/provider/CustomTabsController.java index 877f69ae..be2994d0 100644 --- a/auth0/src/main/java/com/auth0/android/provider/CustomTabsController.java +++ b/auth0/src/main/java/com/auth0/android/provider/CustomTabsController.java @@ -119,7 +119,7 @@ public void launchUri(@NonNull final Uri uri, final boolean launchAsTwa, ThreadS return; } - new Thread(() -> { + threadSwitcher.backgroundThread(() -> { try { if (launchAsTwa) { this.launchedAsTwa = true; @@ -140,7 +140,7 @@ public void launchUri(@NonNull final Uri uri, final boolean launchAsTwa, ThreadS "a0.browser_not_available", "Error launching browser for authentication", ex); threadSwitcher.mainThread(() -> failureCallback.apply(e)); } - }).start(); + }); } private void launchAsDefault(Context context, Uri uri) { diff --git a/auth0/src/test/java/com/auth0/android/provider/CustomTabsControllerTest.java b/auth0/src/test/java/com/auth0/android/provider/CustomTabsControllerTest.java index 34db290a..bdbfbf5f 100644 --- a/auth0/src/test/java/com/auth0/android/provider/CustomTabsControllerTest.java +++ b/auth0/src/test/java/com/auth0/android/provider/CustomTabsControllerTest.java @@ -10,6 +10,7 @@ import android.net.Uri; import android.os.Looper; +import androidx.annotation.NonNull; import androidx.browser.customtabs.CustomTabsCallback; import androidx.browser.customtabs.CustomTabsClient; import androidx.browser.customtabs.CustomTabsIntent; @@ -19,6 +20,7 @@ import androidx.browser.trusted.TrustedWebActivityIntentBuilder; import org.junit.Before; +import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.ArgumentCaptor; @@ -40,9 +42,11 @@ import static org.hamcrest.Matchers.nullValue; import static org.hamcrest.core.Is.is; import static org.hamcrest.core.Is.isA; +import static org.mockito.ArgumentMatchers.same; import static org.mockito.Matchers.any; import static org.mockito.Matchers.anyInt; import static org.mockito.Matchers.eq; +import static org.mockito.Mockito.atLeastOnce; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.mock; @@ -53,7 +57,9 @@ import static org.mockito.Mockito.when; import com.auth0.android.authentication.AuthenticationException; +import com.auth0.android.request.internal.CommonThreadSwitcher; import com.auth0.android.request.internal.ThreadSwitcher; +import com.auth0.android.util.CommonThreadSwitcherRule; import com.google.androidbrowserhelper.trusted.TwaLauncher; import com.google.androidbrowserhelper.trusted.splashscreens.SplashScreenStrategy; @@ -87,7 +93,17 @@ public void setUp() { MockitoAnnotations.openMocks(this); Activity activity = Robolectric.setupActivity(Activity.class); context = spy(activity); - mockThreadSwitcher = spy(ThreadSwitcher.class); + mockThreadSwitcher = spy(new ThreadSwitcher() { + @Override + public void mainThread(@NonNull Runnable runnable) { + runnable.run(); + } + + @Override + public void backgroundThread(@NonNull Runnable runnable) { + runnable.run(); + } + }); //By default, a "compatible" browser is available BrowserPicker browserPicker = mock(BrowserPicker.class); @@ -135,10 +151,11 @@ public void shouldUnbindEvenIfNotBound() throws Exception { @Test public void shouldBindAndLaunchUri() throws Exception { bindService(controller, true); - controller.launchUri(uri, false, mockThreadSwitcher, null); connectBoundService(); + controller.launchUri(uri, false, mockThreadSwitcher, null); verify(context, timeout(MAX_TEST_WAIT_TIME_MS)).startActivity(launchIntentCaptor.capture()); + verify(mockThreadSwitcher).backgroundThread(any()); Intent intent = launchIntentCaptor.getValue(); assertThat(intent.getAction(), is(Intent.ACTION_VIEW)); assertThat(intent.getPackage(), is(DEFAULT_BROWSER_PACKAGE)); @@ -171,6 +188,7 @@ public void shouldBindAndLaunchUriAsTwa() throws Exception { runnableArgumentCaptor.capture(), fallbackStrategyArgumentCaptor.capture()); + verify(mockThreadSwitcher).backgroundThread(any()); assertThat(trustedWebActivityIntentBuilderArgumentCaptor.getValue(), is(notNullValue())); assertThat(customTabsCallbackArgumentCaptor.getValue(), is(nullValue())); assertThat(splashScreenStrategyArgumentCaptor.getValue(), is(nullValue())); @@ -187,6 +205,7 @@ public void shouldLaunchUriUsingFallbackWhenNoCompatibleBrowserIsAvailable() { controller.launchUri(uri, false, mockThreadSwitcher, null); verify(context, timeout(MAX_TEST_WAIT_TIME_MS)).startActivity(launchIntentCaptor.capture()); + verify(mockThreadSwitcher).backgroundThread(any()); Intent intent = launchIntentCaptor.getValue(); assertThat(intent.getAction(), is(Intent.ACTION_VIEW)); //A null package name would make the OS decide the best app to resolve the intent @@ -207,10 +226,11 @@ public void shouldBindAndLaunchUriWithCustomization() throws Exception { CustomTabsController controller = new CustomTabsController(context, ctOptions, twaLauncher); bindService(controller, true); - controller.launchUri(uri, false, mockThreadSwitcher, null); connectBoundService(); + controller.launchUri(uri, false, mockThreadSwitcher, null); verify(context, timeout(MAX_TEST_WAIT_TIME_MS)).startActivity(launchIntentCaptor.capture()); + verify(mockThreadSwitcher).backgroundThread(any()); Intent intent = launchIntentCaptor.getValue(); assertThat(intent.getAction(), is(Intent.ACTION_VIEW)); assertThat(intent.getPackage(), is(DEFAULT_BROWSER_PACKAGE)); @@ -255,6 +275,7 @@ public void shouldBindAndLaunchUriWithCustomizationTwa() throws Exception { runnableArgumentCaptor.capture(), fallbackStrategyArgumentCaptor.capture()); + verify(mockThreadSwitcher).backgroundThread(any()); assertThat(trustedWebActivityIntentBuilderArgumentCaptor.getValue(), is(notNullValue())); assertThat(customTabsCallbackArgumentCaptor.getValue(), is(nullValue())); assertThat(splashScreenStrategyArgumentCaptor.getValue(), is(nullValue())); @@ -269,6 +290,7 @@ public void shouldFailToBindButLaunchUri() { verify(context, timeout(MAX_TEST_WAIT_TIME_MS)).startActivity(launchIntentCaptor.capture()); Intent intent = launchIntentCaptor.getValue(); + verify(mockThreadSwitcher).backgroundThread(any()); assertThat(intent.getAction(), is(Intent.ACTION_VIEW)); assertThat(intent.getData(), is(uri)); assertThat(intent.hasExtra(CustomTabsIntent.EXTRA_SESSION), is(true)); @@ -280,6 +302,7 @@ public void shouldNotLaunchUriIfContextNoLongerValid() { bindService(controller, true); controller.clearContext(); controller.launchUri(uri, false, mockThreadSwitcher, null); + verify(mockThreadSwitcher, never()).backgroundThread(any()); verify(context, never()).startActivity(any(Intent.class)); } @@ -291,6 +314,7 @@ public void shouldLaunchUriWithFallbackIfCustomTabIntentFails() { controller.launchUri(uri, false, mockThreadSwitcher, null); verify(context, timeout(MAX_TEST_WAIT_TIME_MS)).startActivity(launchIntentCaptor.capture()); + verify(mockThreadSwitcher).backgroundThread(any()); List intents = launchIntentCaptor.getAllValues(); Intent customTabIntent = intents.get(0); @@ -313,11 +337,11 @@ public void shouldThrowExceptionIfFailedToLaunchBecauseOfException() { .when(context).startActivity(any(Intent.class)); controller.launchUri(uri, false, mockThreadSwitcher, (ex) -> { assertThat(ex, isA(AuthenticationException.class)); - assertThat(ex.getCause(), is(eq(e))); + assertThat(ex.getCause(), equalTo(e)); assertThat(ex.getCode(), is("a0.browser_not_available")); assertThat(ex.getDescription(), is("Error launching browser for authentication")); verify(mockThreadSwitcher).mainThread(any()); - verify(mockThreadSwitcher, Mockito.never()).backgroundThread(any()); + verify(mockThreadSwitcher).backgroundThread(any()); }); } From cb19aa9a05ec82f5b55bd2cb3249bbd559900953 Mon Sep 17 00:00:00 2001 From: Poovamraj T T Date: Fri, 22 Sep 2023 14:10:27 +0530 Subject: [PATCH 36/36] Revert "Run failing test in isolation" This reverts commit efcd00d881398473d8bd6929d47c59c4e804605c. --- .github/workflows/test.yml | 15 +------- .../provider/CustomTabsController.java | 4 +-- .../provider/CustomTabsControllerTest.java | 34 +++---------------- 3 files changed, 8 insertions(+), 45 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index effd8ad2..f4901ae7 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -27,19 +27,6 @@ jobs: - uses: ./.github/actions/setup - - run: ./gradlew testReleaseUnitTest --console=plain --max-workers=1 --no-daemon + - run: ./gradlew clean test jacocoTestReport lint --continue --console=plain --max-workers=1 --no-daemon - uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d # pin@3.1.4 - - - uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce - if: ${{ failure() }} - with: - name: 'Test Result' - path: /home/runner/work/Auth0.Android/Auth0.Android/auth0/build/reports/tests/testDebugUnitTest/index.html - - - - uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce - if: ${{ failure() }} - with: - name: 'Test Result' - path: /home/runner/work/Auth0.Android/Auth0.Android/auth0/build/reports/tests/testReleaseUnitTest/index.html \ No newline at end of file diff --git a/auth0/src/main/java/com/auth0/android/provider/CustomTabsController.java b/auth0/src/main/java/com/auth0/android/provider/CustomTabsController.java index be2994d0..877f69ae 100644 --- a/auth0/src/main/java/com/auth0/android/provider/CustomTabsController.java +++ b/auth0/src/main/java/com/auth0/android/provider/CustomTabsController.java @@ -119,7 +119,7 @@ public void launchUri(@NonNull final Uri uri, final boolean launchAsTwa, ThreadS return; } - threadSwitcher.backgroundThread(() -> { + new Thread(() -> { try { if (launchAsTwa) { this.launchedAsTwa = true; @@ -140,7 +140,7 @@ public void launchUri(@NonNull final Uri uri, final boolean launchAsTwa, ThreadS "a0.browser_not_available", "Error launching browser for authentication", ex); threadSwitcher.mainThread(() -> failureCallback.apply(e)); } - }); + }).start(); } private void launchAsDefault(Context context, Uri uri) { diff --git a/auth0/src/test/java/com/auth0/android/provider/CustomTabsControllerTest.java b/auth0/src/test/java/com/auth0/android/provider/CustomTabsControllerTest.java index bdbfbf5f..34db290a 100644 --- a/auth0/src/test/java/com/auth0/android/provider/CustomTabsControllerTest.java +++ b/auth0/src/test/java/com/auth0/android/provider/CustomTabsControllerTest.java @@ -10,7 +10,6 @@ import android.net.Uri; import android.os.Looper; -import androidx.annotation.NonNull; import androidx.browser.customtabs.CustomTabsCallback; import androidx.browser.customtabs.CustomTabsClient; import androidx.browser.customtabs.CustomTabsIntent; @@ -20,7 +19,6 @@ import androidx.browser.trusted.TrustedWebActivityIntentBuilder; import org.junit.Before; -import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.ArgumentCaptor; @@ -42,11 +40,9 @@ import static org.hamcrest.Matchers.nullValue; import static org.hamcrest.core.Is.is; import static org.hamcrest.core.Is.isA; -import static org.mockito.ArgumentMatchers.same; import static org.mockito.Matchers.any; import static org.mockito.Matchers.anyInt; import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.atLeastOnce; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.mock; @@ -57,9 +53,7 @@ import static org.mockito.Mockito.when; import com.auth0.android.authentication.AuthenticationException; -import com.auth0.android.request.internal.CommonThreadSwitcher; import com.auth0.android.request.internal.ThreadSwitcher; -import com.auth0.android.util.CommonThreadSwitcherRule; import com.google.androidbrowserhelper.trusted.TwaLauncher; import com.google.androidbrowserhelper.trusted.splashscreens.SplashScreenStrategy; @@ -93,17 +87,7 @@ public void setUp() { MockitoAnnotations.openMocks(this); Activity activity = Robolectric.setupActivity(Activity.class); context = spy(activity); - mockThreadSwitcher = spy(new ThreadSwitcher() { - @Override - public void mainThread(@NonNull Runnable runnable) { - runnable.run(); - } - - @Override - public void backgroundThread(@NonNull Runnable runnable) { - runnable.run(); - } - }); + mockThreadSwitcher = spy(ThreadSwitcher.class); //By default, a "compatible" browser is available BrowserPicker browserPicker = mock(BrowserPicker.class); @@ -151,11 +135,10 @@ public void shouldUnbindEvenIfNotBound() throws Exception { @Test public void shouldBindAndLaunchUri() throws Exception { bindService(controller, true); - connectBoundService(); controller.launchUri(uri, false, mockThreadSwitcher, null); + connectBoundService(); verify(context, timeout(MAX_TEST_WAIT_TIME_MS)).startActivity(launchIntentCaptor.capture()); - verify(mockThreadSwitcher).backgroundThread(any()); Intent intent = launchIntentCaptor.getValue(); assertThat(intent.getAction(), is(Intent.ACTION_VIEW)); assertThat(intent.getPackage(), is(DEFAULT_BROWSER_PACKAGE)); @@ -188,7 +171,6 @@ public void shouldBindAndLaunchUriAsTwa() throws Exception { runnableArgumentCaptor.capture(), fallbackStrategyArgumentCaptor.capture()); - verify(mockThreadSwitcher).backgroundThread(any()); assertThat(trustedWebActivityIntentBuilderArgumentCaptor.getValue(), is(notNullValue())); assertThat(customTabsCallbackArgumentCaptor.getValue(), is(nullValue())); assertThat(splashScreenStrategyArgumentCaptor.getValue(), is(nullValue())); @@ -205,7 +187,6 @@ public void shouldLaunchUriUsingFallbackWhenNoCompatibleBrowserIsAvailable() { controller.launchUri(uri, false, mockThreadSwitcher, null); verify(context, timeout(MAX_TEST_WAIT_TIME_MS)).startActivity(launchIntentCaptor.capture()); - verify(mockThreadSwitcher).backgroundThread(any()); Intent intent = launchIntentCaptor.getValue(); assertThat(intent.getAction(), is(Intent.ACTION_VIEW)); //A null package name would make the OS decide the best app to resolve the intent @@ -226,11 +207,10 @@ public void shouldBindAndLaunchUriWithCustomization() throws Exception { CustomTabsController controller = new CustomTabsController(context, ctOptions, twaLauncher); bindService(controller, true); - connectBoundService(); controller.launchUri(uri, false, mockThreadSwitcher, null); + connectBoundService(); verify(context, timeout(MAX_TEST_WAIT_TIME_MS)).startActivity(launchIntentCaptor.capture()); - verify(mockThreadSwitcher).backgroundThread(any()); Intent intent = launchIntentCaptor.getValue(); assertThat(intent.getAction(), is(Intent.ACTION_VIEW)); assertThat(intent.getPackage(), is(DEFAULT_BROWSER_PACKAGE)); @@ -275,7 +255,6 @@ public void shouldBindAndLaunchUriWithCustomizationTwa() throws Exception { runnableArgumentCaptor.capture(), fallbackStrategyArgumentCaptor.capture()); - verify(mockThreadSwitcher).backgroundThread(any()); assertThat(trustedWebActivityIntentBuilderArgumentCaptor.getValue(), is(notNullValue())); assertThat(customTabsCallbackArgumentCaptor.getValue(), is(nullValue())); assertThat(splashScreenStrategyArgumentCaptor.getValue(), is(nullValue())); @@ -290,7 +269,6 @@ public void shouldFailToBindButLaunchUri() { verify(context, timeout(MAX_TEST_WAIT_TIME_MS)).startActivity(launchIntentCaptor.capture()); Intent intent = launchIntentCaptor.getValue(); - verify(mockThreadSwitcher).backgroundThread(any()); assertThat(intent.getAction(), is(Intent.ACTION_VIEW)); assertThat(intent.getData(), is(uri)); assertThat(intent.hasExtra(CustomTabsIntent.EXTRA_SESSION), is(true)); @@ -302,7 +280,6 @@ public void shouldNotLaunchUriIfContextNoLongerValid() { bindService(controller, true); controller.clearContext(); controller.launchUri(uri, false, mockThreadSwitcher, null); - verify(mockThreadSwitcher, never()).backgroundThread(any()); verify(context, never()).startActivity(any(Intent.class)); } @@ -314,7 +291,6 @@ public void shouldLaunchUriWithFallbackIfCustomTabIntentFails() { controller.launchUri(uri, false, mockThreadSwitcher, null); verify(context, timeout(MAX_TEST_WAIT_TIME_MS)).startActivity(launchIntentCaptor.capture()); - verify(mockThreadSwitcher).backgroundThread(any()); List intents = launchIntentCaptor.getAllValues(); Intent customTabIntent = intents.get(0); @@ -337,11 +313,11 @@ public void shouldThrowExceptionIfFailedToLaunchBecauseOfException() { .when(context).startActivity(any(Intent.class)); controller.launchUri(uri, false, mockThreadSwitcher, (ex) -> { assertThat(ex, isA(AuthenticationException.class)); - assertThat(ex.getCause(), equalTo(e)); + assertThat(ex.getCause(), is(eq(e))); assertThat(ex.getCode(), is("a0.browser_not_available")); assertThat(ex.getDescription(), is("Error launching browser for authentication")); verify(mockThreadSwitcher).mainThread(any()); - verify(mockThreadSwitcher).backgroundThread(any()); + verify(mockThreadSwitcher, Mockito.never()).backgroundThread(any()); }); }