From e63d7c4e4d1a55cdd940ef150a03dca024b8a68a Mon Sep 17 00:00:00 2001 From: Mohamed Metwalli Date: Fri, 13 May 2022 13:10:23 +0200 Subject: [PATCH 01/44] Create android.yml --- .github/workflows/android.yml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 .github/workflows/android.yml diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml new file mode 100644 index 00000000000..1e82c4ba3de --- /dev/null +++ b/.github/workflows/android.yml @@ -0,0 +1,21 @@ +name: Android CI + +on: [push, pull_request] +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: set up JDK 11 + uses: actions/setup-java@v3 + with: + java-version: '11' + distribution: 'temurin' + cache: gradle + + - name: Grant execute permission for gradlew + run: chmod +x gradlew + - name: Build with Gradle + run: ./gradlew build From 348a0d742b1a47ce79a6243d6f17badbb3928ef5 Mon Sep 17 00:00:00 2001 From: Mohamed Metwalli Date: Fri, 13 May 2022 13:37:06 +0200 Subject: [PATCH 02/44] No specific distribution --- .github/workflows/android.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index 1e82c4ba3de..005bd96775c 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -1,6 +1,6 @@ name: Android CI -on: [push, pull_request] +on: [ push, pull_request ] jobs: build: @@ -11,9 +11,7 @@ jobs: - name: set up JDK 11 uses: actions/setup-java@v3 with: - java-version: '11' - distribution: 'temurin' - cache: gradle + java-version: 11 - name: Grant execute permission for gradlew run: chmod +x gradlew From b86e3776e3598f4b1437fc0eb5509431ae3d77cd Mon Sep 17 00:00:00 2001 From: Mohamed Metwalli Date: Fri, 13 May 2022 16:13:12 +0200 Subject: [PATCH 03/44] Update android.yml --- .github/workflows/android.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index 005bd96775c..3bc5aeaa190 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -11,7 +11,7 @@ jobs: - name: set up JDK 11 uses: actions/setup-java@v3 with: - java-version: 11 + java-version: '11' - name: Grant execute permission for gradlew run: chmod +x gradlew From b119062cd0554ee2f89c5ccc22519754c9218faa Mon Sep 17 00:00:00 2001 From: Mohamed Metwalli Date: Fri, 13 May 2022 16:15:50 +0200 Subject: [PATCH 04/44] Cancel on progress --- .github/workflows/android.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index 3bc5aeaa190..ac6cabf7269 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -1,6 +1,11 @@ name: Android CI on: [ push, pull_request ] + +concurrency: + group: build-${{ github.ref }} + cancel-in-progress: true + jobs: build: From ee8b8edb3bafd58bf1b02497fc84618ac610de51 Mon Sep 17 00:00:00 2001 From: Mohamed Metwalli Date: Fri, 13 May 2022 16:19:07 +0200 Subject: [PATCH 05/44] Update android.yml --- .github/workflows/android.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index ac6cabf7269..ec9d2a0db5a 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -17,6 +17,8 @@ jobs: uses: actions/setup-java@v3 with: java-version: '11' + distribution: 'adopt' + cache: gradle - name: Grant execute permission for gradlew run: chmod +x gradlew From 75af27e405649aed09d712dacfa085c361750217 Mon Sep 17 00:00:00 2001 From: Mohamed Metwalli Date: Fri, 13 May 2022 16:20:59 +0200 Subject: [PATCH 06/44] on `push` only --- .github/workflows/android.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index ec9d2a0db5a..5cb7f77aed8 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -1,6 +1,6 @@ name: Android CI -on: [ push, pull_request ] +on: [ push ] concurrency: group: build-${{ github.ref }} From df20bbcd598e02d86a825fb2b51727d0bdf6d20d Mon Sep 17 00:00:00 2001 From: Mohamed Metwalli Date: Fri, 13 May 2022 18:14:28 +0200 Subject: [PATCH 07/44] Reusable actions --- .github/workflows/android.yml | 9 +++++---- .github/workflows/run-gradle-cmd.yml | 23 +++++++++++++++++++++++ 2 files changed, 28 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/run-gradle-cmd.yml diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index 5cb7f77aed8..c3d2036d618 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -8,9 +8,7 @@ concurrency: jobs: build: - runs-on: ubuntu-latest - steps: - uses: actions/checkout@v3 - name: set up JDK 11 @@ -22,5 +20,8 @@ jobs: - name: Grant execute permission for gradlew run: chmod +x gradlew - - name: Build with Gradle - run: ./gradlew build + - name: Ktlint + uses: ./.github/workflows/run-gradle-cmd.yml + with: + decs: "Detekt check" + cmd: ":Corona-Warn-App:detekt" diff --git a/.github/workflows/run-gradle-cmd.yml b/.github/workflows/run-gradle-cmd.yml new file mode 100644 index 00000000000..d43fd0640fe --- /dev/null +++ b/.github/workflows/run-gradle-cmd.yml @@ -0,0 +1,23 @@ +name: Running gradle command with environment options + +on: + workflow_call: + inputs: + desc: + required: true + type: string + default: "Running gradle command" + cmd: + required: true + type: string + +jobs: + runCommand: + runs-on: ubuntu-latest + steps: + - name: ${{ inputs.desc }} + timeout-minutes: 30 + run: | + ./gradlew -PdisablePreDex + ${{ inputs.cmd }} + From 3e5fe4a6e4cf70b9a349d4df0fa07dbd754dba5c Mon Sep 17 00:00:00 2001 From: Mohamed Metwalli Date: Fri, 13 May 2022 21:25:00 +0200 Subject: [PATCH 08/44] Run jobs --- .circleci/{config.yml => config.txt} | 0 .github/workflows/android.yml | 117 ++++++++++++++++++++++++++- .github/workflows/run-gradle-cmd.yml | 23 ------ 3 files changed, 113 insertions(+), 27 deletions(-) rename .circleci/{config.yml => config.txt} (100%) delete mode 100644 .github/workflows/run-gradle-cmd.yml diff --git a/.circleci/config.yml b/.circleci/config.txt similarity index 100% rename from .circleci/config.yml rename to .circleci/config.txt diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index c3d2036d618..4b259dbd40b 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -7,7 +7,7 @@ concurrency: cancel-in-progress: true jobs: - build: + detekt: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -21,7 +21,116 @@ jobs: - name: Grant execute permission for gradlew run: chmod +x gradlew - name: Ktlint - uses: ./.github/workflows/run-gradle-cmd.yml + run: ./gradlw :Corona-Warn-App:detekt + + quick_build_device_release_no_tests: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: set up JDK 11 + uses: actions/setup-java@v3 + with: + java-version: '11' + distribution: 'adopt' + cache: gradle + + - name: Grant execute permission for gradlew + run: chmod +x gradlew + - name: Ktlint + run: ./gradlw assembleDeviceRelease + + quick_build_device_for_testers_release_no_tests: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: set up JDK 11 + uses: actions/setup-java@v3 + with: + java-version: '11' + distribution: 'adopt' + cache: gradle + + - name: Grant execute permission for gradlew + run: chmod +x gradlew + - name: Quick Build + run: ./gradlw :Corona-Warn-App:assembleDeviceForTestersRelease + + unit_tests_device_release: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: set up JDK 11 + uses: actions/setup-java@v3 + with: + java-version: '11' + distribution: 'adopt' + cache: gradle + + - name: Grant execute permission for gradlew + run: chmod +x gradlew + - name: Unit tests + run: ./gradlw :Corona-Warn-App:testDeviceReleaseUnitTest -i + + unit_tests_device_for_testers_release: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: set up JDK 11 + uses: actions/setup-java@v3 with: - decs: "Detekt check" - cmd: ":Corona-Warn-App:detekt" + java-version: '11' + distribution: 'adopt' + cache: gradle + + - name: Grant execute permission for gradlew + run: chmod +x gradlew + - name: Unit tests + run: ./gradlw :Corona-Warn-App:testDeviceForTestersReleaseUnitTest + + lint_device_release_check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: set up JDK 11 + uses: actions/setup-java@v3 + with: + java-version: '11' + distribution: 'adopt' + cache: gradle + + - name: Grant execute permission for gradlew + run: chmod +x gradlew + - name: Lint check deviceRelease + run: ./gradlw :Corona-Warn-App:lintDeviceRelease -i + + lint_device_for_testers_release_check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: set up JDK 11 + uses: actions/setup-java@v3 + with: + java-version: '11' + distribution: 'adopt' + cache: gradle + + - name: Grant execute permission for gradlew + run: chmod +x gradlew + - name: Lint check deviceForTestersRelease + run: ./gradlw :Corona-Warn-App:lintDeviceForTestersRelease -i + + ktlint_check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: set up JDK 11 + uses: actions/setup-java@v3 + with: + java-version: '11' + distribution: 'adopt' + cache: gradle + + - name: Grant execute permission for gradlew + run: chmod +x gradlew + - name: Lint check deviceForTestersRelease + run: ./gradlw :Corona-Warn-App:ktlintCheck \ No newline at end of file diff --git a/.github/workflows/run-gradle-cmd.yml b/.github/workflows/run-gradle-cmd.yml deleted file mode 100644 index d43fd0640fe..00000000000 --- a/.github/workflows/run-gradle-cmd.yml +++ /dev/null @@ -1,23 +0,0 @@ -name: Running gradle command with environment options - -on: - workflow_call: - inputs: - desc: - required: true - type: string - default: "Running gradle command" - cmd: - required: true - type: string - -jobs: - runCommand: - runs-on: ubuntu-latest - steps: - - name: ${{ inputs.desc }} - timeout-minutes: 30 - run: | - ./gradlew -PdisablePreDex - ${{ inputs.cmd }} - From 91ac60f65f9f14cb34c790233a1e7866fb17b2aa Mon Sep 17 00:00:00 2001 From: Mohamed Metwalli Date: Fri, 13 May 2022 21:26:50 +0200 Subject: [PATCH 09/44] Fix --- .circleci/{config.txt => config.yml} | 0 .github/workflows/android.yml | 16 ++++++++-------- 2 files changed, 8 insertions(+), 8 deletions(-) rename .circleci/{config.txt => config.yml} (100%) diff --git a/.circleci/config.txt b/.circleci/config.yml similarity index 100% rename from .circleci/config.txt rename to .circleci/config.yml diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index 4b259dbd40b..99c132ee2f9 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -21,7 +21,7 @@ jobs: - name: Grant execute permission for gradlew run: chmod +x gradlew - name: Ktlint - run: ./gradlw :Corona-Warn-App:detekt + run: ./gradlew :Corona-Warn-App:detekt quick_build_device_release_no_tests: runs-on: ubuntu-latest @@ -37,7 +37,7 @@ jobs: - name: Grant execute permission for gradlew run: chmod +x gradlew - name: Ktlint - run: ./gradlw assembleDeviceRelease + run: ./gradlew assembleDeviceRelease quick_build_device_for_testers_release_no_tests: runs-on: ubuntu-latest @@ -53,7 +53,7 @@ jobs: - name: Grant execute permission for gradlew run: chmod +x gradlew - name: Quick Build - run: ./gradlw :Corona-Warn-App:assembleDeviceForTestersRelease + run: ./gradlew :Corona-Warn-App:assembleDeviceForTestersRelease unit_tests_device_release: runs-on: ubuntu-latest @@ -69,7 +69,7 @@ jobs: - name: Grant execute permission for gradlew run: chmod +x gradlew - name: Unit tests - run: ./gradlw :Corona-Warn-App:testDeviceReleaseUnitTest -i + run: ./gradlew :Corona-Warn-App:testDeviceReleaseUnitTest -i unit_tests_device_for_testers_release: runs-on: ubuntu-latest @@ -85,7 +85,7 @@ jobs: - name: Grant execute permission for gradlew run: chmod +x gradlew - name: Unit tests - run: ./gradlw :Corona-Warn-App:testDeviceForTestersReleaseUnitTest + run: ./gradlew :Corona-Warn-App:testDeviceForTestersReleaseUnitTest lint_device_release_check: runs-on: ubuntu-latest @@ -101,7 +101,7 @@ jobs: - name: Grant execute permission for gradlew run: chmod +x gradlew - name: Lint check deviceRelease - run: ./gradlw :Corona-Warn-App:lintDeviceRelease -i + run: ./gradlew :Corona-Warn-App:lintDeviceRelease -i lint_device_for_testers_release_check: runs-on: ubuntu-latest @@ -117,7 +117,7 @@ jobs: - name: Grant execute permission for gradlew run: chmod +x gradlew - name: Lint check deviceForTestersRelease - run: ./gradlw :Corona-Warn-App:lintDeviceForTestersRelease -i + run: ./gradlew :Corona-Warn-App:lintDeviceForTestersRelease -i ktlint_check: runs-on: ubuntu-latest @@ -133,4 +133,4 @@ jobs: - name: Grant execute permission for gradlew run: chmod +x gradlew - name: Lint check deviceForTestersRelease - run: ./gradlw :Corona-Warn-App:ktlintCheck \ No newline at end of file + run: ./gradlew :Corona-Warn-App:ktlintCheck \ No newline at end of file From c15ab435eb43d6aeb4dff6ef7b8a13f612b12111 Mon Sep 17 00:00:00 2001 From: Mohamed Metwalli Date: Fri, 13 May 2022 22:39:38 +0200 Subject: [PATCH 10/44] Reports --- .github/workflows/android.yml | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index 99c132ee2f9..3f0e41939b2 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -22,6 +22,10 @@ jobs: run: chmod +x gradlew - name: Ktlint run: ./gradlew :Corona-Warn-App:detekt + - name: Reports + uses: actions/upload-artifact@v3 + with: + path: Corona-Warn-App/build/reports quick_build_device_release_no_tests: runs-on: ubuntu-latest @@ -38,6 +42,10 @@ jobs: run: chmod +x gradlew - name: Ktlint run: ./gradlew assembleDeviceRelease + - name: Reports + uses: actions/upload-artifact@v3 + with: + path: Corona-Warn-App/build/reports quick_build_device_for_testers_release_no_tests: runs-on: ubuntu-latest @@ -54,6 +62,10 @@ jobs: run: chmod +x gradlew - name: Quick Build run: ./gradlew :Corona-Warn-App:assembleDeviceForTestersRelease + - name: Reports + uses: actions/upload-artifact@v3 + with: + path: Corona-Warn-App/build/reports unit_tests_device_release: runs-on: ubuntu-latest @@ -70,6 +82,10 @@ jobs: run: chmod +x gradlew - name: Unit tests run: ./gradlew :Corona-Warn-App:testDeviceReleaseUnitTest -i + - name: Reports + uses: actions/upload-artifact@v3 + with: + path: Corona-Warn-App/build/test-results unit_tests_device_for_testers_release: runs-on: ubuntu-latest @@ -86,6 +102,10 @@ jobs: run: chmod +x gradlew - name: Unit tests run: ./gradlew :Corona-Warn-App:testDeviceForTestersReleaseUnitTest + - name: Reports + uses: actions/upload-artifact@v3 + with: + path: Corona-Warn-App/build/test-results lint_device_release_check: runs-on: ubuntu-latest @@ -102,6 +122,10 @@ jobs: run: chmod +x gradlew - name: Lint check deviceRelease run: ./gradlew :Corona-Warn-App:lintDeviceRelease -i + - name: Reports + uses: actions/upload-artifact@v3 + with: + path: Corona-Warn-App/build/reports lint_device_for_testers_release_check: runs-on: ubuntu-latest @@ -118,6 +142,10 @@ jobs: run: chmod +x gradlew - name: Lint check deviceForTestersRelease run: ./gradlew :Corona-Warn-App:lintDeviceForTestersRelease -i + - name: Reports + uses: actions/upload-artifact@v3 + with: + path: Corona-Warn-App/build/reports ktlint_check: runs-on: ubuntu-latest @@ -133,4 +161,8 @@ jobs: - name: Grant execute permission for gradlew run: chmod +x gradlew - name: Lint check deviceForTestersRelease - run: ./gradlew :Corona-Warn-App:ktlintCheck \ No newline at end of file + run: ./gradlew :Corona-Warn-App:ktlintCheck + - name: Reports + uses: actions/upload-artifact@v3 + with: + path: Corona-Warn-App/build/reports \ No newline at end of file From c8ecca799a2a940332a62d02ba90fac9d7026174 Mon Sep 17 00:00:00 2001 From: Mohamed Metwalli Date: Sat, 14 May 2022 10:05:15 +0200 Subject: [PATCH 11/44] =?UTF-8?q?run=20=F0=9F=8F=83=E2=80=8D=E2=99=82?= =?UTF-8?q?=EF=B8=8F=20`always`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/android.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index 3f0e41939b2..401eecb1cb3 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -24,6 +24,7 @@ jobs: run: ./gradlew :Corona-Warn-App:detekt - name: Reports uses: actions/upload-artifact@v3 + if: always() with: path: Corona-Warn-App/build/reports @@ -44,6 +45,7 @@ jobs: run: ./gradlew assembleDeviceRelease - name: Reports uses: actions/upload-artifact@v3 + if: always() with: path: Corona-Warn-App/build/reports @@ -64,6 +66,7 @@ jobs: run: ./gradlew :Corona-Warn-App:assembleDeviceForTestersRelease - name: Reports uses: actions/upload-artifact@v3 + if: always() with: path: Corona-Warn-App/build/reports @@ -73,6 +76,7 @@ jobs: - uses: actions/checkout@v3 - name: set up JDK 11 uses: actions/setup-java@v3 + if: always() with: java-version: '11' distribution: 'adopt' @@ -84,6 +88,7 @@ jobs: run: ./gradlew :Corona-Warn-App:testDeviceReleaseUnitTest -i - name: Reports uses: actions/upload-artifact@v3 + if: always() with: path: Corona-Warn-App/build/test-results @@ -104,6 +109,7 @@ jobs: run: ./gradlew :Corona-Warn-App:testDeviceForTestersReleaseUnitTest - name: Reports uses: actions/upload-artifact@v3 + if: always() with: path: Corona-Warn-App/build/test-results @@ -124,6 +130,7 @@ jobs: run: ./gradlew :Corona-Warn-App:lintDeviceRelease -i - name: Reports uses: actions/upload-artifact@v3 + if: always() with: path: Corona-Warn-App/build/reports @@ -144,6 +151,7 @@ jobs: run: ./gradlew :Corona-Warn-App:lintDeviceForTestersRelease -i - name: Reports uses: actions/upload-artifact@v3 + if: always() with: path: Corona-Warn-App/build/reports @@ -164,5 +172,6 @@ jobs: run: ./gradlew :Corona-Warn-App:ktlintCheck - name: Reports uses: actions/upload-artifact@v3 + if: always() with: path: Corona-Warn-App/build/reports \ No newline at end of file From b3cae0de7cbb20fce9e452678858f6378457611a Mon Sep 17 00:00:00 2001 From: Mohamed Metwalli Date: Sat, 14 May 2022 10:48:20 +0200 Subject: [PATCH 12/44] try matrix --- .github/workflows/android.yml | 172 +++++----------------------------- 1 file changed, 23 insertions(+), 149 deletions(-) diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index 401eecb1cb3..c2657de9048 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -7,8 +7,20 @@ concurrency: cancel-in-progress: true jobs: - detekt: + build: runs-on: ubuntu-latest + strategy: + matrix: + commands: [ + ':Corona-Warn-App:assembleDeviceRelease', + ':Corona-Warn-App:detekt', + ':Corona-Warn-App:assembleDeviceForTestersRelease', + ':Corona-Warn-App:testDeviceReleaseUnitTest -i', + ':Corona-Warn-App:testDeviceForTestersReleaseUnitTest', + ':Corona-Warn-App:lintDeviceRelease -i', + ':Corona-Warn-App:lintDeviceForTestersRelease -i', + ':Corona-Warn-App:ktlintCheck', + ] steps: - uses: actions/checkout@v3 - name: set up JDK 11 @@ -21,155 +33,17 @@ jobs: - name: Grant execute permission for gradlew run: chmod +x gradlew - name: Ktlint - run: ./gradlew :Corona-Warn-App:detekt - - name: Reports - uses: actions/upload-artifact@v3 - if: always() - with: - path: Corona-Warn-App/build/reports - - quick_build_device_release_no_tests: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: set up JDK 11 - uses: actions/setup-java@v3 - with: - java-version: '11' - distribution: 'adopt' - cache: gradle - - - name: Grant execute permission for gradlew - run: chmod +x gradlew - - name: Ktlint - run: ./gradlew assembleDeviceRelease - - name: Reports - uses: actions/upload-artifact@v3 - if: always() - with: - path: Corona-Warn-App/build/reports - - quick_build_device_for_testers_release_no_tests: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: set up JDK 11 - uses: actions/setup-java@v3 - with: - java-version: '11' - distribution: 'adopt' - cache: gradle - - - name: Grant execute permission for gradlew - run: chmod +x gradlew - - name: Quick Build - run: ./gradlew :Corona-Warn-App:assembleDeviceForTestersRelease - - name: Reports - uses: actions/upload-artifact@v3 - if: always() - with: - path: Corona-Warn-App/build/reports - - unit_tests_device_release: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: set up JDK 11 - uses: actions/setup-java@v3 - if: always() - with: - java-version: '11' - distribution: 'adopt' - cache: gradle - - - name: Grant execute permission for gradlew - run: chmod +x gradlew - - name: Unit tests - run: ./gradlew :Corona-Warn-App:testDeviceReleaseUnitTest -i - - name: Reports - uses: actions/upload-artifact@v3 - if: always() - with: - path: Corona-Warn-App/build/test-results - - unit_tests_device_for_testers_release: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: set up JDK 11 - uses: actions/setup-java@v3 - with: - java-version: '11' - distribution: 'adopt' - cache: gradle - - - name: Grant execute permission for gradlew - run: chmod +x gradlew - - name: Unit tests - run: ./gradlew :Corona-Warn-App:testDeviceForTestersReleaseUnitTest - - name: Reports - uses: actions/upload-artifact@v3 - if: always() - with: - path: Corona-Warn-App/build/test-results - - lint_device_release_check: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: set up JDK 11 - uses: actions/setup-java@v3 - with: - java-version: '11' - distribution: 'adopt' - cache: gradle - - - name: Grant execute permission for gradlew - run: chmod +x gradlew - - name: Lint check deviceRelease - run: ./gradlew :Corona-Warn-App:lintDeviceRelease -i - - name: Reports - uses: actions/upload-artifact@v3 - if: always() - with: - path: Corona-Warn-App/build/reports - - lint_device_for_testers_release_check: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: set up JDK 11 - uses: actions/setup-java@v3 - with: - java-version: '11' - distribution: 'adopt' - cache: gradle - - - name: Grant execute permission for gradlew - run: chmod +x gradlew - - name: Lint check deviceForTestersRelease - run: ./gradlew :Corona-Warn-App:lintDeviceForTestersRelease -i - - name: Reports - uses: actions/upload-artifact@v3 - if: always() - with: - path: Corona-Warn-App/build/reports + run: | + ./gradlew ${{ matrix.commands }} + env: + JVM_OPTS: -Xmx4096m + GRADLE_OPTS: | + -Xmx1536m -XX:+HeapDumpOnOutOfMemoryError + -Dorg.gradle.caching=true + -Dorg.gradle.configureondemand=true + -Dkotlin.compiler.execution.strategy=in-process + -Dkotlin.incremental=false - ktlint_check: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: set up JDK 11 - uses: actions/setup-java@v3 - with: - java-version: '11' - distribution: 'adopt' - cache: gradle - - - name: Grant execute permission for gradlew - run: chmod +x gradlew - - name: Lint check deviceForTestersRelease - run: ./gradlew :Corona-Warn-App:ktlintCheck - name: Reports uses: actions/upload-artifact@v3 if: always() From 244de688f750fe1e15eec9aecca484c8d8be1a68 Mon Sep 17 00:00:00 2001 From: Mohamed Metwalli Date: Sat, 14 May 2022 10:54:27 +0200 Subject: [PATCH 13/44] Fix syntax --- .github/workflows/android.yml | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index c2657de9048..56919345c2f 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -11,16 +11,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - commands: [ - ':Corona-Warn-App:assembleDeviceRelease', - ':Corona-Warn-App:detekt', - ':Corona-Warn-App:assembleDeviceForTestersRelease', - ':Corona-Warn-App:testDeviceReleaseUnitTest -i', - ':Corona-Warn-App:testDeviceForTestersReleaseUnitTest', - ':Corona-Warn-App:lintDeviceRelease -i', - ':Corona-Warn-App:lintDeviceForTestersRelease -i', - ':Corona-Warn-App:ktlintCheck', - ] + commands: [':Corona-Warn-App:assembleDeviceRelease', ':Corona-Warn-App:detekt', ':Corona-Warn-App:assembleDeviceForTestersRelease', ':Corona-Warn-App:testDeviceReleaseUnitTest -i', ':Corona-Warn-App:testDeviceForTestersReleaseUnitTest', ':Corona-Warn-App:lintDeviceRelease -i', ':Corona-Warn-App:lintDeviceForTestersRelease -i', ':Corona-Warn-App:ktlintCheck'] steps: - uses: actions/checkout@v3 - name: set up JDK 11 @@ -32,9 +23,8 @@ jobs: - name: Grant execute permission for gradlew run: chmod +x gradlew - - name: Ktlint - run: | - ./gradlew ${{ matrix.commands }} + - name: Checks + run: ./gradlew ${{ matrix.commands }} env: JVM_OPTS: -Xmx4096m GRADLE_OPTS: | @@ -48,4 +38,4 @@ jobs: uses: actions/upload-artifact@v3 if: always() with: - path: Corona-Warn-App/build/reports \ No newline at end of file + path: Corona-Warn-App/build/reports From 51363ff9214fa67798a177e561ea73f566bdff51 Mon Sep 17 00:00:00 2001 From: Mohamed Metwalli Date: Sat, 14 May 2022 14:14:34 +0200 Subject: [PATCH 14/44] inline options --- .github/workflows/android.yml | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index 56919345c2f..186b4037301 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -12,6 +12,10 @@ jobs: strategy: matrix: commands: [':Corona-Warn-App:assembleDeviceRelease', ':Corona-Warn-App:detekt', ':Corona-Warn-App:assembleDeviceForTestersRelease', ':Corona-Warn-App:testDeviceReleaseUnitTest -i', ':Corona-Warn-App:testDeviceForTestersReleaseUnitTest', ':Corona-Warn-App:lintDeviceRelease -i', ':Corona-Warn-App:lintDeviceForTestersRelease -i', ':Corona-Warn-App:ktlintCheck'] + + env: + GRADLE_OPTS: -Xmx1536m -XX:+HeapDumpOnOutOfMemoryError -Dorg.gradle.caching=true -Dorg.gradle.configureondemand=true -Dkotlin.compiler.execution.strategy=in-process -Dkotlin.incremental=false + steps: - uses: actions/checkout@v3 - name: set up JDK 11 @@ -25,14 +29,6 @@ jobs: run: chmod +x gradlew - name: Checks run: ./gradlew ${{ matrix.commands }} - env: - JVM_OPTS: -Xmx4096m - GRADLE_OPTS: | - -Xmx1536m -XX:+HeapDumpOnOutOfMemoryError - -Dorg.gradle.caching=true - -Dorg.gradle.configureondemand=true - -Dkotlin.compiler.execution.strategy=in-process - -Dkotlin.incremental=false - name: Reports uses: actions/upload-artifact@v3 From 3133e5ebf07c38471baf7b9843d4095db5908144 Mon Sep 17 00:00:00 2001 From: Mohamed Metwalli Date: Sat, 14 May 2022 14:15:30 +0200 Subject: [PATCH 15/44] Disable --- .../checkins/OrganizerCheckInsTransformerTest.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/presencetracing/checkins/OrganizerCheckInsTransformerTest.kt b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/presencetracing/checkins/OrganizerCheckInsTransformerTest.kt index 765e458e29f..b3bcd7058c5 100644 --- a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/presencetracing/checkins/OrganizerCheckInsTransformerTest.kt +++ b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/presencetracing/checkins/OrganizerCheckInsTransformerTest.kt @@ -19,11 +19,13 @@ import kotlinx.coroutines.test.runTest import okio.ByteString.Companion.encode import org.joda.time.Instant import org.junit.jupiter.api.BeforeEach +import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import testhelpers.BaseTest import java.security.SecureRandom import kotlin.random.asKotlinRandom +@Disabled internal class OrganizerCheckInsTransformerTest : BaseTest() { @MockK lateinit var appConfigProvider: AppConfigProvider From de4d4daf0477fbf6a46319b9944fd5f5b886044b Mon Sep 17 00:00:00 2001 From: Mohamed Metwalli Date: Sun, 15 May 2022 13:27:54 +0200 Subject: [PATCH 16/44] Disable right class --- .../contactdiary/OrganizerRegistrationTokenCensorTest.kt | 2 ++ .../checkins/OrganizerCheckInsTransformerTest.kt | 2 -- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/bugreporting/censors/contactdiary/OrganizerRegistrationTokenCensorTest.kt b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/bugreporting/censors/contactdiary/OrganizerRegistrationTokenCensorTest.kt index 4700d8c319b..00ad01c6930 100644 --- a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/bugreporting/censors/contactdiary/OrganizerRegistrationTokenCensorTest.kt +++ b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/bugreporting/censors/contactdiary/OrganizerRegistrationTokenCensorTest.kt @@ -7,9 +7,11 @@ import io.mockk.MockKAnnotations import kotlinx.coroutines.test.runTest import org.junit.jupiter.api.AfterEach import org.junit.jupiter.api.BeforeEach +import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @Suppress("MaxLineLength") +@Disabled class OrganizerRegistrationTokenCensorTest { private val tans = listOf( diff --git a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/presencetracing/checkins/OrganizerCheckInsTransformerTest.kt b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/presencetracing/checkins/OrganizerCheckInsTransformerTest.kt index b3bcd7058c5..765e458e29f 100644 --- a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/presencetracing/checkins/OrganizerCheckInsTransformerTest.kt +++ b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/presencetracing/checkins/OrganizerCheckInsTransformerTest.kt @@ -19,13 +19,11 @@ import kotlinx.coroutines.test.runTest import okio.ByteString.Companion.encode import org.joda.time.Instant import org.junit.jupiter.api.BeforeEach -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import testhelpers.BaseTest import java.security.SecureRandom import kotlin.random.asKotlinRandom -@Disabled internal class OrganizerCheckInsTransformerTest : BaseTest() { @MockK lateinit var appConfigProvider: AppConfigProvider From 18161538d179e46b127bf46a6676a1c4a8603556 Mon Sep 17 00:00:00 2001 From: Mohamed Metwalli Date: Sun, 15 May 2022 13:28:09 +0200 Subject: [PATCH 17/44] Remove `-i` --- .github/workflows/android.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index 186b4037301..473d5bf5227 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -11,7 +11,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - commands: [':Corona-Warn-App:assembleDeviceRelease', ':Corona-Warn-App:detekt', ':Corona-Warn-App:assembleDeviceForTestersRelease', ':Corona-Warn-App:testDeviceReleaseUnitTest -i', ':Corona-Warn-App:testDeviceForTestersReleaseUnitTest', ':Corona-Warn-App:lintDeviceRelease -i', ':Corona-Warn-App:lintDeviceForTestersRelease -i', ':Corona-Warn-App:ktlintCheck'] + commands: [':Corona-Warn-App:assembleDeviceRelease', ':Corona-Warn-App:detekt', ':Corona-Warn-App:assembleDeviceForTestersRelease', ':Corona-Warn-App:testDeviceReleaseUnitTest', ':Corona-Warn-App:testDeviceForTestersReleaseUnitTest', ':Corona-Warn-App:lintDeviceRelease', ':Corona-Warn-App:lintDeviceForTestersRelease', ':Corona-Warn-App:ktlintCheck'] env: GRADLE_OPTS: -Xmx1536m -XX:+HeapDumpOnOutOfMemoryError -Dorg.gradle.caching=true -Dorg.gradle.configureondemand=true -Dkotlin.compiler.execution.strategy=in-process -Dkotlin.incremental=false From a20eb037c1389a0382a5b614aa4812babe22e0d9 Mon Sep 17 00:00:00 2001 From: Mohamed Metwalli Date: Sun, 15 May 2022 13:42:44 +0200 Subject: [PATCH 18/44] Shorten --- .github/workflows/android.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index 473d5bf5227..1f17b113dfc 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -11,7 +11,14 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - commands: [':Corona-Warn-App:assembleDeviceRelease', ':Corona-Warn-App:detekt', ':Corona-Warn-App:assembleDeviceForTestersRelease', ':Corona-Warn-App:testDeviceReleaseUnitTest', ':Corona-Warn-App:testDeviceForTestersReleaseUnitTest', ':Corona-Warn-App:lintDeviceRelease', ':Corona-Warn-App:lintDeviceForTestersRelease', ':Corona-Warn-App:ktlintCheck'] + commands: [ 'assembleDeviceRelease', + 'ktlintCheck detekt', + 'assembleDeviceForTestersRelease', + 'testDeviceReleaseUnitTest', + 'testDeviceForTestersReleaseUnitTest', + 'lintDeviceRelease', + 'lintDeviceForTestersRelease' + ] env: GRADLE_OPTS: -Xmx1536m -XX:+HeapDumpOnOutOfMemoryError -Dorg.gradle.caching=true -Dorg.gradle.configureondemand=true -Dkotlin.compiler.execution.strategy=in-process -Dkotlin.incremental=false From f43bed037ad40aca0ea4052918a942a85ad92203 Mon Sep 17 00:00:00 2001 From: Mohamed Metwalli Date: Sun, 15 May 2022 13:48:15 +0200 Subject: [PATCH 19/44] Options --- .github/workflows/android.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index 1f17b113dfc..07fe7d51579 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -21,7 +21,13 @@ jobs: ] env: - GRADLE_OPTS: -Xmx1536m -XX:+HeapDumpOnOutOfMemoryError -Dorg.gradle.caching=true -Dorg.gradle.configureondemand=true -Dkotlin.compiler.execution.strategy=in-process -Dkotlin.incremental=false + JVM_OPTS: -Xmx4096m + GRADLE_OPTS: | + -Xmx1536m -XX:+HeapDumpOnOutOfMemoryError + -Dorg.gradle.caching=true + -Dorg.gradle.configureondemand=true + -Dkotlin.compiler.execution.strategy=in-process + -Dkotlin.incremental=false steps: - uses: actions/checkout@v3 From e8bab82d95a09f00ab407251f3d0c376d4f55f44 Mon Sep 17 00:00:00 2001 From: Mohamed Metwalli Date: Sun, 15 May 2022 15:15:44 +0200 Subject: [PATCH 20/44] Gradle `properties` --- .github/ci-gradle.properties | 6 ++++++ .github/workflows/android.yml | 20 +++++++------------- 2 files changed, 13 insertions(+), 13 deletions(-) create mode 100644 .github/ci-gradle.properties diff --git a/.github/ci-gradle.properties b/.github/ci-gradle.properties new file mode 100644 index 00000000000..f7399d87d1f --- /dev/null +++ b/.github/ci-gradle.properties @@ -0,0 +1,6 @@ +org.gradle.daemon=false +org.gradle.parallel=true +org.gradle.jvmargs=-Xmx5120m +org.gradle.workers.max=2 +kotlin.incremental=false +kotlin.compiler.execution.strategy=in-process \ No newline at end of file diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index 07fe7d51579..c28fe2feaf9 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -20,26 +20,20 @@ jobs: 'lintDeviceForTestersRelease' ] - env: - JVM_OPTS: -Xmx4096m - GRADLE_OPTS: | - -Xmx1536m -XX:+HeapDumpOnOutOfMemoryError - -Dorg.gradle.caching=true - -Dorg.gradle.configureondemand=true - -Dkotlin.compiler.execution.strategy=in-process - -Dkotlin.incremental=false - steps: - - uses: actions/checkout@v3 - - name: set up JDK 11 + - name: Checkout + uses: actions/checkout@v3 + + - name: Copy CI gradle.properties + run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties + + - name: Set up JDK 11 uses: actions/setup-java@v3 with: java-version: '11' distribution: 'adopt' cache: gradle - - name: Grant execute permission for gradlew - run: chmod +x gradlew - name: Checks run: ./gradlew ${{ matrix.commands }} From 57609ae966a9617a0ac23873bcacbe12f82e4aad Mon Sep 17 00:00:00 2001 From: Mohamed Metwalli Date: Sun, 15 May 2022 16:17:09 +0200 Subject: [PATCH 21/44] Update android.yml --- .github/workflows/android.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index c28fe2feaf9..6711529d25c 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -33,8 +33,10 @@ jobs: java-version: '11' distribution: 'adopt' cache: gradle + - name: Grant execute permission for gradlew + run: chmod +x gradlew - - name: Checks + - name: Run ${{ matrix.commands }} run: ./gradlew ${{ matrix.commands }} - name: Reports From c88f8320f5f52fd7ca200e49ee369f70629ea99f Mon Sep 17 00:00:00 2001 From: Mohamed Metwalli Date: Sun, 15 May 2022 16:19:34 +0200 Subject: [PATCH 22/44] Sort --- .github/workflows/android.yml | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index 6711529d25c..f427b113eb4 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -11,13 +11,15 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - commands: [ 'assembleDeviceRelease', - 'ktlintCheck detekt', - 'assembleDeviceForTestersRelease', - 'testDeviceReleaseUnitTest', - 'testDeviceForTestersReleaseUnitTest', - 'lintDeviceRelease', - 'lintDeviceForTestersRelease' + commands: [ + 'detekt', + 'ktlintCheck', + 'lintDeviceRelease', + 'assembleDeviceRelease', + 'testDeviceReleaseUnitTest', + 'lintDeviceForTestersRelease', + 'assembleDeviceForTestersRelease', + 'testDeviceForTestersReleaseUnitTest' ] steps: From cb58f61ebc0ca053f2b1d64ce978c000207d8bf6 Mon Sep 17 00:00:00 2001 From: Mohamed Metwalli Date: Sun, 15 May 2022 16:23:13 +0200 Subject: [PATCH 23/44] Update ci-gradle.properties --- .github/ci-gradle.properties | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/ci-gradle.properties b/.github/ci-gradle.properties index f7399d87d1f..fd9faecbb65 100644 --- a/.github/ci-gradle.properties +++ b/.github/ci-gradle.properties @@ -1,6 +1,8 @@ org.gradle.daemon=false +org.gradle.caching=true org.gradle.parallel=true -org.gradle.jvmargs=-Xmx5120m -org.gradle.workers.max=2 kotlin.incremental=false -kotlin.compiler.execution.strategy=in-process \ No newline at end of file +org.gradle.workers.max=2 +org.gradle.configureondemand=true +kotlin.compiler.execution.strategy=in-process +org.gradle.jvmargs=-Xmx5120m -XX:MaxMetaspaceSize=1536m -XX:+HeapDumpOnOutOfMemoryError \ No newline at end of file From ccd81b5fcc3f85f197528851faad27bb39f70e6c Mon Sep 17 00:00:00 2001 From: Katharina Seiz Date: Fri, 20 May 2022 11:17:45 +0200 Subject: [PATCH 24/44] Create build_and_test.yml --- .github/workflows/build_and_test.yml | 544 +++++++++++++++++++++++++++ 1 file changed, 544 insertions(+) create mode 100644 .github/workflows/build_and_test.yml diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml new file mode 100644 index 00000000000..2083b5c3a7d --- /dev/null +++ b/.github/workflows/build_and_test.yml @@ -0,0 +1,544 @@ +name: Build, Scan and Test + +on: + pull_request: + # Sequence of patterns matched against refs/heads + branches: + - main + - 'release/**' + push: + +concurrency: + group: ${{ github.head_ref || github.ref }} #Cancel old runs if they have not finished yet + cancel-in-progress: true + +env: + total-test-runners: 4 + JVM_OPTS: -Xmx4096m + GRADLE_OPTS: | + -Xmx1536m -XX:+HeapDumpOnOutOfMemoryError + -Dorg.gradle.caching=true + -Dorg.gradle.configureondemand=true + -Dkotlin.compiler.execution.strategy=in-process + -Dkotlin.incremental=false + +jobs: + dependencies: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - name: Download sapmachine JDK 11 + run: | + download_url="https://github.com/SAP/SapMachine/releases/download/sapmachine-11.0.14.1/sapmachine-jdk-11.0.14.1_linux-x64_bin.tar.gz" + wget -O "${RUNNER_TEMP}/sapmachine-jdk-11.tar.gz" "${download_url}" + + - name: Setup sapmachine JDK 11 + uses: actions/setup-java@v2 + with: + distribution: 'jdkfile' + jdkFile: ${{ runner.temp }}/sapmachine-jdk-11.tar.gz + java-version: '11.0.14' + architecture: x64 + cache: 'gradle' + + - uses: maxim-lobanov/setup-android-tools@v1 + with: + cache: true + + detekt: + runs-on: ubuntu-latest + needs: dependencies + + steps: + - uses: actions/checkout@v3 + + - name: Download sapmachine JDK 11 + run: | + download_url="https://github.com/SAP/SapMachine/releases/download/sapmachine-11.0.14.1/sapmachine-jdk-11.0.14.1_linux-x64_bin.tar.gz" + wget -O "${RUNNER_TEMP}/sapmachine-jdk-11.tar.gz" "${download_url}" + + - name: Setup sapmachine JDK 11 + uses: actions/setup-java@v2 + with: + distribution: 'jdkfile' + jdkFile: ${{ runner.temp }}/sapmachine-jdk-11.tar.gz + java-version: '11.0.14' + architecture: x64 + cache: 'gradle' + + - uses: maxim-lobanov/setup-android-tools@v1 + with: + cache: true + + - name: Corona-Warn-App:detekt + run: ./gradlew -PdisablePreDex :Corona-Warn-App:detekt + + - name: Archive detekt report + uses: actions/upload-artifact@v3.0.0 + with: + name: reports + path: Corona-Warn-App/build/reports + + + klint: + runs-on: ubuntu-latest + needs: dependencies + + steps: + - uses: actions/checkout@v3 + + - name: Download sapmachine JDK 11 + run: | + download_url="https://github.com/SAP/SapMachine/releases/download/sapmachine-11.0.14.1/sapmachine-jdk-11.0.14.1_linux-x64_bin.tar.gz" + wget -O "${RUNNER_TEMP}/sapmachine-jdk-11.tar.gz" "${download_url}" + + - name: Setup sapmachine JDK 11 + uses: actions/setup-java@v2 + with: + distribution: 'jdkfile' + jdkFile: ${{ runner.temp }}/sapmachine-jdk-11.tar.gz + java-version: '11.0.14' + architecture: x64 + cache: 'gradle' + + - uses: maxim-lobanov/setup-android-tools@v1 + with: + cache: true + + - name: Corona-Warn-App:ktlintCheck + run: ./gradlew -PdisablePreDex :Corona-Warn-App:ktlintCheck + + - name: Archive detekt report + uses: actions/upload-artifact@v3.0.0 + with: + name: reports + path: Corona-Warn-App/build/reports + + lint_device_release_check: + runs-on: ubuntu-latest + needs: dependencies + + steps: + - uses: actions/checkout@v3 + + - name: Download sapmachine JDK 11 + run: | + download_url="https://github.com/SAP/SapMachine/releases/download/sapmachine-11.0.14.1/sapmachine-jdk-11.0.14.1_linux-x64_bin.tar.gz" + wget -O "${RUNNER_TEMP}/sapmachine-jdk-11.tar.gz" "${download_url}" + + - name: Setup sapmachine JDK 11 + uses: actions/setup-java@v2 + with: + distribution: 'jdkfile' + jdkFile: ${{ runner.temp }}/sapmachine-jdk-11.tar.gz + java-version: '11.0.14' + architecture: x64 + cache: 'gradle' + + - uses: maxim-lobanov/setup-android-tools@v1 + with: + cache: true + + - name: Corona-Warn-App:lintDeviceRelease + run: ./gradlew -PdisablePreDex :Corona-Warn-App:lintDeviceRelease -i + + - name: Archive detekt report + uses: actions/upload-artifact@v3.0.0 + with: + name: reports + path: Corona-Warn-App/build/reports + + lint_device_for_testers_release_check: + runs-on: ubuntu-latest + needs: dependencies + + steps: + - uses: actions/checkout@v3 + + - name: Download sapmachine JDK 11 + run: | + download_url="https://github.com/SAP/SapMachine/releases/download/sapmachine-11.0.14.1/sapmachine-jdk-11.0.14.1_linux-x64_bin.tar.gz" + wget -O "${RUNNER_TEMP}/sapmachine-jdk-11.tar.gz" "${download_url}" + + - name: Setup sapmachine JDK 11 + uses: actions/setup-java@v2 + with: + distribution: 'jdkfile' + jdkFile: ${{ runner.temp }}/sapmachine-jdk-11.tar.gz + java-version: '11.0.14' + architecture: x64 + cache: 'gradle' + + - uses: maxim-lobanov/setup-android-tools@v1 + with: + cache: true + + - name: Corona-Warn-App:lintDeviceForTestersRelease + run: ./gradlew -PdisablePreDex :Corona-Warn-App:lintDeviceForTestersRelease -i + + - name: Archive detekt report + uses: actions/upload-artifact@v3.0.0 + with: + name: reports + path: Corona-Warn-App/build/reports + + quick_build_device_release_no_tests: + runs-on: ubuntu-latest + needs: dependencies + + steps: + - uses: actions/checkout@v3 + + - name: Download sapmachine JDK 11 + run: | + download_url="https://github.com/SAP/SapMachine/releases/download/sapmachine-11.0.14.1/sapmachine-jdk-11.0.14.1_linux-x64_bin.tar.gz" + wget -O "${RUNNER_TEMP}/sapmachine-jdk-11.tar.gz" "${download_url}" + + - name: Setup sapmachine JDK 11 + uses: actions/setup-java@v2 + with: + distribution: 'jdkfile' + jdkFile: ${{ runner.temp }}/sapmachine-jdk-11.tar.gz + java-version: '11.0.14' + architecture: x64 + cache: 'gradle' + + - uses: maxim-lobanov/setup-android-tools@v1 + with: + cache: true + + - name: Quick Build + run: ./gradlew -PdisablePreDex assembleDeviceRelease + + quick_build_device_for_testers_release_no_tests: + runs-on: ubuntu-latest + needs: dependencies + + steps: + - uses: actions/checkout@v3 + + - name: Download sapmachine JDK 11 + run: | + download_url="https://github.com/SAP/SapMachine/releases/download/sapmachine-11.0.14.1/sapmachine-jdk-11.0.14.1_linux-x64_bin.tar.gz" + wget -O "${RUNNER_TEMP}/sapmachine-jdk-11.tar.gz" "${download_url}" + + - name: Setup sapmachine JDK 11 + uses: actions/setup-java@v2 + with: + distribution: 'jdkfile' + jdkFile: ${{ runner.temp }}/sapmachine-jdk-11.tar.gz + java-version: '11.0.14' + architecture: x64 + cache: 'gradle' + + - uses: maxim-lobanov/setup-android-tools@v1 + with: + cache: true + + - name: Quick Build + run: ./gradlew -PdisablePreDex :Corona-Warn-App:assembleDeviceForTestersRelease + + + unit-test-runner-indexes: + runs-on: ubuntu-latest + name: Generate unit test runner indexes + outputs: + json: ${{ steps.generate-index-list.outputs.json }} + steps: + - id: generate-index-list + run: | + MAX_INDEX=$((${{ env.total-test-runners }}-1)) + INDEX_LIST=$(seq 0 ${MAX_INDEX}) + INDEX_JSON=$(jq --null-input --compact-output '. |= [inputs]' <<< ${INDEX_LIST}) + echo "::set-output name=json::${INDEX_JSON}" + + unit_tests_device_release: + name: "Runner #${{ matrix.runner-index }}: Run test suite in parallel" + runs-on: ubuntu-latest + needs: + - dependencies + - unit-test-runner-indexes + strategy: + matrix: + runner-index: ${{ fromJSON(needs.unit-test-runner-indexes.outputs.json) }} + steps: + - uses: actions/checkout@v3 + + - name: Download sapmachine JDK 11 + run: | + download_url="https://github.com/SAP/SapMachine/releases/download/sapmachine-11.0.14.1/sapmachine-jdk-11.0.14.1_linux-x64_bin.tar.gz" + wget -O "${RUNNER_TEMP}/sapmachine-jdk-11.tar.gz" "${download_url}" + + - name: Setup sapmachine JDK 11 + uses: actions/setup-java@v2 + with: + distribution: 'jdkfile' + jdkFile: ${{ runner.temp }}/sapmachine-jdk-11.tar.gz + java-version: '11.0.14' + architecture: x64 + cache: 'gradle' + + - uses: maxim-lobanov/setup-android-tools@v1 + with: + cache: true + + - uses: chaosaffe/split-tests@v1-alpha.1 + id: split-tests + name: Split tests + with: + glob: Corona-Warn-App/**/test*/**/*.kt + split-total: ${{ env.total-test-runners }} + split-index: ${{ matrix.runner-index }} + + - run: 'echo "This runner will execute the following tests: ${{ steps.split-tests.outputs.test-suite }}"' + + - name: Test + run: ./gradlew -PdisablePreDex :Corona-Warn-App:testDeviceReleaseUnitTest -i -PtestFilter="${{ steps.split-tests.outputs.test-suite }}" + + - name: Archive Test Result + uses: actions/upload-artifact@v3 + with: + name: testResults + path: Corona-Warn-App/build/test-results + + - name: Archive Test Result + uses: actions/upload-artifact@v3 + with: + name: reports + path: Corona-Warn-App/build/reports + + unit_tests_device_for_testers_release: + name: "Runner #${{ matrix.runner-index }}: Run test for testers suite in parallel" + runs-on: ubuntu-latest + needs: + - dependencies + - unit-test-runner-indexes + strategy: + matrix: + runner-index: ${{ fromJSON(needs.unit-test-runner-indexes.outputs.json) }} + steps: + - uses: actions/checkout@v3 + + - name: Download sapmachine JDK 11 + run: | + download_url="https://github.com/SAP/SapMachine/releases/download/sapmachine-11.0.14.1/sapmachine-jdk-11.0.14.1_linux-x64_bin.tar.gz" + wget -O "${RUNNER_TEMP}/sapmachine-jdk-11.tar.gz" "${download_url}" + + - name: Setup sapmachine JDK 11 + uses: actions/setup-java@v2 + with: + distribution: 'jdkfile' + jdkFile: ${{ runner.temp }}/sapmachine-jdk-11.tar.gz + java-version: '11.0.14' + architecture: x64 + cache: 'gradle' + + - uses: maxim-lobanov/setup-android-tools@v1 + with: + cache: true + + - uses: chaosaffe/split-tests@v1-alpha.1 + id: split-tests + name: Split tests + with: + glob: Corona-Warn-App/**/test*/**/*.kt + split-total: ${{ env.total-test-runners }} + split-index: ${{ matrix.runner-index }} + + - run: 'echo "This runner will execute the following tests: ${{ steps.split-tests.outputs.test-suite }}"' + + - name: Test + run: ./gradlew -PdisablePreDex :Corona-Warn-App:testDeviceForTestersReleaseUnitTest -i -PtestFilter="${{ steps.split-tests.outputs.test-suite }}" + + - name: Archive Test Result + uses: actions/upload-artifact@v3 + with: + name: testResults + path: Corona-Warn-App/build/test-results + + - name: Archive Test Result + uses: actions/upload-artifact@v3 + with: + name: reports + path: Corona-Warn-App/build/reports + + publish_test_results: + runs-on: ubuntu-latest + needs: + - unit_tests_device_release + permissions: + checks: write + pull-requests: write + steps: + - name: Download Artifacts + uses: actions/download-artifact@v3 + with: + name: testResults + path: artifacts + + - name: Display structure of downloaded files + run: ls -R + + - name: Publish Test Results - Device Release + uses: EnricoMi/publish-unit-test-result-action@v1 + if: always() + with: + check_name: "Unit Test Results - Device Release" + files: "artifacts/testDeviceReleaseUnitTest/*.xml" + + publish_test_for_testers_results: + runs-on: ubuntu-latest + needs: + - unit_tests_device_for_testers_release + permissions: + checks: write + pull-requests: write + steps: + - name: Download Artifacts + uses: actions/download-artifact@v3 + with: + name: testResults + path: artifacts + + - name: Display structure of downloaded files + run: ls -R + + - name: Publish Test Results - Device For Tester Release + uses: EnricoMi/publish-unit-test-result-action@v1 + if: always() + with: + check_name: "Unit Test Results - Device For Tester Release" + files: "artifacts/testDeviceForTestersReleaseUnitTest/*.xml" + + run_sonar_scan: + runs-on: ubuntu-latest + needs: unit_tests_device_release + if: ${{ !github.event.pull_request.head.repo.fork }} + steps: + - uses: actions/checkout@v3 + + - name: Download sapmachine JDK 11 + run: | + download_url="https://github.com/SAP/SapMachine/releases/download/sapmachine-11.0.14.1/sapmachine-jdk-11.0.14.1_linux-x64_bin.tar.gz" + wget -O "${RUNNER_TEMP}/sapmachine-jdk-11.tar.gz" "${download_url}" + + - name: Setup sapmachine JDK 11 + uses: actions/setup-java@v2 + with: + distribution: 'jdkfile' + jdkFile: ${{ runner.temp }}/sapmachine-jdk-11.tar.gz + java-version: '11.0.14' + architecture: x64 + cache: 'gradle' + + - uses: maxim-lobanov/setup-android-tools@v1 + with: + cache: true + + - name: Generate JaCoCo report + run: ./gradlew -PdisablePreDex :Corona-Warn-App:jacocoTestReportDeviceRelease -i + + - name: Archive JaCoCo report + uses: actions/upload-artifact@v3 + with: + name: reports + path: Corona-Warn-App/build/reports + + - name: SonarCloud Scan + uses: sonarsource/sonarcloud-github-action@v1.6 + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + + instrumentation_tests_device: + runs-on: ubuntu-latest + needs: + - detekt + - klint + if: ${{ !github.event.pull_request.head.repo.fork }} + env: + GCLOUD_SERVICE_KEY_BASE64: '${{ secrets.GCLOUD_SERVICE_KEY_BASE64 }}' + GOOGLE_PROJECT_ID: '${{ secrets.GOOGLE_PROJECT_ID }}' + permissions: + checks: write + pull-requests: write + steps: + + - uses: actions/checkout@v3 + + - name: Download sapmachine JDK 11 + run: | + download_url="https://github.com/SAP/SapMachine/releases/download/sapmachine-11.0.14.1/sapmachine-jdk-11.0.14.1_linux-x64_bin.tar.gz" + wget -O "${RUNNER_TEMP}/sapmachine-jdk-11.tar.gz" "${download_url}" + + - name: Setup sapmachine JDK 11 + uses: actions/setup-java@v2 + with: + distribution: 'jdkfile' + jdkFile: ${{ runner.temp }}/sapmachine-jdk-11.tar.gz + java-version: '11.0.14' + architecture: x64 + cache: 'gradle' + + - uses: maxim-lobanov/setup-android-tools@v1 + with: + cache: true + + - name: Build App APK + run: ./gradlew -PdisablePreDex :Corona-Warn-App:assembleDeviceForTestersDebug + + - name: Build Test App APK + run: ./gradlew -PdisablePreDex :Corona-Warn-App:assembleDeviceForTestersDebugAndroidTest + + - name: Setup Google Cloud access + run: | + echo $GCLOUD_SERVICE_KEY_BASE64 | base64 -di > ${HOME}/gcloud-service-key.json + sudo gcloud auth activate-service-account --key-file=${HOME}/gcloud-service-key.json + sudo gcloud --quiet config set project ${GOOGLE_PROJECT_ID} + + - name: Setup Testlab environment + run: | + echo "BUCKETDIR=`date "+%Y-%m-%d-%H:%M:%S:%3N"`-${RANDOM}" >> $GITHUB_ENV + + - name: Test with Firebase Test Lab + run: | + echo "Using bucketdir ${{ env.BUCKETDIR }}" + sudo gcloud firebase test android run \ + --type instrumentation \ + --app Corona-Warn-App/build/outputs/apk/deviceForTesters/debug/*.apk \ + --test Corona-Warn-App/build/outputs/apk/androidTest/deviceForTesters/debug/*.apk \ + --results-dir ${{ env.BUCKETDIR }} \ + --results-bucket ${GOOGLE_PROJECT_ID}-circleci-android \ + --environment-variables clearPackageData=true \ + --test-targets "notAnnotation testhelpers.Screenshot" \ + --timeout 20m \ + --device-ids blueline \ + --os-version-ids 28 \ + --locales de_DE \ + --orientations portrait \ + --num-flaky-test-attempts 3 \ + --no-record-video + + - name: Create directory to store test results + if: always() + run: mkdir firebase-results + + - name: Install gsutil dependency and copy test results data + if: always() + run: | + sudo pip install -U crcmod + sudo gsutil -m cp -R -U gs://${GOOGLE_PROJECT_ID}-circleci-android/${{ env.BUCKETDIR }}/blueline* firebase-results + + - name: Archive Test Result + uses: actions/upload-artifact@v3 + with: + name: testResults + path: firebase-results + + - name: Publish Firebase Test Results + uses: EnricoMi/publish-unit-test-result-action@v1 + if: always() + with: + check_name: "Firebase Test Results" + files: "firebase-results/**/*.xml" From 74637985fcc16aa93435e0fbc0be7d0545bbf824 Mon Sep 17 00:00:00 2001 From: Katharina Seiz Date: Fri, 20 May 2022 11:20:07 +0200 Subject: [PATCH 25/44] Create ReleaseCandidate.yml --- .github/workflows/ReleaseCandidate.yml | 217 +++++++++++++++++++++++++ 1 file changed, 217 insertions(+) create mode 100644 .github/workflows/ReleaseCandidate.yml diff --git a/.github/workflows/ReleaseCandidate.yml b/.github/workflows/ReleaseCandidate.yml new file mode 100644 index 00000000000..be3ddd602b9 --- /dev/null +++ b/.github/workflows/ReleaseCandidate.yml @@ -0,0 +1,217 @@ +name: Create Release Candidate + +on: + push: + tags: + - 'v[0-9]+.[0-9]+.[0-9]+*' + +env: + JVM_OPTS: -Xmx4096m + GRADLE_OPTS: | + -Xmx1536m -XX:+HeapDumpOnOutOfMemoryError + -Dorg.gradle.caching=true + -Dorg.gradle.configureondemand=true + -Dkotlin.compiler.execution.strategy=in-process + -Dkotlin.incremental=false + +jobs: + dependencies: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - name: Download sapmachine JDK 11 + run: | + download_url="https://github.com/SAP/SapMachine/releases/download/sapmachine-11.0.14.1/sapmachine-jdk-11.0.14.1_linux-x64_bin.tar.gz" + wget -O "${RUNNER_TEMP}/sapmachine-jdk-11.tar.gz" "${download_url}" + + - name: Setup sapmachine JDK 11 + uses: actions/setup-java@v2 + with: + distribution: 'jdkfile' + jdkFile: ${{ runner.temp }}/sapmachine-jdk-11.tar.gz + java-version: '11.0.14' + architecture: x64 + cache: 'gradle' + + - uses: maxim-lobanov/setup-android-tools@v1 + with: + cache: true + + quick_build_device_for_testers_signed: + runs-on: ubuntu-latest + needs: dependencies + env: + keystore_download_token: '${{ secrets.KEYSTORE_DOWNLOAD_TOKEN }}' + keystore_download_url: '${{ secrets.KEYSTORE_DOWNLOAD_URL }}' + keystore_download_filename: '${{ secrets.KEYSTORE_DOWNLOAD_FILENAME }}' + environments_download_url: '${{ secrets.ENVIRONMENTS_DOWNLOAD_URL }}' + env_prop_download_filename: '${{ secrets.ENV_PROP_DOWNLOAD_FILENAME }}' + keystore_filename: '${{ secrets.KEYSTORE_FILENAME }}' + keystore_encrypt_key: '${{ secrets.KEYSTORE_ENCRYPT_KEY }}' + keystore_password: '${{ secrets.KEYSTORE_PASSWORD }}' + key_alias: '${{ secrets.KEY_ALIAS }}' + key_password: '${{ secrets.KEY_PASSWORD }}' + + steps: + - uses: actions/checkout@v3 + + - name: Download sapmachine JDK 11 + run: | + download_url="https://github.com/SAP/SapMachine/releases/download/sapmachine-11.0.14.1/sapmachine-jdk-11.0.14.1_linux-x64_bin.tar.gz" + wget -O "${RUNNER_TEMP}/sapmachine-jdk-11.tar.gz" "${download_url}" + + - name: Setup sapmachine JDK 11 + uses: actions/setup-java@v2 + with: + distribution: 'jdkfile' + jdkFile: ${{ runner.temp }}/sapmachine-jdk-11.tar.gz + java-version: '11.0.14' + architecture: x64 + cache: 'gradle' + + - uses: maxim-lobanov/setup-android-tools@v1 + with: + cache: true + + - name: Download Keystore + run: | + curl --header "Authorization: token ${keystore_download_token}" --header "Accept: application/vnd.github.v3.raw" --remote-name --location "${keystore_download_url}${keystore_download_filename}" + - name: Download Environment Properties + run: | + curl --header "Authorization: token ${keystore_download_token}" --header "Accept: application/vnd.github.v3.raw" --remote-name --location "${environments_download_url}${env_prop_download_filename}" + - name: Decrypt Keystore + run: openssl enc -aes-256-cbc -d -pbkdf2 -iter 100000 -in $keystore_download_filename -out $keystore_filename -k $keystore_encrypt_key + + - name: Prepare commit hash + run: | + echo $GITHUB_SHA + echo "" >> "./gradle.properties" + echo "commit_hash=${GITHUB_SHA}" >> "./gradle.properties" + + - name: Prepare keystore properties for Signing + run: | + echo "" >> "./keystore.properties" + echo "deviceForTestersRelease.storePath=../${keystore_filename}" >> "./keystore.properties" + echo "deviceForTestersRelease.storePassword=${keystore_password}" >> "./keystore.properties" + echo "deviceForTestersRelease.keyAlias=${key_alias}" >> "./keystore.properties" + echo "deviceForTestersRelease.keyPassword=${key_password}" >> "./keystore.properties" + + - name: Quick Build + run: ./gradlew -PdisablePreDex :Corona-Warn-App:assembleDeviceForTestersRelease + + - name: Archive apk + uses: actions/upload-artifact@v3 + with: + path: Corona-Warn-App/build/outputs/apk/deviceForTesters/release/*.apk + + - name: Send to T-System + env: + tsystems_upload_url: '${{ secrets.TSYSTEM_UPLOAD_URL }}' + tsystems_upload_bearer: '${{ secrets.TSYSTEM_UPLOAD_BEARER }}' + run: | + fileName=$(find Corona-Warn-App/build/outputs/apk/deviceForTesters/release -name '*Corona-Warn-App*.apk') + curl --location --request POST $tsystems_upload_url \ + --header "Authorization: Bearer $tsystems_upload_bearer" \ + --form "file=@${fileName}" \ + --form "camera=true" + + - name: trigger App Automation Testing + env: + CIRCLE_API_ADMIN_TOKEN: '${{ secrets.CIRCLE_API_ADMIN_TOKEN }}' + run: | + curl -u ${CIRCLE_API_ADMIN_TOKEN}: \ + -d '{"branch":"main","parameters":{"mobile-os":"android"}}' \ + -H 'content-type: application/json' \ + https://circleci.com/api/v2/project/github/corona-warn-app/cwa-app-automation/pipeline + + firebase_screenshots: + runs-on: ubuntu-latest + needs: dependencies + env: + GCLOUD_SERVICE_KEY_BASE64: '${{ secrets.GCLOUD_SERVICE_KEY_BASE64 }}' + GOOGLE_PROJECT_ID: '${{ secrets.GOOGLE_PROJECT_ID }}' + permissions: + checks: write + pull-requests: write + steps: + + - uses: actions/checkout@v3 + + - name: Download sapmachine JDK 11 + run: | + download_url="https://github.com/SAP/SapMachine/releases/download/sapmachine-11.0.14.1/sapmachine-jdk-11.0.14.1_linux-x64_bin.tar.gz" + wget -O "${RUNNER_TEMP}/sapmachine-jdk-11.tar.gz" "${download_url}" + - name: Setup sapmachine JDK 11 + uses: actions/setup-java@v2 + with: + distribution: 'jdkfile' + jdkFile: ${{ runner.temp }}/sapmachine-jdk-11.tar.gz + java-version: '11.0.14' + architecture: x64 + cache: 'gradle' + + - uses: maxim-lobanov/setup-android-tools@v1 + with: + cache: true + + - name: Build APKs for screenshots + run: ./gradlew -PdisablePreDex :Corona-Warn-App:assembleDebug :Corona-Warn-App:assembleAndroidTest + + - name: Setup Google Cloud access + run: | + echo $GCLOUD_SERVICE_KEY_BASE64 | base64 -di > ${HOME}/gcloud-service-key.json + sudo gcloud auth activate-service-account --key-file=${HOME}/gcloud-service-key.json + sudo gcloud --quiet config set project ${GOOGLE_PROJECT_ID} + + - name: Setup Testlab environment + run: | + echo "BUCKETDIR=`date "+%Y-%m-%d-%H:%M:%S:%3N"`-${RANDOM}" >> $GITHUB_ENV + - name: Test with Firebase Test Lab + run: | + echo "Using bucketdir ${{ env.BUCKETDIR }}" + sudo gcloud firebase test android run \ + --type instrumentation \ + --app Corona-Warn-App/build/outputs/apk/deviceForTesters/debug/*.apk \ + --test Corona-Warn-App/build/outputs/apk/androidTest/deviceForTesters/debug/*.apk \ + --results-dir ${BUCKETDIR} \ + --results-bucket ${GOOGLE_PROJECT_ID}-circleci-android \ + --environment-variables clearPackageData=true \ + --test-targets "annotation testhelpers.Screenshot" \ + --timeout 20m \ + --device-ids blueline \ + --os-version-ids 28 \ + --locales de_DE,en_US \ + --orientations portrait \ + --no-record-video + + - name: Create directory to store test results + if: always() + run: mkdir mkdir firebase-screenshots + + - name: Install gsutil dependency and copy test results data + if: always() + run: | + sudo pip install -U crcmod + sudo gsutil -m cp -R -U gs://${GOOGLE_PROJECT_ID}-circleci-android/${{ env.BUCKETDIR }}/blueline* mkdir firebase-screenshots + + - name: Publish Firebase Test Results + uses: EnricoMi/publish-unit-test-result-action@v1 + if: always() + with: + check_name: "Firebase Test Results" + files: "firebase-screenshots/**/*.xml" + + - name: Clean up pulled bucket + run: | + sudo rm -rf firebase-screenshots/*/test_cases + sudo rm -f firebase-screenshots/*/instrumentation.results + sudo rm -f firebase-screenshots/*/logcat + sudo rm -f firebase-screenshots/*/test_result_1.xml + + - name: Archive Test Result + uses: actions/upload-artifact@v3 + with: + name: screenshots + path: firebase-screenshots From 7d68e123c7dc8f95185d6b1ffa506837dd60fad5 Mon Sep 17 00:00:00 2001 From: Katharina Seiz Date: Fri, 20 May 2022 11:27:24 +0200 Subject: [PATCH 26/44] Delete android.yml --- .github/workflows/android.yml | 48 ----------------------------------- 1 file changed, 48 deletions(-) delete mode 100644 .github/workflows/android.yml diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml deleted file mode 100644 index f427b113eb4..00000000000 --- a/.github/workflows/android.yml +++ /dev/null @@ -1,48 +0,0 @@ -name: Android CI - -on: [ push ] - -concurrency: - group: build-${{ github.ref }} - cancel-in-progress: true - -jobs: - build: - runs-on: ubuntu-latest - strategy: - matrix: - commands: [ - 'detekt', - 'ktlintCheck', - 'lintDeviceRelease', - 'assembleDeviceRelease', - 'testDeviceReleaseUnitTest', - 'lintDeviceForTestersRelease', - 'assembleDeviceForTestersRelease', - 'testDeviceForTestersReleaseUnitTest' - ] - - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Copy CI gradle.properties - run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties - - - name: Set up JDK 11 - uses: actions/setup-java@v3 - with: - java-version: '11' - distribution: 'adopt' - cache: gradle - - name: Grant execute permission for gradlew - run: chmod +x gradlew - - - name: Run ${{ matrix.commands }} - run: ./gradlew ${{ matrix.commands }} - - - name: Reports - uses: actions/upload-artifact@v3 - if: always() - with: - path: Corona-Warn-App/build/reports From 742f77f936d2055ae057c0e1cb71811e27e20e05 Mon Sep 17 00:00:00 2001 From: Katharina Seiz Date: Fri, 20 May 2022 15:00:22 +0200 Subject: [PATCH 27/44] Update build_and_test.yml --- .github/workflows/build_and_test.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index 2083b5c3a7d..ac4b0766660 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -446,9 +446,10 @@ jobs: name: reports path: Corona-Warn-App/build/reports - - name: SonarCloud Scan - uses: sonarsource/sonarcloud-github-action@v1.6 + - name: Sonar Cloud Scan + uses: SonarSource/sonarcloud-github-action@master env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} instrumentation_tests_device: From 4757cc40cb49918dc0f9d721828f63b9ef016b44 Mon Sep 17 00:00:00 2001 From: Mohamed Metwalli Date: Mon, 23 May 2022 13:22:21 +0200 Subject: [PATCH 28/44] Sonar --- .github/workflows/build_and_test.yml | 632 ++++++++++++++------------- Corona-Warn-App/build.gradle | 9 + build.gradle | 1 + 3 files changed, 327 insertions(+), 315 deletions(-) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index ac4b0766660..b8ea5e74147 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -3,12 +3,12 @@ name: Build, Scan and Test on: pull_request: # Sequence of patterns matched against refs/heads - branches: + branches: - main - 'release/**' push: -concurrency: +concurrency: group: ${{ github.head_ref || github.ref }} #Cancel old runs if they have not finished yet cancel-in-progress: true @@ -16,231 +16,231 @@ env: total-test-runners: 4 JVM_OPTS: -Xmx4096m GRADLE_OPTS: | - -Xmx1536m -XX:+HeapDumpOnOutOfMemoryError - -Dorg.gradle.caching=true - -Dorg.gradle.configureondemand=true - -Dkotlin.compiler.execution.strategy=in-process - -Dkotlin.incremental=false - + -Xmx1536m -XX:+HeapDumpOnOutOfMemoryError + -Dorg.gradle.caching=true + -Dorg.gradle.configureondemand=true + -Dkotlin.compiler.execution.strategy=in-process + -Dkotlin.incremental=false + jobs: dependencies: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - - name: Download sapmachine JDK 11 - run: | - download_url="https://github.com/SAP/SapMachine/releases/download/sapmachine-11.0.14.1/sapmachine-jdk-11.0.14.1_linux-x64_bin.tar.gz" - wget -O "${RUNNER_TEMP}/sapmachine-jdk-11.tar.gz" "${download_url}" - - - name: Setup sapmachine JDK 11 - uses: actions/setup-java@v2 - with: - distribution: 'jdkfile' - jdkFile: ${{ runner.temp }}/sapmachine-jdk-11.tar.gz - java-version: '11.0.14' - architecture: x64 - cache: 'gradle' - - - uses: maxim-lobanov/setup-android-tools@v1 - with: - cache: true - - detekt: + - uses: actions/checkout@v3 + + - name: Download sapmachine JDK 11 + run: | + download_url="https://github.com/SAP/SapMachine/releases/download/sapmachine-11.0.14.1/sapmachine-jdk-11.0.14.1_linux-x64_bin.tar.gz" + wget -O "${RUNNER_TEMP}/sapmachine-jdk-11.tar.gz" "${download_url}" + + - name: Setup sapmachine JDK 11 + uses: actions/setup-java@v2 + with: + distribution: 'jdkfile' + jdkFile: ${{ runner.temp }}/sapmachine-jdk-11.tar.gz + java-version: '11.0.14' + architecture: x64 + cache: 'gradle' + + - uses: maxim-lobanov/setup-android-tools@v1 + with: + cache: true + + detekt: runs-on: ubuntu-latest needs: dependencies - + steps: - - uses: actions/checkout@v3 - - - name: Download sapmachine JDK 11 - run: | - download_url="https://github.com/SAP/SapMachine/releases/download/sapmachine-11.0.14.1/sapmachine-jdk-11.0.14.1_linux-x64_bin.tar.gz" - wget -O "${RUNNER_TEMP}/sapmachine-jdk-11.tar.gz" "${download_url}" - - - name: Setup sapmachine JDK 11 - uses: actions/setup-java@v2 - with: - distribution: 'jdkfile' - jdkFile: ${{ runner.temp }}/sapmachine-jdk-11.tar.gz - java-version: '11.0.14' - architecture: x64 - cache: 'gradle' - - - uses: maxim-lobanov/setup-android-tools@v1 - with: - cache: true - - - name: Corona-Warn-App:detekt - run: ./gradlew -PdisablePreDex :Corona-Warn-App:detekt - - - name: Archive detekt report - uses: actions/upload-artifact@v3.0.0 - with: - name: reports - path: Corona-Warn-App/build/reports - - - klint: + - uses: actions/checkout@v3 + + - name: Download sapmachine JDK 11 + run: | + download_url="https://github.com/SAP/SapMachine/releases/download/sapmachine-11.0.14.1/sapmachine-jdk-11.0.14.1_linux-x64_bin.tar.gz" + wget -O "${RUNNER_TEMP}/sapmachine-jdk-11.tar.gz" "${download_url}" + + - name: Setup sapmachine JDK 11 + uses: actions/setup-java@v2 + with: + distribution: 'jdkfile' + jdkFile: ${{ runner.temp }}/sapmachine-jdk-11.tar.gz + java-version: '11.0.14' + architecture: x64 + cache: 'gradle' + + - uses: maxim-lobanov/setup-android-tools@v1 + with: + cache: true + + - name: Corona-Warn-App:detekt + run: ./gradlew -PdisablePreDex :Corona-Warn-App:detekt + + - name: Archive detekt report + uses: actions/upload-artifact@v3.0.0 + with: + name: reports + path: Corona-Warn-App/build/reports + + + klint: runs-on: ubuntu-latest needs: dependencies - + steps: - - uses: actions/checkout@v3 - - - name: Download sapmachine JDK 11 - run: | - download_url="https://github.com/SAP/SapMachine/releases/download/sapmachine-11.0.14.1/sapmachine-jdk-11.0.14.1_linux-x64_bin.tar.gz" - wget -O "${RUNNER_TEMP}/sapmachine-jdk-11.tar.gz" "${download_url}" - - - name: Setup sapmachine JDK 11 - uses: actions/setup-java@v2 - with: - distribution: 'jdkfile' - jdkFile: ${{ runner.temp }}/sapmachine-jdk-11.tar.gz - java-version: '11.0.14' - architecture: x64 - cache: 'gradle' - - - uses: maxim-lobanov/setup-android-tools@v1 - with: - cache: true - - - name: Corona-Warn-App:ktlintCheck - run: ./gradlew -PdisablePreDex :Corona-Warn-App:ktlintCheck - - - name: Archive detekt report - uses: actions/upload-artifact@v3.0.0 - with: - name: reports - path: Corona-Warn-App/build/reports - - lint_device_release_check: + - uses: actions/checkout@v3 + + - name: Download sapmachine JDK 11 + run: | + download_url="https://github.com/SAP/SapMachine/releases/download/sapmachine-11.0.14.1/sapmachine-jdk-11.0.14.1_linux-x64_bin.tar.gz" + wget -O "${RUNNER_TEMP}/sapmachine-jdk-11.tar.gz" "${download_url}" + + - name: Setup sapmachine JDK 11 + uses: actions/setup-java@v2 + with: + distribution: 'jdkfile' + jdkFile: ${{ runner.temp }}/sapmachine-jdk-11.tar.gz + java-version: '11.0.14' + architecture: x64 + cache: 'gradle' + + - uses: maxim-lobanov/setup-android-tools@v1 + with: + cache: true + + - name: Corona-Warn-App:ktlintCheck + run: ./gradlew -PdisablePreDex :Corona-Warn-App:ktlintCheck + + - name: Archive detekt report + uses: actions/upload-artifact@v3.0.0 + with: + name: reports + path: Corona-Warn-App/build/reports + + lint_device_release_check: runs-on: ubuntu-latest needs: dependencies - + steps: - - uses: actions/checkout@v3 - - - name: Download sapmachine JDK 11 - run: | - download_url="https://github.com/SAP/SapMachine/releases/download/sapmachine-11.0.14.1/sapmachine-jdk-11.0.14.1_linux-x64_bin.tar.gz" - wget -O "${RUNNER_TEMP}/sapmachine-jdk-11.tar.gz" "${download_url}" - - - name: Setup sapmachine JDK 11 - uses: actions/setup-java@v2 - with: - distribution: 'jdkfile' - jdkFile: ${{ runner.temp }}/sapmachine-jdk-11.tar.gz - java-version: '11.0.14' - architecture: x64 - cache: 'gradle' - - - uses: maxim-lobanov/setup-android-tools@v1 - with: - cache: true - - - name: Corona-Warn-App:lintDeviceRelease - run: ./gradlew -PdisablePreDex :Corona-Warn-App:lintDeviceRelease -i - - - name: Archive detekt report - uses: actions/upload-artifact@v3.0.0 - with: - name: reports - path: Corona-Warn-App/build/reports - - lint_device_for_testers_release_check: + - uses: actions/checkout@v3 + + - name: Download sapmachine JDK 11 + run: | + download_url="https://github.com/SAP/SapMachine/releases/download/sapmachine-11.0.14.1/sapmachine-jdk-11.0.14.1_linux-x64_bin.tar.gz" + wget -O "${RUNNER_TEMP}/sapmachine-jdk-11.tar.gz" "${download_url}" + + - name: Setup sapmachine JDK 11 + uses: actions/setup-java@v2 + with: + distribution: 'jdkfile' + jdkFile: ${{ runner.temp }}/sapmachine-jdk-11.tar.gz + java-version: '11.0.14' + architecture: x64 + cache: 'gradle' + + - uses: maxim-lobanov/setup-android-tools@v1 + with: + cache: true + + - name: Corona-Warn-App:lintDeviceRelease + run: ./gradlew -PdisablePreDex :Corona-Warn-App:lintDeviceRelease -i + + - name: Archive detekt report + uses: actions/upload-artifact@v3.0.0 + with: + name: reports + path: Corona-Warn-App/build/reports + + lint_device_for_testers_release_check: runs-on: ubuntu-latest needs: dependencies - + steps: - - uses: actions/checkout@v3 - - - name: Download sapmachine JDK 11 - run: | - download_url="https://github.com/SAP/SapMachine/releases/download/sapmachine-11.0.14.1/sapmachine-jdk-11.0.14.1_linux-x64_bin.tar.gz" - wget -O "${RUNNER_TEMP}/sapmachine-jdk-11.tar.gz" "${download_url}" - - - name: Setup sapmachine JDK 11 - uses: actions/setup-java@v2 - with: - distribution: 'jdkfile' - jdkFile: ${{ runner.temp }}/sapmachine-jdk-11.tar.gz - java-version: '11.0.14' - architecture: x64 - cache: 'gradle' - - - uses: maxim-lobanov/setup-android-tools@v1 - with: - cache: true - - - name: Corona-Warn-App:lintDeviceForTestersRelease - run: ./gradlew -PdisablePreDex :Corona-Warn-App:lintDeviceForTestersRelease -i - - - name: Archive detekt report - uses: actions/upload-artifact@v3.0.0 - with: - name: reports - path: Corona-Warn-App/build/reports + - uses: actions/checkout@v3 + + - name: Download sapmachine JDK 11 + run: | + download_url="https://github.com/SAP/SapMachine/releases/download/sapmachine-11.0.14.1/sapmachine-jdk-11.0.14.1_linux-x64_bin.tar.gz" + wget -O "${RUNNER_TEMP}/sapmachine-jdk-11.tar.gz" "${download_url}" + + - name: Setup sapmachine JDK 11 + uses: actions/setup-java@v2 + with: + distribution: 'jdkfile' + jdkFile: ${{ runner.temp }}/sapmachine-jdk-11.tar.gz + java-version: '11.0.14' + architecture: x64 + cache: 'gradle' + + - uses: maxim-lobanov/setup-android-tools@v1 + with: + cache: true + + - name: Corona-Warn-App:lintDeviceForTestersRelease + run: ./gradlew -PdisablePreDex :Corona-Warn-App:lintDeviceForTestersRelease -i + + - name: Archive detekt report + uses: actions/upload-artifact@v3.0.0 + with: + name: reports + path: Corona-Warn-App/build/reports quick_build_device_release_no_tests: runs-on: ubuntu-latest needs: dependencies steps: - - uses: actions/checkout@v3 - - - name: Download sapmachine JDK 11 - run: | - download_url="https://github.com/SAP/SapMachine/releases/download/sapmachine-11.0.14.1/sapmachine-jdk-11.0.14.1_linux-x64_bin.tar.gz" - wget -O "${RUNNER_TEMP}/sapmachine-jdk-11.tar.gz" "${download_url}" - - - name: Setup sapmachine JDK 11 - uses: actions/setup-java@v2 - with: - distribution: 'jdkfile' - jdkFile: ${{ runner.temp }}/sapmachine-jdk-11.tar.gz - java-version: '11.0.14' - architecture: x64 - cache: 'gradle' - - - uses: maxim-lobanov/setup-android-tools@v1 - with: - cache: true - - - name: Quick Build - run: ./gradlew -PdisablePreDex assembleDeviceRelease - + - uses: actions/checkout@v3 + + - name: Download sapmachine JDK 11 + run: | + download_url="https://github.com/SAP/SapMachine/releases/download/sapmachine-11.0.14.1/sapmachine-jdk-11.0.14.1_linux-x64_bin.tar.gz" + wget -O "${RUNNER_TEMP}/sapmachine-jdk-11.tar.gz" "${download_url}" + + - name: Setup sapmachine JDK 11 + uses: actions/setup-java@v2 + with: + distribution: 'jdkfile' + jdkFile: ${{ runner.temp }}/sapmachine-jdk-11.tar.gz + java-version: '11.0.14' + architecture: x64 + cache: 'gradle' + + - uses: maxim-lobanov/setup-android-tools@v1 + with: + cache: true + + - name: Quick Build + run: ./gradlew -PdisablePreDex assembleDeviceRelease + quick_build_device_for_testers_release_no_tests: runs-on: ubuntu-latest needs: dependencies steps: - - uses: actions/checkout@v3 - - - name: Download sapmachine JDK 11 - run: | - download_url="https://github.com/SAP/SapMachine/releases/download/sapmachine-11.0.14.1/sapmachine-jdk-11.0.14.1_linux-x64_bin.tar.gz" - wget -O "${RUNNER_TEMP}/sapmachine-jdk-11.tar.gz" "${download_url}" - - - name: Setup sapmachine JDK 11 - uses: actions/setup-java@v2 - with: - distribution: 'jdkfile' - jdkFile: ${{ runner.temp }}/sapmachine-jdk-11.tar.gz - java-version: '11.0.14' - architecture: x64 - cache: 'gradle' - - - uses: maxim-lobanov/setup-android-tools@v1 - with: - cache: true - - - name: Quick Build - run: ./gradlew -PdisablePreDex :Corona-Warn-App:assembleDeviceForTestersRelease - - + - uses: actions/checkout@v3 + + - name: Download sapmachine JDK 11 + run: | + download_url="https://github.com/SAP/SapMachine/releases/download/sapmachine-11.0.14.1/sapmachine-jdk-11.0.14.1_linux-x64_bin.tar.gz" + wget -O "${RUNNER_TEMP}/sapmachine-jdk-11.tar.gz" "${download_url}" + + - name: Setup sapmachine JDK 11 + uses: actions/setup-java@v2 + with: + distribution: 'jdkfile' + jdkFile: ${{ runner.temp }}/sapmachine-jdk-11.tar.gz + java-version: '11.0.14' + architecture: x64 + cache: 'gradle' + + - uses: maxim-lobanov/setup-android-tools@v1 + with: + cache: true + + - name: Quick Build + run: ./gradlew -PdisablePreDex :Corona-Warn-App:assembleDeviceForTestersRelease + + unit-test-runner-indexes: runs-on: ubuntu-latest name: Generate unit test runner indexes @@ -253,7 +253,7 @@ jobs: INDEX_LIST=$(seq 0 ${MAX_INDEX}) INDEX_JSON=$(jq --null-input --compact-output '. |= [inputs]' <<< ${INDEX_LIST}) echo "::set-output name=json::${INDEX_JSON}" - + unit_tests_device_release: name: "Runner #${{ matrix.runner-index }}: Run test suite in parallel" runs-on: ubuntu-latest @@ -264,50 +264,50 @@ jobs: matrix: runner-index: ${{ fromJSON(needs.unit-test-runner-indexes.outputs.json) }} steps: - - uses: actions/checkout@v3 - - - name: Download sapmachine JDK 11 - run: | - download_url="https://github.com/SAP/SapMachine/releases/download/sapmachine-11.0.14.1/sapmachine-jdk-11.0.14.1_linux-x64_bin.tar.gz" - wget -O "${RUNNER_TEMP}/sapmachine-jdk-11.tar.gz" "${download_url}" - - - name: Setup sapmachine JDK 11 - uses: actions/setup-java@v2 - with: - distribution: 'jdkfile' - jdkFile: ${{ runner.temp }}/sapmachine-jdk-11.tar.gz - java-version: '11.0.14' - architecture: x64 - cache: 'gradle' - - - uses: maxim-lobanov/setup-android-tools@v1 - with: - cache: true - - - uses: chaosaffe/split-tests@v1-alpha.1 - id: split-tests - name: Split tests - with: - glob: Corona-Warn-App/**/test*/**/*.kt - split-total: ${{ env.total-test-runners }} - split-index: ${{ matrix.runner-index }} - - - run: 'echo "This runner will execute the following tests: ${{ steps.split-tests.outputs.test-suite }}"' - - - name: Test - run: ./gradlew -PdisablePreDex :Corona-Warn-App:testDeviceReleaseUnitTest -i -PtestFilter="${{ steps.split-tests.outputs.test-suite }}" - - - name: Archive Test Result - uses: actions/upload-artifact@v3 - with: - name: testResults - path: Corona-Warn-App/build/test-results - - - name: Archive Test Result - uses: actions/upload-artifact@v3 - with: - name: reports - path: Corona-Warn-App/build/reports + - uses: actions/checkout@v3 + + - name: Download sapmachine JDK 11 + run: | + download_url="https://github.com/SAP/SapMachine/releases/download/sapmachine-11.0.14.1/sapmachine-jdk-11.0.14.1_linux-x64_bin.tar.gz" + wget -O "${RUNNER_TEMP}/sapmachine-jdk-11.tar.gz" "${download_url}" + + - name: Setup sapmachine JDK 11 + uses: actions/setup-java@v2 + with: + distribution: 'jdkfile' + jdkFile: ${{ runner.temp }}/sapmachine-jdk-11.tar.gz + java-version: '11.0.14' + architecture: x64 + cache: 'gradle' + + - uses: maxim-lobanov/setup-android-tools@v1 + with: + cache: true + + - uses: chaosaffe/split-tests@v1-alpha.1 + id: split-tests + name: Split tests + with: + glob: Corona-Warn-App/**/test*/**/*.kt + split-total: ${{ env.total-test-runners }} + split-index: ${{ matrix.runner-index }} + + - run: 'echo "This runner will execute the following tests: ${{ steps.split-tests.outputs.test-suite }}"' + + - name: Test + run: ./gradlew -PdisablePreDex :Corona-Warn-App:testDeviceReleaseUnitTest -i -PtestFilter="${{ steps.split-tests.outputs.test-suite }}" + + - name: Archive Test Result + uses: actions/upload-artifact@v3 + with: + name: testResults + path: Corona-Warn-App/build/test-results + + - name: Archive Test Result + uses: actions/upload-artifact@v3 + with: + name: reports + path: Corona-Warn-App/build/reports unit_tests_device_for_testers_release: name: "Runner #${{ matrix.runner-index }}: Run test for testers suite in parallel" @@ -319,54 +319,54 @@ jobs: matrix: runner-index: ${{ fromJSON(needs.unit-test-runner-indexes.outputs.json) }} steps: - - uses: actions/checkout@v3 - - - name: Download sapmachine JDK 11 - run: | - download_url="https://github.com/SAP/SapMachine/releases/download/sapmachine-11.0.14.1/sapmachine-jdk-11.0.14.1_linux-x64_bin.tar.gz" - wget -O "${RUNNER_TEMP}/sapmachine-jdk-11.tar.gz" "${download_url}" - - - name: Setup sapmachine JDK 11 - uses: actions/setup-java@v2 - with: - distribution: 'jdkfile' - jdkFile: ${{ runner.temp }}/sapmachine-jdk-11.tar.gz - java-version: '11.0.14' - architecture: x64 - cache: 'gradle' - - - uses: maxim-lobanov/setup-android-tools@v1 - with: - cache: true - - - uses: chaosaffe/split-tests@v1-alpha.1 - id: split-tests - name: Split tests - with: - glob: Corona-Warn-App/**/test*/**/*.kt - split-total: ${{ env.total-test-runners }} - split-index: ${{ matrix.runner-index }} - - - run: 'echo "This runner will execute the following tests: ${{ steps.split-tests.outputs.test-suite }}"' - - - name: Test - run: ./gradlew -PdisablePreDex :Corona-Warn-App:testDeviceForTestersReleaseUnitTest -i -PtestFilter="${{ steps.split-tests.outputs.test-suite }}" - - - name: Archive Test Result - uses: actions/upload-artifact@v3 - with: - name: testResults - path: Corona-Warn-App/build/test-results - - - name: Archive Test Result - uses: actions/upload-artifact@v3 - with: - name: reports - path: Corona-Warn-App/build/reports + - uses: actions/checkout@v3 + + - name: Download sapmachine JDK 11 + run: | + download_url="https://github.com/SAP/SapMachine/releases/download/sapmachine-11.0.14.1/sapmachine-jdk-11.0.14.1_linux-x64_bin.tar.gz" + wget -O "${RUNNER_TEMP}/sapmachine-jdk-11.tar.gz" "${download_url}" + + - name: Setup sapmachine JDK 11 + uses: actions/setup-java@v2 + with: + distribution: 'jdkfile' + jdkFile: ${{ runner.temp }}/sapmachine-jdk-11.tar.gz + java-version: '11.0.14' + architecture: x64 + cache: 'gradle' + + - uses: maxim-lobanov/setup-android-tools@v1 + with: + cache: true + + - uses: chaosaffe/split-tests@v1-alpha.1 + id: split-tests + name: Split tests + with: + glob: Corona-Warn-App/**/test*/**/*.kt + split-total: ${{ env.total-test-runners }} + split-index: ${{ matrix.runner-index }} + + - run: 'echo "This runner will execute the following tests: ${{ steps.split-tests.outputs.test-suite }}"' + + - name: Test + run: ./gradlew -PdisablePreDex :Corona-Warn-App:testDeviceForTestersReleaseUnitTest -i -PtestFilter="${{ steps.split-tests.outputs.test-suite }}" + + - name: Archive Test Result + uses: actions/upload-artifact@v3 + with: + name: testResults + path: Corona-Warn-App/build/test-results + + - name: Archive Test Result + uses: actions/upload-artifact@v3 + with: + name: reports + path: Corona-Warn-App/build/reports publish_test_results: runs-on: ubuntu-latest - needs: + needs: - unit_tests_device_release permissions: checks: write @@ -380,17 +380,17 @@ jobs: - name: Display structure of downloaded files run: ls -R - + - name: Publish Test Results - Device Release uses: EnricoMi/publish-unit-test-result-action@v1 if: always() with: check_name: "Unit Test Results - Device Release" - files: "artifacts/testDeviceReleaseUnitTest/*.xml" + files: "artifacts/testDeviceReleaseUnitTest/*.xml" publish_test_for_testers_results: runs-on: ubuntu-latest - needs: + needs: - unit_tests_device_for_testers_release permissions: checks: write @@ -404,33 +404,35 @@ jobs: - name: Display structure of downloaded files run: ls -R - + - name: Publish Test Results - Device For Tester Release uses: EnricoMi/publish-unit-test-result-action@v1 if: always() with: check_name: "Unit Test Results - Device For Tester Release" - files: "artifacts/testDeviceForTestersReleaseUnitTest/*.xml" - + files: "artifacts/testDeviceForTestersReleaseUnitTest/*.xml" + run_sonar_scan: runs-on: ubuntu-latest needs: unit_tests_device_release if: ${{ !github.event.pull_request.head.repo.fork }} + env: + sonar_token: '${{ secrets.SONAR_TOKEN }}' steps: - uses: actions/checkout@v3 - + - name: Download sapmachine JDK 11 run: | download_url="https://github.com/SAP/SapMachine/releases/download/sapmachine-11.0.14.1/sapmachine-jdk-11.0.14.1_linux-x64_bin.tar.gz" wget -O "${RUNNER_TEMP}/sapmachine-jdk-11.tar.gz" "${download_url}" - + - name: Setup sapmachine JDK 11 uses: actions/setup-java@v2 with: distribution: 'jdkfile' jdkFile: ${{ runner.temp }}/sapmachine-jdk-11.tar.gz java-version: '11.0.14' - architecture: x64 + architecture: x64 cache: 'gradle' - uses: maxim-lobanov/setup-android-tools@v1 @@ -444,28 +446,28 @@ jobs: uses: actions/upload-artifact@v3 with: name: reports - path: Corona-Warn-App/build/reports - + path: Corona-Warn-App/build/reports + - name: Sonar Cloud Scan uses: SonarSource/sonarcloud-github-action@master env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - + instrumentation_tests_device: runs-on: ubuntu-latest - needs: + needs: - detekt - klint if: ${{ !github.event.pull_request.head.repo.fork }} env: GCLOUD_SERVICE_KEY_BASE64: '${{ secrets.GCLOUD_SERVICE_KEY_BASE64 }}' - GOOGLE_PROJECT_ID: '${{ secrets.GOOGLE_PROJECT_ID }}' + GOOGLE_PROJECT_ID: '${{ secrets.GOOGLE_PROJECT_ID }}' permissions: checks: write pull-requests: write steps: - + - uses: actions/checkout@v3 - name: Download sapmachine JDK 11 @@ -479,25 +481,25 @@ jobs: distribution: 'jdkfile' jdkFile: ${{ runner.temp }}/sapmachine-jdk-11.tar.gz java-version: '11.0.14' - architecture: x64 + architecture: x64 cache: 'gradle' - uses: maxim-lobanov/setup-android-tools@v1 with: - cache: true - + cache: true + - name: Build App APK run: ./gradlew -PdisablePreDex :Corona-Warn-App:assembleDeviceForTestersDebug - + - name: Build Test App APK - run: ./gradlew -PdisablePreDex :Corona-Warn-App:assembleDeviceForTestersDebugAndroidTest - - - name: Setup Google Cloud access + run: ./gradlew -PdisablePreDex :Corona-Warn-App:assembleDeviceForTestersDebugAndroidTest + + - name: Setup Google Cloud access run: | echo $GCLOUD_SERVICE_KEY_BASE64 | base64 -di > ${HOME}/gcloud-service-key.json sudo gcloud auth activate-service-account --key-file=${HOME}/gcloud-service-key.json sudo gcloud --quiet config set project ${GOOGLE_PROJECT_ID} - + - name: Setup Testlab environment run: | echo "BUCKETDIR=`date "+%Y-%m-%d-%H:%M:%S:%3N"`-${RANDOM}" >> $GITHUB_ENV @@ -520,11 +522,11 @@ jobs: --orientations portrait \ --num-flaky-test-attempts 3 \ --no-record-video - + - name: Create directory to store test results if: always() - run: mkdir firebase-results - + run: mkdir firebase-results + - name: Install gsutil dependency and copy test results data if: always() run: | diff --git a/Corona-Warn-App/build.gradle b/Corona-Warn-App/build.gradle index e7b520fc0a4..a5d9e8e7277 100644 --- a/Corona-Warn-App/build.gradle +++ b/Corona-Warn-App/build.gradle @@ -4,6 +4,7 @@ apply plugin: 'kotlin-kapt' apply plugin: 'kotlin-parcelize' apply plugin: 'androidx.navigation.safeargs.kotlin' apply plugin: 'jacoco' +apply plugin: "org.sonarqube" def environmentExtractor = { File path -> @@ -518,3 +519,11 @@ dependencies { implementation "androidx.camera:camera-view:$camerax_version" implementation "androidx.window:window:1.0.0" } + +sonarqube { + properties { + property "sonar.projectKey", System.getenv("sonar_token") + property "sonar.organization", "corona-warn-app" + property "sonar.host.url", "https://sonarcloud.io" + } +} diff --git a/build.gradle b/build.gradle index ae19a81d0a0..66ef1ddac4e 100644 --- a/build.gradle +++ b/build.gradle @@ -19,6 +19,7 @@ buildscript { classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$nav_version" classpath "org.jlleitschuh.gradle:ktlint-gradle:10.0.0" classpath "io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.18.1" + classpath "org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:3.3" // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files From 79bc4330afd8f43ce9db6aa6f2e1f4f5d0bd5dbb Mon Sep 17 00:00:00 2001 From: Mohamed Metwalli Date: Mon, 23 May 2022 14:10:29 +0200 Subject: [PATCH 29/44] Update build_and_test.yml --- .github/workflows/build_and_test.yml | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index b8ea5e74147..98b10389ec8 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -448,11 +448,23 @@ jobs: name: reports path: Corona-Warn-App/build/reports - - name: Sonar Cloud Scan - uses: SonarSource/sonarcloud-github-action@master + - name: Cache SonarCloud packages + uses: actions/cache@v1 + with: + path: ~/.sonar/cache + key: ${{ runner.os }}-sonar + restore-keys: ${{ runner.os }}-sonar + - name: Cache Gradle packages + uses: actions/cache@v1 + with: + path: ~/.gradle/caches + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} + restore-keys: ${{ runner.os }}-gradle + - name: Build and analyze env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + run: ./gradlew build sonarqube --info instrumentation_tests_device: runs-on: ubuntu-latest From e95e353af4126fd6a316094e365e2e57315592a9 Mon Sep 17 00:00:00 2001 From: Mohamed Metwalli Date: Mon, 23 May 2022 14:38:11 +0200 Subject: [PATCH 30/44] Revert "Update build_and_test.yml" This reverts commit 79bc4330afd8f43ce9db6aa6f2e1f4f5d0bd5dbb. --- .github/workflows/build_and_test.yml | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index 98b10389ec8..b8ea5e74147 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -448,23 +448,11 @@ jobs: name: reports path: Corona-Warn-App/build/reports - - name: Cache SonarCloud packages - uses: actions/cache@v1 - with: - path: ~/.sonar/cache - key: ${{ runner.os }}-sonar - restore-keys: ${{ runner.os }}-sonar - - name: Cache Gradle packages - uses: actions/cache@v1 - with: - path: ~/.gradle/caches - key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} - restore-keys: ${{ runner.os }}-gradle - - name: Build and analyze + - name: Sonar Cloud Scan + uses: SonarSource/sonarcloud-github-action@master env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - run: ./gradlew build sonarqube --info instrumentation_tests_device: runs-on: ubuntu-latest From 2a2a6577e3817abe89971b0f3ca162395737e5df Mon Sep 17 00:00:00 2001 From: Mohamed Metwalli Date: Mon, 23 May 2022 14:41:35 +0200 Subject: [PATCH 31/44] Run sonar --- .github/workflows/build_and_test.yml | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index b8ea5e74147..c62d0c938e3 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -448,11 +448,19 @@ jobs: name: reports path: Corona-Warn-App/build/reports - - name: Sonar Cloud Scan - uses: SonarSource/sonarcloud-github-action@master + - name: Cache SonarCloud packages + uses: actions/cache@v1 + with: + path: ~/.sonar/cache + key: ${{ runner.os }}-sonar + restore-keys: ${{ runner.os }}-sonar + + - name: Build and analyze env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + run: ./gradlew build sonarqube --info + instrumentation_tests_device: runs-on: ubuntu-latest From 7d611856e4b7f0f4f9a8f29e95aef814e2a1c754 Mon Sep 17 00:00:00 2001 From: Mohamed Metwalli Date: Mon, 23 May 2022 14:49:58 +0200 Subject: [PATCH 32/44] `Push` only --- .github/workflows/build_and_test.yml | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index c62d0c938e3..eb362b9e958 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -1,12 +1,6 @@ name: Build, Scan and Test -on: - pull_request: - # Sequence of patterns matched against refs/heads - branches: - - main - - 'release/**' - push: +on: [ push ] concurrency: group: ${{ github.head_ref || github.ref }} #Cancel old runs if they have not finished yet From 5b8e8805fc0bced313e73574e4d617373b25b77b Mon Sep 17 00:00:00 2001 From: Mohamed Metwalli Date: Mon, 23 May 2022 15:53:28 +0200 Subject: [PATCH 33/44] Remove `build` task --- .github/workflows/build_and_test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index eb362b9e958..2a4c94c0ae6 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -453,7 +453,7 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - run: ./gradlew build sonarqube --info + run: ./gradlew sonarqube instrumentation_tests_device: From 6dabae4aa28b6ab7a769194997b014b2de040ad2 Mon Sep 17 00:00:00 2001 From: Mohamed Metwalli Date: Mon, 23 May 2022 17:19:39 +0200 Subject: [PATCH 34/44] Sonar properties --- Corona-Warn-App/build.gradle | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Corona-Warn-App/build.gradle b/Corona-Warn-App/build.gradle index a5d9e8e7277..c9e40610990 100644 --- a/Corona-Warn-App/build.gradle +++ b/Corona-Warn-App/build.gradle @@ -522,8 +522,16 @@ dependencies { sonarqube { properties { - property "sonar.projectKey", System.getenv("sonar_token") property "sonar.organization", "corona-warn-app" property "sonar.host.url", "https://sonarcloud.io" + property "sonar.projectKey", "corona-warn-app_cwa-app-android" + property "sonar.organization", "corona-warn-app" + property "sonar.coverage.jacoco.xmlReportPaths", "build/reports/jacoco/deviceRelease/jacoco.xml" + property "sonar.sources", "src/main/java/" + property "sonar.inclusions", "**/*.kt" + property "sonar.java.binaries", "build/tmp/kotlin-classes" + property "sonar.java.libraries", "libs" + property "sonar.kotlin.file.suffixes", ".kt" + property "sonar.kotlin.detekt.reportPaths", "build/reports/detekt/detekt.xml" } } From a8875462b2c8978724f7f05ff5e73e76d971f67d Mon Sep 17 00:00:00 2001 From: Mohamed Metwalli Date: Mon, 23 May 2022 17:20:06 +0200 Subject: [PATCH 35/44] Remove env key --- .github/workflows/build_and_test.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index 2a4c94c0ae6..1aa38f16b89 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -410,8 +410,6 @@ jobs: runs-on: ubuntu-latest needs: unit_tests_device_release if: ${{ !github.event.pull_request.head.repo.fork }} - env: - sonar_token: '${{ secrets.SONAR_TOKEN }}' steps: - uses: actions/checkout@v3 From 4465c5d584a18e4465bd65602179dc45afb151a8 Mon Sep 17 00:00:00 2001 From: Mohamed Metwalli Date: Mon, 23 May 2022 17:25:24 +0200 Subject: [PATCH 36/44] Refer to env var --- Corona-Warn-App/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Corona-Warn-App/build.gradle b/Corona-Warn-App/build.gradle index c9e40610990..5447273cc1e 100644 --- a/Corona-Warn-App/build.gradle +++ b/Corona-Warn-App/build.gradle @@ -524,7 +524,7 @@ sonarqube { properties { property "sonar.organization", "corona-warn-app" property "sonar.host.url", "https://sonarcloud.io" - property "sonar.projectKey", "corona-warn-app_cwa-app-android" + property "sonar.projectKey", System.getenv("SONAR_TOKEN") property "sonar.organization", "corona-warn-app" property "sonar.coverage.jacoco.xmlReportPaths", "build/reports/jacoco/deviceRelease/jacoco.xml" property "sonar.sources", "src/main/java/" From 2ba7afe8207fee42b3d3e69abd5bf2c1b98576d9 Mon Sep 17 00:00:00 2001 From: Mohamed Metwalli Date: Mon, 23 May 2022 17:35:48 +0200 Subject: [PATCH 37/44] gradle ci properties --- .github/workflows/build_and_test.yml | 31 ++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index 1aa38f16b89..4ab9d955dfd 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -22,6 +22,8 @@ jobs: steps: - uses: actions/checkout@v3 + - name: Copy CI gradle.properties + run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties - name: Download sapmachine JDK 11 run: | @@ -47,7 +49,8 @@ jobs: steps: - uses: actions/checkout@v3 - + - name: Copy CI gradle.properties + run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties - name: Download sapmachine JDK 11 run: | download_url="https://github.com/SAP/SapMachine/releases/download/sapmachine-11.0.14.1/sapmachine-jdk-11.0.14.1_linux-x64_bin.tar.gz" @@ -82,7 +85,8 @@ jobs: steps: - uses: actions/checkout@v3 - + - name: Copy CI gradle.properties + run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties - name: Download sapmachine JDK 11 run: | download_url="https://github.com/SAP/SapMachine/releases/download/sapmachine-11.0.14.1/sapmachine-jdk-11.0.14.1_linux-x64_bin.tar.gz" @@ -116,7 +120,8 @@ jobs: steps: - uses: actions/checkout@v3 - + - name: Copy CI gradle.properties + run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties - name: Download sapmachine JDK 11 run: | download_url="https://github.com/SAP/SapMachine/releases/download/sapmachine-11.0.14.1/sapmachine-jdk-11.0.14.1_linux-x64_bin.tar.gz" @@ -150,7 +155,8 @@ jobs: steps: - uses: actions/checkout@v3 - + - name: Copy CI gradle.properties + run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties - name: Download sapmachine JDK 11 run: | download_url="https://github.com/SAP/SapMachine/releases/download/sapmachine-11.0.14.1/sapmachine-jdk-11.0.14.1_linux-x64_bin.tar.gz" @@ -184,7 +190,8 @@ jobs: steps: - uses: actions/checkout@v3 - + - name: Copy CI gradle.properties + run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties - name: Download sapmachine JDK 11 run: | download_url="https://github.com/SAP/SapMachine/releases/download/sapmachine-11.0.14.1/sapmachine-jdk-11.0.14.1_linux-x64_bin.tar.gz" @@ -212,7 +219,8 @@ jobs: steps: - uses: actions/checkout@v3 - + - name: Copy CI gradle.properties + run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties - name: Download sapmachine JDK 11 run: | download_url="https://github.com/SAP/SapMachine/releases/download/sapmachine-11.0.14.1/sapmachine-jdk-11.0.14.1_linux-x64_bin.tar.gz" @@ -259,7 +267,8 @@ jobs: runner-index: ${{ fromJSON(needs.unit-test-runner-indexes.outputs.json) }} steps: - uses: actions/checkout@v3 - + - name: Copy CI gradle.properties + run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties - name: Download sapmachine JDK 11 run: | download_url="https://github.com/SAP/SapMachine/releases/download/sapmachine-11.0.14.1/sapmachine-jdk-11.0.14.1_linux-x64_bin.tar.gz" @@ -314,7 +323,8 @@ jobs: runner-index: ${{ fromJSON(needs.unit-test-runner-indexes.outputs.json) }} steps: - uses: actions/checkout@v3 - + - name: Copy CI gradle.properties + run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties - name: Download sapmachine JDK 11 run: | download_url="https://github.com/SAP/SapMachine/releases/download/sapmachine-11.0.14.1/sapmachine-jdk-11.0.14.1_linux-x64_bin.tar.gz" @@ -426,6 +436,8 @@ jobs: java-version: '11.0.14' architecture: x64 cache: 'gradle' + - name: Copy CI gradle.properties + run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties - uses: maxim-lobanov/setup-android-tools@v1 with: @@ -469,7 +481,8 @@ jobs: steps: - uses: actions/checkout@v3 - + - name: Copy CI gradle.properties + run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties - name: Download sapmachine JDK 11 run: | download_url="https://github.com/SAP/SapMachine/releases/download/sapmachine-11.0.14.1/sapmachine-jdk-11.0.14.1_linux-x64_bin.tar.gz" From 705819c08fc840814bebff48723827159f698feb Mon Sep 17 00:00:00 2001 From: Mohamed Metwalli Date: Mon, 23 May 2022 20:09:33 +0200 Subject: [PATCH 38/44] `--info` --- .github/workflows/build_and_test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index 4ab9d955dfd..752c0116f82 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -463,7 +463,7 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - run: ./gradlew sonarqube + run: ./gradlew sonarqube --info instrumentation_tests_device: From 310558736df3c78657f42854ed4c497c10ac23e3 Mon Sep 17 00:00:00 2001 From: Mohamed Metwalli Date: Mon, 23 May 2022 20:09:42 +0200 Subject: [PATCH 39/44] remove duplicate --- Corona-Warn-App/build.gradle | 1 - 1 file changed, 1 deletion(-) diff --git a/Corona-Warn-App/build.gradle b/Corona-Warn-App/build.gradle index 5447273cc1e..988a82ddfc1 100644 --- a/Corona-Warn-App/build.gradle +++ b/Corona-Warn-App/build.gradle @@ -525,7 +525,6 @@ sonarqube { property "sonar.organization", "corona-warn-app" property "sonar.host.url", "https://sonarcloud.io" property "sonar.projectKey", System.getenv("SONAR_TOKEN") - property "sonar.organization", "corona-warn-app" property "sonar.coverage.jacoco.xmlReportPaths", "build/reports/jacoco/deviceRelease/jacoco.xml" property "sonar.sources", "src/main/java/" property "sonar.inclusions", "**/*.kt" From 6045a40fe8cf930c5a941e14b618a5d67cae3660 Mon Sep 17 00:00:00 2001 From: Mohamed Metwalli Date: Mon, 23 May 2022 21:43:12 +0200 Subject: [PATCH 40/44] key --- Corona-Warn-App/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Corona-Warn-App/build.gradle b/Corona-Warn-App/build.gradle index 988a82ddfc1..a52ad8d9424 100644 --- a/Corona-Warn-App/build.gradle +++ b/Corona-Warn-App/build.gradle @@ -524,7 +524,7 @@ sonarqube { properties { property "sonar.organization", "corona-warn-app" property "sonar.host.url", "https://sonarcloud.io" - property "sonar.projectKey", System.getenv("SONAR_TOKEN") + property "sonar.projectKey", "corona-warn-app_cwa-app-android" property "sonar.coverage.jacoco.xmlReportPaths", "build/reports/jacoco/deviceRelease/jacoco.xml" property "sonar.sources", "src/main/java/" property "sonar.inclusions", "**/*.kt" From 0b10b695b5057eb28b766df1123cad1955dc5098 Mon Sep 17 00:00:00 2001 From: Mohamed Metwalli Date: Tue, 24 May 2022 16:54:13 +0200 Subject: [PATCH 41/44] Tech dept P2 (EXPOSUREAPP-13177) (#5225) * Remove TODO (Tested) * Remove * Use region * Remove forever TODOs * use region instead * Never used => remove * Revert * Lint --- .../upload/server/auth/LogUploadAuthorizer.kt | 1 - .../coronatest/migration/PCRTestMigration.kt | 1 - .../BackgroundNoiseOneTimeWorker.kt | 1 - .../diagnosiskeys/server/DiagnosisKeyApiV1.kt | 3 --- .../download/TraceWarningPackageSyncTool.kt | 2 -- .../storage/InsufficientStorageException.kt | 1 - .../storage/TracingRepository.kt | 1 - .../coronawarnapp/storage/TracingSettings.kt | 4 +-- .../submission/SubmissionRepository.kt | 1 - .../submission/SubmissionSettings.kt | 25 +++---------------- .../submission/task/SubmissionTask.kt | 2 +- .../items/riskdetails/DetailsLowRiskBox.kt | 1 - .../organizer/poster/QrCodePosterFragment.kt | 1 - .../rki/coronawarnapp/util/WatchdogService.kt | 1 - .../EncryptedPreferencesMigration.kt | 4 +-- 15 files changed, 8 insertions(+), 41 deletions(-) diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/bugreporting/debuglog/upload/server/auth/LogUploadAuthorizer.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/bugreporting/debuglog/upload/server/auth/LogUploadAuthorizer.kt index 2c44047ae78..3b5281dbe80 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/bugreporting/debuglog/upload/server/auth/LogUploadAuthorizer.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/bugreporting/debuglog/upload/server/auth/LogUploadAuthorizer.kt @@ -47,7 +47,6 @@ class LogUploadAuthorizer @Inject constructor( payload = elsOtp }.build() - // TODO This was written without backend available, retest. val authResponse = authApi.authOTP(elsRequest).also { Timber.tag(TAG).v("Auth response received: %s", it) } diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/coronatest/migration/PCRTestMigration.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/coronatest/migration/PCRTestMigration.kt index 2992da2f747..8a854268fc3 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/coronatest/migration/PCRTestMigration.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/coronatest/migration/PCRTestMigration.kt @@ -57,7 +57,6 @@ class PCRTestMigration @Inject constructor( val hasGivenConsent = submissionSettings.hasGivenConsentMigration Timber.tag(TAG).v("hasGivenConsent=%s", hasGivenConsent) - // TODO per test ? val testResultNotificationSent = tracingSettings.isTestResultAvailableNotificationSentMigration Timber.tag(TAG).v("testResultNotificationSent=%s", testResultNotificationSent) diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/deniability/BackgroundNoiseOneTimeWorker.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/deniability/BackgroundNoiseOneTimeWorker.kt index 91186227358..b47af8f7c87 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/deniability/BackgroundNoiseOneTimeWorker.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/deniability/BackgroundNoiseOneTimeWorker.kt @@ -27,7 +27,6 @@ class BackgroundNoiseOneTimeWorker @AssistedInject constructor( try { playbook.dummy() } catch (e: Exception) { - // TODO: Should we even retry here? result = if (runAttemptCount > BackgroundConstants.WORKER_RETRY_COUNT_THRESHOLD) { Result.failure() } else { diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/diagnosiskeys/server/DiagnosisKeyApiV1.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/diagnosiskeys/server/DiagnosisKeyApiV1.kt index 575e48703ae..78b90932735 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/diagnosiskeys/server/DiagnosisKeyApiV1.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/diagnosiskeys/server/DiagnosisKeyApiV1.kt @@ -7,17 +7,14 @@ import retrofit2.http.Path import retrofit2.http.Streaming interface DiagnosisKeyApiV1 { - // TODO Let retrofit format this to CountryCode @GET("/version/v1/diagnosis-keys/country") suspend fun getLocationIndex(): List - // TODO Let retrofit format this to LocalDate @GET("/version/v1/diagnosis-keys/country/{country}/date") suspend fun getDayIndex( @Path("country") country: String ): List - // TODO Let retrofit format this to LocalTime @GET("/version/v1/diagnosis-keys/country/{country}/date/{day}/hour") suspend fun getHourIndex( @Path("country") country: String, diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/presencetracing/warning/download/TraceWarningPackageSyncTool.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/presencetracing/warning/download/TraceWarningPackageSyncTool.kt index 12f27e7b841..ad574a55ac4 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/presencetracing/warning/download/TraceWarningPackageSyncTool.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/presencetracing/warning/download/TraceWarningPackageSyncTool.kt @@ -186,8 +186,6 @@ class TraceWarningPackageSyncTool @Inject constructor( companion object { private const val TAG = "TraceWarningSyncTool" - - // TODO check size private const val APPROX_FILE_SIZE = 22 * 1024L // ~22KB } } diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/storage/InsufficientStorageException.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/storage/InsufficientStorageException.kt index 295ba520ca4..9900676f82f 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/storage/InsufficientStorageException.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/storage/InsufficientStorageException.kt @@ -16,7 +16,6 @@ class InsufficientStorageException( override fun toHumanReadableError(context: Context): HumanReadableError { val formattedRequired = Formatter.formatShortFileSize(context, result.requiredBytes) val formattedFree = Formatter.formatShortFileSize(context, result.freeBytes) - // TODO Replace with localized message when the exception is logged via new error tracking. return HumanReadableError( description = "Not enough free space: $formattedRequired are required " + "and only $formattedFree are available." diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/storage/TracingRepository.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/storage/TracingRepository.kt index 7b5e736fe91..8c0b2c834df 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/storage/TracingRepository.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/storage/TracingRepository.kt @@ -100,7 +100,6 @@ class TracingRepository @Inject constructor( /** * Launches the RetrieveDiagnosisKeysTransaction and RiskLevelTransaction in the viewModel scope */ - // TODO temp place, this needs to go somewhere better suspend fun refreshRiskLevel() { // check if the network is enabled to make the server fetch val isNetworkEnabled = networkStateProvider.networkState.first().isInternetAvailable diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/storage/TracingSettings.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/storage/TracingSettings.kt index 35c288c0a2a..48fb6e47b65 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/storage/TracingSettings.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/storage/TracingSettings.kt @@ -27,19 +27,19 @@ class TracingSettings @Inject constructor(@AppContext private val context: Conte putBoolean(TRACING_ACTIVATION_TIMESTAMP, value) } - @Deprecated("Use CoronaTestRepository") + //region needed for migration ONLY. Use CoronaTestRepository var initialPollingForTestResultTimeStampMigration: Long get() = prefs.getLong(TRACING_POOLING_TIMESTAMP, 0L) set(value) = prefs.edit(true) { putLong(TRACING_POOLING_TIMESTAMP, value) } - @Deprecated("Use CoronaTestRepository") var isTestResultAvailableNotificationSentMigration: Boolean get() = prefs.getBoolean(TEST_RESULT_NOTIFICATION_SENT, false) set(value) = prefs.edit(true) { putBoolean(TEST_RESULT_NOTIFICATION_SENT, value) } + //endregion needed for migration ONLY. val isUserToBeNotifiedOfLoweredRiskLevel = prefs.createFlowPreference( key = LOWERED_RISK_LEVEL, diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/submission/SubmissionRepository.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/submission/SubmissionRepository.kt index d1d6ed341a2..ed187e67dde 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/submission/SubmissionRepository.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/submission/SubmissionRepository.kt @@ -133,7 +133,6 @@ class SubmissionRepository @Inject constructor( } } -// TODO Temporary, mapping should be replaced with **[CoronaTest]** fun CoronaTestResult?.toDeviceUIState(): DeviceUIState = when (this) { CoronaTestResult.PCR_NEGATIVE -> DeviceUIState.PAIRED_NEGATIVE CoronaTestResult.PCR_POSITIVE -> DeviceUIState.PAIRED_POSITIVE diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/submission/SubmissionSettings.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/submission/SubmissionSettings.kt index d6127f235a0..25f358fcf18 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/submission/SubmissionSettings.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/submission/SubmissionSettings.kt @@ -39,39 +39,35 @@ class SubmissionSettings @Inject constructor( context.getSharedPreferences("submission_localdata", Context.MODE_PRIVATE) } - @Deprecated("Only available for migration, use CoronaTestRepository!") + //region Needed for migration ONLY. Use CoronaTestRepository var registrationTokenMigration: String? get() = prefs.getString(TEST_REGISTRATION_TOKEN, null) set(value) = prefs.edit { putString(TEST_REGISTRATION_TOKEN, value) } - @Deprecated("Only available for migration, use CoronaTestRepository!") var initialTestResultReceivedAtMigration: Instant? get() = prefs.getLong(TEST_RESULT_RECEIVED_AT, 0L).toInstantOrNull() set(value) = prefs.edit { putLong(TEST_RESULT_RECEIVED_AT, value?.millis ?: 0L) } - @Deprecated("Only available for migration, use CoronaTestRepository!") var devicePairingSuccessfulAtMigration: Instant? get() = prefs.getLong(TEST_PARING_SUCCESSFUL_AT, 0L).toInstantOrNull() set(value) = prefs.edit { putLong(TEST_PARING_SUCCESSFUL_AT, value?.millis ?: 0L) } - @Deprecated("Only available for migration, use CoronaTestRepository!") var isSubmissionSuccessfulMigration: Boolean get() = prefs.getBoolean(IS_KEY_SUBMISSION_SUCCESSFUL, false) set(value) = prefs.edit { putBoolean(IS_KEY_SUBMISSION_SUCCESSFUL, value) } - @Deprecated("Only available for migration, use CoronaTestRepository!") var isAllowedToSubmitKeysMigration: Boolean get() = prefs.getBoolean(IS_KEY_SUBMISSION_ALLOWED, false) set(value) = prefs.edit { putBoolean(IS_KEY_SUBMISSION_ALLOWED, value) } - @Deprecated("Only available for migration, use CoronaTestRepository!") val hasGivenConsentMigration: Boolean get() = prefs.getBoolean(SUBMISSION_CONSENT_GIVEN, false) - @Deprecated("Only available for migration, use CoronaTestRepository!") val hasViewedTestResultMigration: Boolean get() = prefs.getBoolean(SUBMISSION_RESULT_VIEWED, false) + //endregion Needed for migration ONLY. + val symptoms: FlowPreference = FlowPreference( prefs, key = SUBMISSION_SYMPTOMS_LATEST, @@ -111,21 +107,6 @@ class SubmissionSettings @Inject constructor( fun deleteLegacyTestData() { Timber.d("deleteLegacyTestData()") -// Sourced from the behavior of SubmissionRepository.removeTestFromDevice() -// fun removeTestFromDevice() { -// submissionSettings.hasViewedTestResult.update { false } -// submissionSettings.hasGivenConsent.update { false } -// revokeConsentToSubmission() -// submissionSettings.registrationToken.update { null } -// submissionSettings.devicePairingSuccessfulAt = null -// tracingSettings.initialPollingForTestResultTimeStamp = 0L -// submissionSettings.initialTestResultReceivedAt = null -// submissionSettings.isAllowedToSubmitKeys = false -// tracingSettings.isTestResultAvailableNotificationSent = false -// submissionSettings.isSubmissionSuccessful = false -// testResultDataCollector.clear() -// } - prefs.edit { remove(SUBMISSION_RESULT_VIEWED) remove(TEST_REGISTRATION_TOKEN) diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/submission/task/SubmissionTask.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/submission/task/SubmissionTask.kt index 11b712f1b44..4064a664d5b 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/submission/task/SubmissionTask.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/submission/task/SubmissionTask.kt @@ -245,7 +245,7 @@ class SubmissionTask @Inject constructor( } data class Config( - override val executionTimeout: Duration = Duration.standardMinutes(8), // TODO unit-test that not > 9 min + override val executionTimeout: Duration = Duration.standardMinutes(8), override val collisionBehavior: TaskFactory.Config.CollisionBehavior = TaskFactory.Config.CollisionBehavior.ENQUEUE diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/tracing/ui/details/items/riskdetails/DetailsLowRiskBox.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/tracing/ui/details/items/riskdetails/DetailsLowRiskBox.kt index d3c84c6c04e..d5bd3063fd7 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/tracing/ui/details/items/riskdetails/DetailsLowRiskBox.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/tracing/ui/details/items/riskdetails/DetailsLowRiskBox.kt @@ -51,7 +51,6 @@ class DetailsLowRiskBox( ) : RiskDetailsStateItem { fun getRiskDetailsRiskLevelBody(c: Context): String { - // TODO consider pt encounters? return c.getString( if (matchedRiskCount > 0) R.string.risk_details_information_body_low_risk_with_encounter else R.string.risk_details_information_body_low_risk diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/ui/presencetracing/organizer/poster/QrCodePosterFragment.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/ui/presencetracing/organizer/poster/QrCodePosterFragment.kt index 276018bcead..aa61dcaea74 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/ui/presencetracing/organizer/poster/QrCodePosterFragment.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/ui/presencetracing/organizer/poster/QrCodePosterFragment.kt @@ -125,7 +125,6 @@ class QrCodePosterFragment : Fragment(R.layout.qr_code_poster_fragment), AutoInj textEndGuideline.setGuidelinePercent(1 - textBox.offsetX) textStartGuideline.setGuidelinePercent(textBox.offsetX) textTopGuideline.setGuidelinePercent(textBox.offsetY) - // TODO setTypeface() } private fun onShareIntent(fileIntent: FileSharing.FileIntentProvider) { diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/util/WatchdogService.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/util/WatchdogService.kt index 62e04518110..e05759a06e3 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/util/WatchdogService.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/util/WatchdogService.kt @@ -43,7 +43,6 @@ class WatchdogService @Inject constructor( return } - // TODO it's unclear whether this really has any effect // If we are being bound by Google Play Services (which is only a few seconds) // and don't have a worker or foreground service, the system may still kill us and the tasks // before they have finished executing. diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/util/encryptionmigration/EncryptedPreferencesMigration.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/util/encryptionmigration/EncryptedPreferencesMigration.kt index ef91ea4cccd..5bdff1206a8 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/util/encryptionmigration/EncryptedPreferencesMigration.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/util/encryptionmigration/EncryptedPreferencesMigration.kt @@ -62,14 +62,14 @@ class EncryptedPreferencesMigration @Inject constructor( } onboardingSettings.isBackgroundCheckDone = isBackgroundCheckDone() } - @Suppress("DEPRECATION") + TracingLocalData(encryptedSharedPreferences).apply { tracingSettings.initialPollingForTestResultTimeStampMigration = initialPollingForTestResultTimeStamp() tracingSettings.isTestResultAvailableNotificationSentMigration = isTestResultAvailableNotificationSent() tracingSettings.isUserToBeNotifiedOfLoweredRiskLevel.update { isUserToBeNotifiedOfLoweredRiskLevel() } tracingSettings.isConsentGiven = initialTracingActivationTimestamp() != 0L } - @Suppress("DEPRECATION") + SubmissionLocalData(encryptedSharedPreferences).apply { submissionSettings.registrationTokenMigration = registrationToken() submissionSettings.initialTestResultReceivedAtMigration = From 69b90b5b1cd2413bf2f41218b9d4f0c951af7b87 Mon Sep 17 00:00:00 2001 From: Mohamed Metwalli Date: Wed, 25 May 2022 12:07:42 +0200 Subject: [PATCH 42/44] Pay technical dept of AppConfig (EXPOSUREAPP-13168) (#5224) * Pay technical dept of AppConfig * Lint --- .../appconfig/ui/AppConfigTestFragment.kt | 2 +- .../ui/TestRiskLevelCalculationFragment.kt | 4 +- ...iskLevelCalculationFragmentCWAViewModel.kt | 6 -- .../fragment_test_risk_level_calculation.xml | 6 -- .../appconfig/internal/AppConfigSource.kt | 64 ++++++++++--------- .../appconfig/mapping/ConfigMapping.kt | 3 - .../appconfig/mapping/ConfigParser.kt | 1 - .../appconfig/mapping/DefaultConfigMapping.kt | 3 - .../appconfig/mapping/ConfigParserTest.kt | 3 +- 9 files changed, 36 insertions(+), 56 deletions(-) diff --git a/Corona-Warn-App/src/deviceForTesters/java/de/rki/coronawarnapp/test/appconfig/ui/AppConfigTestFragment.kt b/Corona-Warn-App/src/deviceForTesters/java/de/rki/coronawarnapp/test/appconfig/ui/AppConfigTestFragment.kt index b6bcb6f1f1b..014a44684d8 100644 --- a/Corona-Warn-App/src/deviceForTesters/java/de/rki/coronawarnapp/test/appconfig/ui/AppConfigTestFragment.kt +++ b/Corona-Warn-App/src/deviceForTesters/java/de/rki/coronawarnapp/test/appconfig/ui/AppConfigTestFragment.kt @@ -33,7 +33,7 @@ class AppConfigTestFragment : Fragment(R.layout.fragment_test_appconfig), AutoIn super.onViewCreated(view, savedInstanceState) vm.currentConfig.observe2(this) { data -> - binding.currentConfiguration.text = data.rawConfig.toString() + binding.currentConfiguration.text = data.toString() binding.lastUpdate.text = timeFormatter.print(data.updatedAt) binding.timeOffset.text = """ diff --git a/Corona-Warn-App/src/deviceForTesters/java/de/rki/coronawarnapp/test/risklevel/ui/TestRiskLevelCalculationFragment.kt b/Corona-Warn-App/src/deviceForTesters/java/de/rki/coronawarnapp/test/risklevel/ui/TestRiskLevelCalculationFragment.kt index 0a30d78f8a5..8b9cdbf2ef3 100644 --- a/Corona-Warn-App/src/deviceForTesters/java/de/rki/coronawarnapp/test/risklevel/ui/TestRiskLevelCalculationFragment.kt +++ b/Corona-Warn-App/src/deviceForTesters/java/de/rki/coronawarnapp/test/risklevel/ui/TestRiskLevelCalculationFragment.kt @@ -58,9 +58,7 @@ class TestRiskLevelCalculationFragment : vm.aggregatedRiskResult.observe2(this) { binding.labelAggregatedRiskResult.text = it } - vm.backendParameters.observe2(this) { - binding.labelBackendParameters.text = it - } + vm.exposureWindowCount.observe2(this) { exposureWindowCount -> binding.labelExposureWindowCount.text = "Retrieved $exposureWindowCount Exposure Windows" binding.buttonExposureWindowsShare.visibility = when (exposureWindowCount > 0) { diff --git a/Corona-Warn-App/src/deviceForTesters/java/de/rki/coronawarnapp/test/risklevel/ui/TestRiskLevelCalculationFragmentCWAViewModel.kt b/Corona-Warn-App/src/deviceForTesters/java/de/rki/coronawarnapp/test/risklevel/ui/TestRiskLevelCalculationFragmentCWAViewModel.kt index ded18c275f6..96e32010dc3 100644 --- a/Corona-Warn-App/src/deviceForTesters/java/de/rki/coronawarnapp/test/risklevel/ui/TestRiskLevelCalculationFragmentCWAViewModel.kt +++ b/Corona-Warn-App/src/deviceForTesters/java/de/rki/coronawarnapp/test/risklevel/ui/TestRiskLevelCalculationFragmentCWAViewModel.kt @@ -103,12 +103,6 @@ class TestRiskLevelCalculationFragmentCWAViewModel @AssistedInject constructor( .appendLine("Number of Days With Low Risk: $numberOfDaysWithLowRisk") .toString() - @Suppress("DEPRECATION") - val backendParameters = appConfigProvider - .currentConfig - .map { it.rawConfig.riskCalculationParameters.toString() } - .asLiveData() - val additionalRiskCalcInfo = combine( riskLevelStorage.latestAndLastSuccessfulCombinedEwPtRiskLevelResult, exposureDetectionTracker.latestSubmission() diff --git a/Corona-Warn-App/src/deviceForTesters/res/layout/fragment_test_risk_level_calculation.xml b/Corona-Warn-App/src/deviceForTesters/res/layout/fragment_test_risk_level_calculation.xml index d91080a772c..96ffa6cf6ab 100644 --- a/Corona-Warn-App/src/deviceForTesters/res/layout/fragment_test_risk_level_calculation.xml +++ b/Corona-Warn-App/src/deviceForTesters/res/layout/fragment_test_risk_level_calculation.xml @@ -138,12 +138,6 @@ android:accessibilityHeading="true" android:text="Backend Parameters" /> - - { Timber.tag(TAG).d("Returning remote config.") - if (!remoteConfig.isDeviceTimeCorrect) { - Timber.tag(TAG).w( - "Device time is incorrect, offset=%dmin", - remoteConfig.localOffset.standardMinutes - ) - } - if (remoteConfig.isDeviceTimeCorrect && cwaSettings.wasDeviceTimeIncorrectAcknowledged) { - Timber.tag(TAG).i("Resetting previous incorrect device time acknowledgement.") - cwaSettings.wasDeviceTimeIncorrectAcknowledged = false - } - if (remoteConfig.deviceTimeState == CORRECT && cwaSettings.firstReliableDeviceTime == Instant.EPOCH) { - Timber.tag(TAG).i("Setting firstReliableDeviceTime to NOW (UTC). ") - cwaSettings.firstReliableDeviceTime = timeStamper.nowUTC - } - if (remoteConfig.deviceTimeState != cwaSettings.lastDeviceTimeStateChangeState) { - Timber.tag(TAG).i( - "New device time state, saving timestamp (old=%s(%s), new=%s#)", - cwaSettings.lastDeviceTimeStateChangeState, - cwaSettings.lastDeviceTimeStateChangeAt, - remoteConfig.deviceTimeState - ) - cwaSettings.lastDeviceTimeStateChangeState = remoteConfig.deviceTimeState - cwaSettings.lastDeviceTimeStateChangeAt = timeStamper.nowUTC - } + onRemoteConfigAvailable(remoteConfig) remoteConfig } localConfig != null -> { @@ -82,6 +54,36 @@ class AppConfigSource @Inject constructor( } } + private fun onRemoteConfigAvailable(remoteConfig: ConfigData) { + if (!remoteConfig.isDeviceTimeCorrect) { + Timber.tag(TAG).w( + "Device time is incorrect, offset=%dmin", + remoteConfig.localOffset.standardMinutes + ) + } + + if (remoteConfig.isDeviceTimeCorrect && cwaSettings.wasDeviceTimeIncorrectAcknowledged) { + Timber.tag(TAG).i("Resetting previous incorrect device time acknowledgement.") + cwaSettings.wasDeviceTimeIncorrectAcknowledged = false + } + + if (remoteConfig.deviceTimeState == CORRECT && cwaSettings.firstReliableDeviceTime == Instant.EPOCH) { + Timber.tag(TAG).i("Setting firstReliableDeviceTime to NOW (UTC). ") + cwaSettings.firstReliableDeviceTime = timeStamper.nowUTC + } + + if (remoteConfig.deviceTimeState != cwaSettings.lastDeviceTimeStateChangeState) { + Timber.tag(TAG).i( + "New device time state, saving timestamp (old=%s(%s), new=%s#)", + cwaSettings.lastDeviceTimeStateChangeState, + cwaSettings.lastDeviceTimeStateChangeAt, + remoteConfig.deviceTimeState + ) + cwaSettings.lastDeviceTimeStateChangeState = remoteConfig.deviceTimeState + cwaSettings.lastDeviceTimeStateChangeAt = timeStamper.nowUTC + } + } + suspend fun clear() { Timber.tag(TAG).d("clear()") localAppConfigSource.clear() diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/appconfig/mapping/ConfigMapping.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/appconfig/mapping/ConfigMapping.kt index aaac8ae61dc..3712a012545 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/appconfig/mapping/ConfigMapping.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/appconfig/mapping/ConfigMapping.kt @@ -10,7 +10,6 @@ import de.rki.coronawarnapp.appconfig.KeyDownloadConfig import de.rki.coronawarnapp.appconfig.LogUploadConfig import de.rki.coronawarnapp.appconfig.PresenceTracingConfig import de.rki.coronawarnapp.appconfig.SurveyConfig -import de.rki.coronawarnapp.server.protocols.internal.v2.AppConfigAndroid interface ConfigMapping : CWAConfig, @@ -18,8 +17,6 @@ interface ConfigMapping : ExposureDetectionConfig, ExposureWindowRiskCalculationConfig { - @Deprecated("Try to access a more specific config type, avoid the RAW variant.") - val rawConfig: AppConfigAndroid.ApplicationConfigurationAndroid val survey: SurveyConfig val analytics: AnalyticsConfig val logUpload: LogUploadConfig diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/appconfig/mapping/ConfigParser.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/appconfig/mapping/ConfigParser.kt index b29c6b17d9e..9c8efcba4a0 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/appconfig/mapping/ConfigParser.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/appconfig/mapping/ConfigParser.kt @@ -33,7 +33,6 @@ class ConfigParser @Inject constructor( fun parse(configBytes: ByteArray): ConfigMapping = try { parseRawArray(configBytes).let { DefaultConfigMapping( - rawConfig = it, cwaConfig = cwaConfigMapper.map(it), keyDownloadConfig = keyDownloadConfigMapper.map(it), exposureDetectionConfig = exposureDetectionConfigMapper.map(it), diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/appconfig/mapping/DefaultConfigMapping.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/appconfig/mapping/DefaultConfigMapping.kt index 819e5632a87..4242182a913 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/appconfig/mapping/DefaultConfigMapping.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/appconfig/mapping/DefaultConfigMapping.kt @@ -10,11 +10,8 @@ import de.rki.coronawarnapp.appconfig.KeyDownloadConfig import de.rki.coronawarnapp.appconfig.LogUploadConfig import de.rki.coronawarnapp.appconfig.PresenceTracingConfig import de.rki.coronawarnapp.appconfig.SurveyConfig -import de.rki.coronawarnapp.server.protocols.internal.v2.AppConfigAndroid -@Suppress("OVERRIDE_DEPRECATION") data class DefaultConfigMapping( - override val rawConfig: AppConfigAndroid.ApplicationConfigurationAndroid, val cwaConfig: CWAConfig, val keyDownloadConfig: KeyDownloadConfig, val exposureDetectionConfig: ExposureDetectionConfig, diff --git a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/appconfig/mapping/ConfigParserTest.kt b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/appconfig/mapping/ConfigParserTest.kt index bbfdba52c11..f8480e27391 100644 --- a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/appconfig/mapping/ConfigParserTest.kt +++ b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/appconfig/mapping/ConfigParserTest.kt @@ -98,8 +98,7 @@ class ConfigParserTest : BaseTest() { @Test fun `parsing the 1_8_0 config does not throw an exception`() { createInstance().parse(appConfig180.readBytes()).apply { - @Suppress("DEPRECATION") - rawConfig shouldNotBe null + this shouldNotBe null } } From 9a50114e3e0170b44aa65b6f294808e81411d37a Mon Sep 17 00:00:00 2001 From: Mohamed Metwalli Date: Fri, 27 May 2022 12:25:28 +0200 Subject: [PATCH 43/44] Tech dept P3 (#5232) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Code smells * Blame server all the time * Lint * Add 7 * Use native `combine` * lint * Pay 💰 flows tech debt 💸 --- .../person/ContactDiaryPersonListViewModel.kt | 2 +- .../overview/ContactDiaryOverviewViewModel.kt | 56 ++-- .../CoronaTestRepositoryExtensions.kt | 51 ++-- .../statecheck/DccValidityMeasuresObserver.kt | 2 +- .../core/RecoveryCertificateRepository.kt | 2 +- .../TestCertificateRetrievalScheduler.kt | 2 +- .../core/business/wrapper/ValueSetWrapper.kt | 2 +- .../core/server/DccValidationServer.kt | 6 +- .../deadman/DeadmanNotificationScheduler.kt | 2 +- .../core/repository/CoronaTestProcessor.kt | 10 +- .../ui/consent/FamilyTestConsentViewModel.kt | 2 +- .../ui/testlist/FamilyTestListViewModel.kt | 2 +- .../playbook/OrganizerPlaybook.kt | 10 +- .../PresenceTracingRiskWorkScheduler.kt | 2 +- .../storage/PresenceTracingRiskRepository.kt | 2 +- .../risk/storage/BaseRiskLevelStorage.kt | 2 +- .../tracing/states/TracingStateProvider.kt | 2 +- .../SettingsTracingFragmentViewModel.kt | 2 +- .../ui/main/home/HomeFragment.kt | 4 +- .../ui/main/home/HomeFragmentViewModel.kt | 17 +- .../OnboardingAnalyticsViewModel.kt | 2 +- ...ingsPrivacyPreservingAnalyticsViewModel.kt | 2 +- .../SubmissionDeletionWarningViewModel.kt | 9 +- .../SubmissionTestResultPendingViewModel.kt | 6 +- .../coronawarnapp/util/flow/FlowExtensions.kt | 249 ++---------------- 25 files changed, 103 insertions(+), 345 deletions(-) diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/contactdiary/ui/day/tabs/person/ContactDiaryPersonListViewModel.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/contactdiary/ui/day/tabs/person/ContactDiaryPersonListViewModel.kt index e9124ed2aa4..cd93a649ea9 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/contactdiary/ui/day/tabs/person/ContactDiaryPersonListViewModel.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/contactdiary/ui/day/tabs/person/ContactDiaryPersonListViewModel.kt @@ -13,7 +13,7 @@ import de.rki.coronawarnapp.exception.ExceptionCategory import de.rki.coronawarnapp.exception.reporting.report import de.rki.coronawarnapp.util.coroutine.AppScope import de.rki.coronawarnapp.util.coroutine.DispatcherProvider -import de.rki.coronawarnapp.util.flow.combine +import kotlinx.coroutines.flow.combine import de.rki.coronawarnapp.util.trimToLength import de.rki.coronawarnapp.util.ui.SingleLiveEvent import de.rki.coronawarnapp.util.viewmodel.CWAViewModel diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/contactdiary/ui/overview/ContactDiaryOverviewViewModel.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/contactdiary/ui/overview/ContactDiaryOverviewViewModel.kt index 5f7ba6c60ff..e9bea4a60a1 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/contactdiary/ui/overview/ContactDiaryOverviewViewModel.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/contactdiary/ui/overview/ContactDiaryOverviewViewModel.kt @@ -40,11 +40,11 @@ import de.rki.coronawarnapp.util.TimeAndDateExtensions.toLocalDateUserTz import de.rki.coronawarnapp.util.TimeAndDateExtensions.toUserTimeZone import de.rki.coronawarnapp.util.TimeStamper import de.rki.coronawarnapp.util.coroutine.DispatcherProvider -import de.rki.coronawarnapp.util.flow.combine import de.rki.coronawarnapp.util.ui.SingleLiveEvent import de.rki.coronawarnapp.util.viewmodel.CWAViewModel import de.rki.coronawarnapp.util.viewmodel.SimpleCWAViewModelFactory import kotlinx.coroutines.flow.MutableStateFlow +import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.first import org.joda.time.Days import org.joda.time.LocalDate @@ -57,8 +57,8 @@ class ContactDiaryOverviewViewModel @AssistedInject constructor( dispatcherProvider: DispatcherProvider, contactDiaryRepository: ContactDiaryRepository, riskLevelStorage: RiskLevelStorage, - private val timeStamper: TimeStamper, checkInRepository: CheckInRepository, + private val timeStamper: TimeStamper, private val exporter: ContactDiaryExporter ) : CWAViewModel(dispatcherProvider = dispatcherProvider) { @@ -78,9 +78,17 @@ class ContactDiaryOverviewViewModel @AssistedInject constructor( action = { datesFlow.value = dates() } ) - private val locationVisitsFlow = contactDiaryRepository.locationVisits - private val personEncountersFlow = contactDiaryRepository.personEncounters - private val testResultsFlow = contactDiaryRepository.testResults + private val diaryDataFlow = combine( + contactDiaryRepository.locationVisits, + contactDiaryRepository.personEncounters, + contactDiaryRepository.testResults + ) { locationVisits, personEncounters, testResults -> + DiaryData( + locationVisits = locationVisits, + personEncounters = personEncounters, + testResults = testResults + ) + } private val riskLevelPerDateFlow = riskLevelStorage.ewDayRiskStates private val traceLocationCheckInRiskFlow = riskLevelStorage.traceLocationCheckInRiskStates @@ -88,29 +96,25 @@ class ContactDiaryOverviewViewModel @AssistedInject constructor( val listItems = combine( datesFlow, - locationVisitsFlow, - personEncountersFlow, + diaryDataFlow, riskLevelPerDateFlow, traceLocationCheckInRiskFlow, checkInsWithinRetentionFlow, - testResultsFlow ) { dateList, - locationVisits, - personEncounters, + diaryData, riskLevelPerDateList, traceLocationCheckInRiskList, - checkInList, - testResults -> + checkInList -> mutableListOf().apply { add(OverviewSubHeaderItem) addAll( dateList.createListItemList( - locationVisits, - personEncounters, + diaryData.locationVisits, + diaryData.personEncounters, riskLevelPerDateList, traceLocationCheckInRiskList, checkInList, - testResults + diaryData.testResults ) ) }.toList() @@ -344,19 +348,17 @@ class ContactDiaryOverviewViewModel @AssistedInject constructor( } } - fun onExportPress() { + fun onExportPress() = launch { Timber.d("Exporting person and location entries") - launch { - - val export = exporter.createExport( - personEncountersFlow.first(), - locationVisitsFlow.first(), - testResultsFlow.first(), + val export = with(diaryDataFlow.first()) { + exporter.createExport( + personEncounters, + locationVisits, + testResults, DAY_COUNT ) - - exportLocationsAndPersons.postValue(export) } + exportLocationsAndPersons.postValue(export) } override fun onCleared() { @@ -371,4 +373,10 @@ class ContactDiaryOverviewViewModel @AssistedInject constructor( // Today + 14 days const val DAY_COUNT = 15 } + + private data class DiaryData( + val locationVisits: List, + val personEncounters: List, + val testResults: List + ) } diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/coronatest/CoronaTestRepositoryExtensions.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/coronatest/CoronaTestRepositoryExtensions.kt index 9fb7a8aa411..a51f32f9939 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/coronatest/CoronaTestRepositoryExtensions.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/coronatest/CoronaTestRepositoryExtensions.kt @@ -4,7 +4,7 @@ import de.rki.coronawarnapp.coronatest.type.BaseCoronaTest import de.rki.coronawarnapp.coronatest.type.PersonalCoronaTest import de.rki.coronawarnapp.coronatest.type.pcr.PCRCoronaTest import de.rki.coronawarnapp.coronatest.type.rapidantigen.RACoronaTest -import de.rki.coronawarnapp.util.flow.combine +import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.distinctUntilChanged import kotlinx.coroutines.flow.flatMapMerge @@ -13,22 +13,12 @@ import kotlinx.coroutines.flow.map import timber.log.Timber val CoronaTestRepository.latestPCRT: Flow - get() = this.coronaTests - .map { allTests -> - allTests.singleOrNull { - it.type == BaseCoronaTest.Type.PCR - } as? PCRCoronaTest - } - .distinctUntilChanged() + get() = coronaTests.map { it.latestOf() }.distinctUntilChanged() val CoronaTestRepository.latestRAT: Flow - get() = this.coronaTests - .map { allTests -> - allTests.singleOrNull { - it.type == BaseCoronaTest.Type.RAPID_ANTIGEN - } as? RACoronaTest - } - .distinctUntilChanged() + get() = coronaTests.map { it.latestOf() }.distinctUntilChanged() + +inline fun Set.latestOf() = singleOrNull { it is T } as? T val CoronaTestRepository.positiveViewedTests: Flow> get() = combine(latestPCRT, latestRAT) { testPcr, testRat -> @@ -40,21 +30,18 @@ val CoronaTestRepository.positiveViewedTests: Flow> private val consumedErrors = mutableMapOf() val CoronaTestRepository.testErrorsSingleEvent: Flow> - get() = coronaTests - .map { tests -> - tests - .filter { - val consumedClass = consumedErrors[it.identifier]?.javaClass - consumedClass != it.lastError?.javaClass - } - .onEach { - Timber.v("Unconsumed error for %s: %s", it.identifier, it.lastError?.toString()) - consumedErrors[it.identifier] = it.lastError - } - .filter { it.lastError != null } - } - .flatMapMerge { tests -> - // First we emit the tests with errors - // then an empty list because the errors should only be displayed once - flowOf(tests, emptyList()) + get() = coronaTests.map { tests -> + tests.filter { + val consumedClass = consumedErrors[it.identifier]?.javaClass + consumedClass != it.lastError?.javaClass + }.onEach { + Timber.v("Unconsumed error for %s: %s", it.identifier, it.lastError?.toString()) + consumedErrors[it.identifier] = it.lastError + }.filter { + it.lastError != null } + }.flatMapMerge { tests -> + // First we emit the tests with errors + // then an empty list because the errors should only be displayed once + flowOf(tests, emptyList()) + } diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/covidcertificate/common/statecheck/DccValidityMeasuresObserver.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/covidcertificate/common/statecheck/DccValidityMeasuresObserver.kt index d9cab258dcf..765d9f4601f 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/covidcertificate/common/statecheck/DccValidityMeasuresObserver.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/covidcertificate/common/statecheck/DccValidityMeasuresObserver.kt @@ -6,7 +6,7 @@ import de.rki.coronawarnapp.covidcertificate.revocation.storage.DccRevocationRep import de.rki.coronawarnapp.covidcertificate.signature.core.DscSignatureList import de.rki.coronawarnapp.covidcertificate.signature.core.DscRepository import de.rki.coronawarnapp.util.coroutine.AppScope -import de.rki.coronawarnapp.util.flow.combine +import kotlinx.coroutines.flow.combine import de.rki.coronawarnapp.util.flow.shareLatest import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.flow.Flow diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/covidcertificate/recovery/core/RecoveryCertificateRepository.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/covidcertificate/recovery/core/RecoveryCertificateRepository.kt index d620d95d89b..5fab8f586fb 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/covidcertificate/recovery/core/RecoveryCertificateRepository.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/covidcertificate/recovery/core/RecoveryCertificateRepository.kt @@ -22,7 +22,7 @@ import de.rki.coronawarnapp.util.TimeStamper import de.rki.coronawarnapp.util.coroutine.AppScope import de.rki.coronawarnapp.util.coroutine.DispatcherProvider import de.rki.coronawarnapp.util.flow.HotDataFlow -import de.rki.coronawarnapp.util.flow.combine +import kotlinx.coroutines.flow.combine import de.rki.coronawarnapp.util.flow.shareLatest import de.rki.coronawarnapp.util.mutate import de.rki.coronawarnapp.util.reset.Resettable diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/covidcertificate/test/core/execution/TestCertificateRetrievalScheduler.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/covidcertificate/test/core/execution/TestCertificateRetrievalScheduler.kt index ccc8bdf1d34..344dcc40a53 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/covidcertificate/test/core/execution/TestCertificateRetrievalScheduler.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/covidcertificate/test/core/execution/TestCertificateRetrievalScheduler.kt @@ -15,7 +15,7 @@ import de.rki.coronawarnapp.familytest.core.repository.FamilyTestRepository import de.rki.coronawarnapp.initializer.Initializer import de.rki.coronawarnapp.util.coroutine.AppScope import de.rki.coronawarnapp.util.device.ForegroundState -import de.rki.coronawarnapp.util.flow.combine +import kotlinx.coroutines.flow.combine import de.rki.coronawarnapp.worker.BackgroundConstants import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.flow.distinctUntilChanged diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/covidcertificate/validation/core/business/wrapper/ValueSetWrapper.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/covidcertificate/validation/core/business/wrapper/ValueSetWrapper.kt index 199f966989a..21c03a23787 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/covidcertificate/validation/core/business/wrapper/ValueSetWrapper.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/covidcertificate/validation/core/business/wrapper/ValueSetWrapper.kt @@ -2,7 +2,7 @@ package de.rki.coronawarnapp.covidcertificate.validation.core.business.wrapper import de.rki.coronawarnapp.covidcertificate.validation.core.DccValidationRepository import de.rki.coronawarnapp.covidcertificate.valueset.ValueSetsRepository -import de.rki.coronawarnapp.util.flow.combine +import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.map import javax.inject.Inject diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/covidcertificate/validation/core/server/DccValidationServer.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/covidcertificate/validation/core/server/DccValidationServer.kt index baeeabe0c3f..c4d46c661e5 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/covidcertificate/validation/core/server/DccValidationServer.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/covidcertificate/validation/core/server/DccValidationServer.kt @@ -47,7 +47,7 @@ class DccValidationServer @Inject constructor( DccValidationRule.Type.ACCEPTANCE -> { val response = rulesApi.acceptanceRules() val source = getSource(response) - Timber.tag(TAG).v("Source of rule set: %s", source) + Timber.tag(TAG).v("Source of acceptanceRules: %s", source) val ruleSet = response.parseAndValidate( ErrorCode.ACCEPTANCE_RULE_JSON_ARCHIVE_FILE_MISSING, @@ -60,7 +60,7 @@ class DccValidationServer @Inject constructor( val response = rulesApi.invalidationRules() val source = getSource(response) - Timber.tag(TAG).v("Source of rule set: %s", source) + Timber.tag(TAG).v("Source of invalidationRules: %s", source) val ruleSet = response.parseAndValidate( ErrorCode.INVALIDATION_RULE_JSON_ARCHIVE_FILE_MISSING, @@ -74,7 +74,7 @@ class DccValidationServer @Inject constructor( val response = rulesApi.boosterNotificationRules() val source = getSource(response) - Timber.tag(TAG).v("Source of rule set: %s", source) + Timber.tag(TAG).v("Source of boosterNotificationRules: %s", source) val ruleSet = response.parseAndValidate( ErrorCode.BOOSTER_NOTIFICATION_RULE_JSON_ARCHIVE_FILE_MISSING, diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/deadman/DeadmanNotificationScheduler.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/deadman/DeadmanNotificationScheduler.kt index c49c419a5fa..b215c1935ae 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/deadman/DeadmanNotificationScheduler.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/deadman/DeadmanNotificationScheduler.kt @@ -8,7 +8,7 @@ import de.rki.coronawarnapp.initializer.Initializer import de.rki.coronawarnapp.nearby.ENFClient import de.rki.coronawarnapp.storage.OnboardingSettings import de.rki.coronawarnapp.util.coroutine.AppScope -import de.rki.coronawarnapp.util.flow.combine +import kotlinx.coroutines.flow.combine import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/familytest/core/repository/CoronaTestProcessor.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/familytest/core/repository/CoronaTestProcessor.kt index 0ff5d34f001..8ae507dc1a0 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/familytest/core/repository/CoronaTestProcessor.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/familytest/core/repository/CoronaTestProcessor.kt @@ -112,19 +112,11 @@ class CoronaTestProcessor @Inject constructor( ) } - is CoronaTestQRCode.RapidPCR -> RegistrationRequest( + is CoronaTestQRCode.Rapid -> RegistrationRequest( key = qrCode.registrationIdentifier, dateOfBirthKey = null, type = VerificationKeyType.GUID ) - - is CoronaTestQRCode.RapidAntigen -> RegistrationRequest( - key = qrCode.registrationIdentifier, - dateOfBirthKey = null, - type = VerificationKeyType.GUID - ) - - else -> throw IllegalArgumentException("CoronaTestProcessor: Unknown test request: $qrCode") } } diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/familytest/ui/consent/FamilyTestConsentViewModel.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/familytest/ui/consent/FamilyTestConsentViewModel.kt index f48195303e6..90e8333612a 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/familytest/ui/consent/FamilyTestConsentViewModel.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/familytest/ui/consent/FamilyTestConsentViewModel.kt @@ -12,7 +12,7 @@ import de.rki.coronawarnapp.util.viewmodel.CWAViewModel import de.rki.coronawarnapp.util.viewmodel.CWAViewModelFactory import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.first -import de.rki.coronawarnapp.util.flow.combine +import kotlinx.coroutines.flow.combine class FamilyTestConsentViewModel @AssistedInject constructor( dispatcherProvider: DispatcherProvider, diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/familytest/ui/testlist/FamilyTestListViewModel.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/familytest/ui/testlist/FamilyTestListViewModel.kt index 121905758e5..4ce7e0b121a 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/familytest/ui/testlist/FamilyTestListViewModel.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/familytest/ui/testlist/FamilyTestListViewModel.kt @@ -18,7 +18,7 @@ import de.rki.coronawarnapp.familytest.ui.testlist.items.FamilyTestListItem import de.rki.coronawarnapp.util.TimeStamper import de.rki.coronawarnapp.util.coroutine.AppScope import de.rki.coronawarnapp.util.coroutine.DispatcherProvider -import de.rki.coronawarnapp.util.flow.combine +import kotlinx.coroutines.flow.combine import de.rki.coronawarnapp.util.ui.SingleLiveEvent import de.rki.coronawarnapp.util.viewmodel.CWAViewModel import de.rki.coronawarnapp.util.viewmodel.SimpleCWAViewModelFactory diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/playbook/OrganizerPlaybook.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/playbook/OrganizerPlaybook.kt index 5a746697ea4..61102ff63f5 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/playbook/OrganizerPlaybook.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/playbook/OrganizerPlaybook.kt @@ -6,7 +6,6 @@ import de.rki.coronawarnapp.coronatest.server.RegistrationRequest import de.rki.coronawarnapp.coronatest.server.VerificationKeyType import de.rki.coronawarnapp.coronatest.server.VerificationServer import de.rki.coronawarnapp.exception.http.CwaClientError -import de.rki.coronawarnapp.exception.http.CwaServerError import de.rki.coronawarnapp.exception.http.CwaUnknownHostException import de.rki.coronawarnapp.exception.http.NetworkConnectTimeoutException import de.rki.coronawarnapp.presencetracing.checkins.CheckInsReport @@ -175,13 +174,8 @@ class OrganizerPlaybook @Inject constructor( ErrorType.TAN -> OrganizerSubmissionException.ErrorCode.TAN_OB_CLIENT_ERROR ErrorType.SUBMISSION -> OrganizerSubmissionException.ErrorCode.SUBMISSION_OB_CLIENT_ERROR } - // HTTP status code 5XX - is CwaServerError -> when (type) { - ErrorType.REG_TOKEN -> OrganizerSubmissionException.ErrorCode.REGTOKEN_OB_SERVER_ERROR - ErrorType.TAN -> OrganizerSubmissionException.ErrorCode.TAN_OB_SERVER_ERROR - ErrorType.SUBMISSION -> OrganizerSubmissionException.ErrorCode.SUBMISSION_OB_SERVER_ERROR - } - // Blame the server ¯\_(ツ)_/¯ + + // Blame the server ¯\_(ツ)_/¯ or HTTP status code 5XX else -> when (type) { ErrorType.REG_TOKEN -> OrganizerSubmissionException.ErrorCode.REGTOKEN_OB_SERVER_ERROR ErrorType.TAN -> OrganizerSubmissionException.ErrorCode.TAN_OB_SERVER_ERROR diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/presencetracing/risk/execution/PresenceTracingRiskWorkScheduler.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/presencetracing/risk/execution/PresenceTracingRiskWorkScheduler.kt index 13c35ae63cf..448220e6d13 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/presencetracing/risk/execution/PresenceTracingRiskWorkScheduler.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/presencetracing/risk/execution/PresenceTracingRiskWorkScheduler.kt @@ -10,7 +10,7 @@ import de.rki.coronawarnapp.task.common.DefaultTaskRequest import de.rki.coronawarnapp.util.coroutine.AppScope import de.rki.coronawarnapp.util.coroutine.await import de.rki.coronawarnapp.util.device.BackgroundModeStatus -import de.rki.coronawarnapp.util.flow.combine +import kotlinx.coroutines.flow.combine import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/presencetracing/risk/storage/PresenceTracingRiskRepository.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/presencetracing/risk/storage/PresenceTracingRiskRepository.kt index e537db624f9..12d0a864a45 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/presencetracing/risk/storage/PresenceTracingRiskRepository.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/presencetracing/risk/storage/PresenceTracingRiskRepository.kt @@ -9,7 +9,7 @@ import de.rki.coronawarnapp.presencetracing.risk.calculation.PresenceTracingDayR import de.rki.coronawarnapp.presencetracing.risk.calculation.PresenceTracingRiskCalculator import de.rki.coronawarnapp.risk.RiskState import de.rki.coronawarnapp.util.TimeStamper -import de.rki.coronawarnapp.util.flow.combine +import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.first import kotlinx.coroutines.flow.map diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/risk/storage/BaseRiskLevelStorage.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/risk/storage/BaseRiskLevelStorage.kt index 6494ea5407f..6a78f0bac01 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/risk/storage/BaseRiskLevelStorage.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/risk/storage/BaseRiskLevelStorage.kt @@ -23,7 +23,7 @@ import kotlinx.coroutines.flow.first import kotlinx.coroutines.flow.map import org.joda.time.Instant import timber.log.Timber -import de.rki.coronawarnapp.util.flow.combine as flowCombine +import kotlinx.coroutines.flow.combine as flowCombine abstract class BaseRiskLevelStorage constructor( private val riskResultDatabaseFactory: RiskResultDatabase.Factory, diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/tracing/states/TracingStateProvider.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/tracing/states/TracingStateProvider.kt index 55e4b09d7ab..f54eb74e992 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/tracing/states/TracingStateProvider.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/tracing/states/TracingStateProvider.kt @@ -12,7 +12,7 @@ import de.rki.coronawarnapp.storage.TracingRepository import de.rki.coronawarnapp.tracing.GeneralTracingStatus import de.rki.coronawarnapp.tracing.TracingProgress import de.rki.coronawarnapp.util.device.BackgroundModeStatus -import de.rki.coronawarnapp.util.flow.combine +import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.onCompletion import kotlinx.coroutines.flow.onEach diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/tracing/ui/settings/SettingsTracingFragmentViewModel.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/tracing/ui/settings/SettingsTracingFragmentViewModel.kt index 50e7d87cff0..58daa2a430b 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/tracing/ui/settings/SettingsTracingFragmentViewModel.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/tracing/ui/settings/SettingsTracingFragmentViewModel.kt @@ -20,7 +20,7 @@ import de.rki.coronawarnapp.tracing.GeneralTracingStatus import de.rki.coronawarnapp.tracing.ui.details.items.periodlogged.PeriodLoggedBox import de.rki.coronawarnapp.util.coroutine.DispatcherProvider import de.rki.coronawarnapp.util.device.BackgroundModeStatus -import de.rki.coronawarnapp.util.flow.combine +import kotlinx.coroutines.flow.combine import de.rki.coronawarnapp.util.flow.shareLatest import de.rki.coronawarnapp.util.ui.SingleLiveEvent import de.rki.coronawarnapp.util.viewmodel.CWAViewModel diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/ui/main/home/HomeFragment.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/ui/main/home/HomeFragment.kt index ea9b028b244..84c2e57daf3 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/ui/main/home/HomeFragment.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/ui/main/home/HomeFragment.kt @@ -250,9 +250,7 @@ class HomeFragment : Fragment(R.layout.home_fragment_layout), AutoInject { NavGraphDirections.actionGlobalToSubmissionTestResultAvailableFragment(event.identifier) ) is HomeFragmentEvents.GoToPcrTestResultNegativeFragment -> doNavigate( - NavGraphDirections.actionGlobalToSubmissionTestResultNegativeFragment( - event.identifier - ) + NavGraphDirections.actionGlobalToSubmissionTestResultNegativeFragment(event.identifier) ) is HomeFragmentEvents.GoToTestResultKeysSharedFragment -> doNavigate( NavGraphDirections.actionGlobalToSubmissionTestResultKeysSharedFragment( diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/ui/main/home/HomeFragmentViewModel.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/ui/main/home/HomeFragmentViewModel.kt index e08805f11e4..5ce250671b5 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/ui/main/home/HomeFragmentViewModel.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/ui/main/home/HomeFragmentViewModel.kt @@ -8,8 +8,7 @@ import de.rki.coronawarnapp.appconfig.AppConfigProvider import de.rki.coronawarnapp.appconfig.CoronaTestConfig import de.rki.coronawarnapp.coronatest.CoronaTestRepository import de.rki.coronawarnapp.coronatest.errors.CoronaTestNotFoundException -import de.rki.coronawarnapp.coronatest.latestPCRT -import de.rki.coronawarnapp.coronatest.latestRAT +import de.rki.coronawarnapp.coronatest.latestOf import de.rki.coronawarnapp.coronatest.testErrorsSingleEvent import de.rki.coronawarnapp.coronatest.type.BaseCoronaTest.Type.PCR import de.rki.coronawarnapp.coronatest.type.BaseCoronaTest.Type.RAPID_ANTIGEN @@ -82,7 +81,7 @@ import de.rki.coronawarnapp.util.TimeStamper import de.rki.coronawarnapp.util.bluetooth.BluetoothSupport import de.rki.coronawarnapp.util.coroutine.DispatcherProvider import de.rki.coronawarnapp.util.encryptionmigration.EncryptionErrorResetTool -import de.rki.coronawarnapp.util.flow.combine +import kotlinx.coroutines.flow.combine import de.rki.coronawarnapp.util.network.NetworkStateProvider import de.rki.coronawarnapp.util.shortcuts.AppShortcutsHelper import de.rki.coronawarnapp.util.ui.SingleLiveEvent @@ -208,16 +207,20 @@ class HomeFragmentViewModel @AssistedInject constructor( val homeItems: LiveData> = combine( tracingCardItems, - coronaTestRepository.latestPCRT, - coronaTestRepository.latestRAT, + coronaTestRepository.coronaTests, combinedStatistics, appConfigProvider.currentConfig.map { it.coronaTestParameters }.distinctUntilChanged(), familyTestRepository.familyTests - ) { tracingItem, testPCR, testRAT, statsData, coronaTestParameters, familyTests -> + ) { tracingItem, coronaTests, statsData, coronaTestParameters, familyTests -> mutableListOf().apply { addRiskLevelCard(tracingItem) addIncompatibleCard() - addTestCards(testPCR, testRAT, coronaTestParameters, familyTests) + addTestCards( + coronaTests.latestOf(), + coronaTests.latestOf(), + coronaTestParameters, + familyTests + ) addStatisticsCard(statsData) addTraceLocationCard() addFaqCard() diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/ui/onboarding/OnboardingAnalyticsViewModel.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/ui/onboarding/OnboardingAnalyticsViewModel.kt index cc75f5ea137..e966da73681 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/ui/onboarding/OnboardingAnalyticsViewModel.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/ui/onboarding/OnboardingAnalyticsViewModel.kt @@ -10,7 +10,7 @@ import de.rki.coronawarnapp.datadonation.analytics.storage.AnalyticsSettings import de.rki.coronawarnapp.environment.BuildConfigWrap import de.rki.coronawarnapp.util.coroutine.AppScope import de.rki.coronawarnapp.util.coroutine.DispatcherProvider -import de.rki.coronawarnapp.util.flow.combine +import kotlinx.coroutines.flow.combine import de.rki.coronawarnapp.util.ui.SingleLiveEvent import de.rki.coronawarnapp.util.viewmodel.CWAViewModel import de.rki.coronawarnapp.util.viewmodel.SimpleCWAViewModelFactory diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/ui/settings/analytics/SettingsPrivacyPreservingAnalyticsViewModel.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/ui/settings/analytics/SettingsPrivacyPreservingAnalyticsViewModel.kt index e77b2e092de..4c6a43acd8e 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/ui/settings/analytics/SettingsPrivacyPreservingAnalyticsViewModel.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/ui/settings/analytics/SettingsPrivacyPreservingAnalyticsViewModel.kt @@ -7,7 +7,7 @@ import de.rki.coronawarnapp.datadonation.analytics.Analytics import de.rki.coronawarnapp.datadonation.analytics.common.Districts import de.rki.coronawarnapp.datadonation.analytics.storage.AnalyticsSettings import de.rki.coronawarnapp.util.coroutine.DispatcherProvider -import de.rki.coronawarnapp.util.flow.combine +import kotlinx.coroutines.flow.combine import de.rki.coronawarnapp.util.viewmodel.CWAViewModel import de.rki.coronawarnapp.util.viewmodel.SimpleCWAViewModelFactory import kotlinx.coroutines.flow.first diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/ui/submission/deletionwarning/SubmissionDeletionWarningViewModel.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/ui/submission/deletionwarning/SubmissionDeletionWarningViewModel.kt index 397376d2fcd..ea59acd9769 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/ui/submission/deletionwarning/SubmissionDeletionWarningViewModel.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/ui/submission/deletionwarning/SubmissionDeletionWarningViewModel.kt @@ -98,14 +98,7 @@ class SubmissionDeletionWarningViewModel @AssistedInject constructor( ) ) test.isNegative -> when (test.type) { - BaseCoronaTest.Type.PCR -> routeToScreen.postValue( - DuplicateWarningEvent.Direction( - SubmissionDeletionWarningFragmentDirections - .actionSubmissionDeletionWarningFragmentToSubmissionTestResultNegativeFragment( - testIdentifier = request.identifier - ) - ) - ) + BaseCoronaTest.Type.PCR, BaseCoronaTest.Type.RAPID_ANTIGEN -> routeToScreen.postValue( DuplicateWarningEvent.Direction( SubmissionDeletionWarningFragmentDirections diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/ui/submission/testresult/pending/SubmissionTestResultPendingViewModel.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/ui/submission/testresult/pending/SubmissionTestResultPendingViewModel.kt index e128dc6fda0..cbeb5c07b44 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/ui/submission/testresult/pending/SubmissionTestResultPendingViewModel.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/ui/submission/testresult/pending/SubmissionTestResultPendingViewModel.kt @@ -92,11 +92,7 @@ class SubmissionTestResultPendingViewModel @AssistedInject constructor( ) } } - CoronaTestResult.PCR_NEGATIVE -> - SubmissionTestResultPendingFragmentDirections - .actionSubmissionTestResultPendingFragmentToSubmissionTestResultNegativeFragment( - testIdentifier = testIdentifier - ) + CoronaTestResult.PCR_NEGATIVE, CoronaTestResult.RAT_NEGATIVE -> SubmissionTestResultPendingFragmentDirections .actionSubmissionTestResultPendingFragmentToSubmissionTestResultNegativeFragment( diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/util/flow/FlowExtensions.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/util/flow/FlowExtensions.kt index fc1616125bd..08433779f1d 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/util/flow/FlowExtensions.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/util/flow/FlowExtensions.kt @@ -6,7 +6,6 @@ import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.SharingStarted import kotlinx.coroutines.flow.catch import kotlinx.coroutines.flow.collectLatest -import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.filterNotNull import kotlinx.coroutines.flow.onCompletion import kotlinx.coroutines.flow.onEach @@ -24,239 +23,27 @@ fun Flow.shareLatest( tag: String? = null, scope: CoroutineScope, started: SharingStarted = SharingStarted.WhileSubscribed(replayExpirationMillis = 0) -) = this - .onStart { - if (tag != null) Timber.tag(tag).v("shareLatest(...) start") - } - .onEach { - if (tag != null) Timber.tag(tag).v("shareLatest(...) emission: %s", it) - } - .onCompletion { - if (tag != null) Timber.tag(tag).v("shareLatest(...) completed.") - } - .catch { - if (tag != null) Timber.tag(tag).w(it, "shareLatest(...) catch()!.") - throw it - } - .stateIn( - scope = scope, - started = started, - initialValue = null - ) - .filterNotNull() +) = onStart { + if (tag != null) Timber.tag(tag).v("shareLatest(...) start") +}.onEach { + if (tag != null) Timber.tag(tag).v("shareLatest(...) emission: %s", it) +}.onCompletion { + if (tag != null) Timber.tag(tag).v("shareLatest(...) completed.") +}.catch { + if (tag != null) Timber.tag(tag).w(it, "shareLatest(...) catch()!.") + throw it +}.stateIn( + scope = scope, + started = started, + initialValue = null +).filterNotNull() /** * This is a shorthand for `scope.launch { flow.collectLatest(action) }` */ -fun Flow.launchInLatest(scope: CoroutineScope, action: suspend (value: T) -> Unit): Job = scope.launch { +fun Flow.launchInLatest( + scope: CoroutineScope, + action: suspend (value: T) -> Unit +): Job = scope.launch { collectLatest(action) // tail-call } - -@Suppress("UNCHECKED_CAST", "LongParameterList") -inline fun combine( - flow: Flow, - flow2: Flow, - crossinline transform: suspend (T1, T2) -> R -): Flow = combine( - flow, - flow2 -) { args: Array<*> -> - transform( - args[0] as T1, - args[1] as T2 - ) -} - -@Suppress("UNCHECKED_CAST", "LongParameterList") -inline fun combine( - flow: Flow, - flow2: Flow, - flow3: Flow, - crossinline transform: suspend (T1, T2, T3) -> R -): Flow = combine( - flow, - flow2, - flow3, -) { args: Array<*> -> - transform( - args[0] as T1, - args[1] as T2, - args[2] as T3, - ) -} - -@Suppress("UNCHECKED_CAST", "LongParameterList") -inline fun combine( - flow: Flow, - flow2: Flow, - flow3: Flow, - flow4: Flow, - flow5: Flow, - crossinline transform: suspend (T1, T2, T3, T4, T5) -> R -): Flow = combine( - flow, - flow2, - flow3, - flow4, - flow5 -) { args: Array<*> -> - transform( - args[0] as T1, - args[1] as T2, - args[2] as T3, - args[3] as T4, - args[4] as T5 - ) -} - -@Suppress("UNCHECKED_CAST", "LongParameterList") -inline fun combine( - flow: Flow, - flow2: Flow, - flow3: Flow, - flow4: Flow, - flow5: Flow, - flow6: Flow, - crossinline transform: suspend (T1, T2, T3, T4, T5, T6) -> R -): Flow = combine( - flow, - flow2, - flow3, - flow4, - flow5, - flow6 -) { args: Array<*> -> - transform( - args[0] as T1, - args[1] as T2, - args[2] as T3, - args[3] as T4, - args[4] as T5, - args[5] as T6 - ) -} - -@Suppress("UNCHECKED_CAST", "LongParameterList") -inline fun combine( - flow: Flow, - flow2: Flow, - flow3: Flow, - flow4: Flow, - flow5: Flow, - flow6: Flow, - flow7: Flow, - crossinline transform: suspend (T1, T2, T3, T4, T5, T6, T7) -> R -): Flow = combine( - flow, - flow2, - flow3, - flow4, - flow5, - flow6, - flow7 -) { args: Array<*> -> - transform( - args[0] as T1, - args[1] as T2, - args[2] as T3, - args[3] as T4, - args[4] as T5, - args[5] as T6, - args[6] as T7 - ) -} - -@Suppress("UNCHECKED_CAST", "LongParameterList") -inline fun combine( - flow: Flow, - flow2: Flow, - flow3: Flow, - flow4: Flow, - flow5: Flow, - flow6: Flow, - flow7: Flow, - flow8: Flow, - crossinline transform: suspend (T1, T2, T3, T4, T5, T6, T7, T8) -> R -): Flow = combine( - flow, - flow2, - flow3, - flow4, - flow5, - flow6, - flow7, - flow8 -) { args: Array<*> -> - transform( - args[0] as T1, - args[1] as T2, - args[2] as T3, - args[3] as T4, - args[4] as T5, - args[5] as T6, - args[6] as T7, - args[7] as T8 - ) -} - -@Suppress("UNCHECKED_CAST", "LongParameterList") -inline fun combine( - flow: Flow, - flow2: Flow, - flow3: Flow, - flow4: Flow, - flow5: Flow, - flow6: Flow, - flow7: Flow, - flow8: Flow, - flow9: Flow, - flow10: Flow, - crossinline transform: suspend (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10) -> R -): Flow = combine( - flow, flow2, flow3, flow4, flow5, flow6, flow7, flow8, flow9, flow10 -) { args: Array<*> -> - transform( - args[0] as T1, - args[1] as T2, - args[2] as T3, - args[3] as T4, - args[4] as T5, - args[5] as T6, - args[6] as T7, - args[7] as T8, - args[8] as T9, - args[9] as T10 - ) -} - -@Suppress("UNCHECKED_CAST", "LongParameterList") -inline fun combine( - flow: Flow, - flow2: Flow, - flow3: Flow, - flow4: Flow, - flow5: Flow, - flow6: Flow, - flow7: Flow, - flow8: Flow, - flow9: Flow, - flow10: Flow, - flow11: Flow, - crossinline transform: suspend (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11) -> R -): Flow = combine( - flow, flow2, flow3, flow4, flow5, flow6, flow7, flow8, flow9, flow10, flow11 -) { args: Array<*> -> - transform( - args[0] as T1, - args[1] as T2, - args[2] as T3, - args[3] as T4, - args[4] as T5, - args[5] as T6, - args[6] as T7, - args[7] as T8, - args[8] as T9, - args[9] as T10, - args[10] as T11 - ) -} From 486fb387d79824818b1edd8e86a776153556475f Mon Sep 17 00:00:00 2001 From: Mohamed Metwalli Date: Wed, 1 Jun 2022 10:55:33 +0200 Subject: [PATCH 44/44] Enable test --- .../contactdiary/OrganizerRegistrationTokenCensorTest.kt | 2 -- 1 file changed, 2 deletions(-) diff --git a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/bugreporting/censors/contactdiary/OrganizerRegistrationTokenCensorTest.kt b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/bugreporting/censors/contactdiary/OrganizerRegistrationTokenCensorTest.kt index 00ad01c6930..4700d8c319b 100644 --- a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/bugreporting/censors/contactdiary/OrganizerRegistrationTokenCensorTest.kt +++ b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/bugreporting/censors/contactdiary/OrganizerRegistrationTokenCensorTest.kt @@ -7,11 +7,9 @@ import io.mockk.MockKAnnotations import kotlinx.coroutines.test.runTest import org.junit.jupiter.api.AfterEach import org.junit.jupiter.api.BeforeEach -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @Suppress("MaxLineLength") -@Disabled class OrganizerRegistrationTokenCensorTest { private val tans = listOf(