From af9d4023397d9cef64991883424c524cf0396fef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20Mart=C3=ADn?= Date: Mon, 20 May 2024 08:54:09 +0200 Subject: [PATCH 1/8] Try to fix CI quality step Maybe the `onCheck` value in the different Kover verify methods is causing it. --- plugins/src/main/kotlin/extension/KoverExtension.kt | 4 ---- 1 file changed, 4 deletions(-) diff --git a/plugins/src/main/kotlin/extension/KoverExtension.kt b/plugins/src/main/kotlin/extension/KoverExtension.kt index 68f89f300f9..ff66d1d6c6f 100644 --- a/plugins/src/main/kotlin/extension/KoverExtension.kt +++ b/plugins/src/main/kotlin/extension/KoverExtension.kt @@ -122,7 +122,6 @@ fun Project.setupKover() { total { verify { - onCheck = true // General rule: minimum code coverage. rule("Global minimum code coverage.") { groupBy = GroupingEntityType.APPLICATION @@ -140,7 +139,6 @@ fun Project.setupKover() { } variant(KoverVariant.Presenters.variantName) { verify { - onCheck = true // Rule to ensure that coverage of Presenters is sufficient. rule("Check code coverage of presenters") { groupBy = GroupingEntityType.CLASS @@ -171,7 +169,6 @@ fun Project.setupKover() { } variant(KoverVariant.States.variantName) { verify { - onCheck = true // Rule to ensure that coverage of States is sufficient. rule("Check code coverage of states") { groupBy = GroupingEntityType.CLASS @@ -214,7 +211,6 @@ fun Project.setupKover() { } variant(KoverVariant.Views.variantName) { verify { - onCheck = true // Rule to ensure that coverage of Views is sufficient (deactivated for now). rule("Check code coverage of views") { groupBy = GroupingEntityType.CLASS From 8b88aad45c138010dfed4bfe921fd57a8b141a52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20Mart=C3=ADn?= Date: Mon, 20 May 2024 09:54:31 +0200 Subject: [PATCH 2/8] Try splitting quality flow --- .github/workflows/quality.yml | 106 ++++++++++++++++++++++++++++++++-- 1 file changed, 101 insertions(+), 5 deletions(-) diff --git a/.github/workflows/quality.yml b/.github/workflows/quality.yml index b62dbb0127b..a972f583271 100644 --- a/.github/workflows/quality.yml +++ b/.github/workflows/quality.yml @@ -10,7 +10,7 @@ on: # Enrich gradle.properties for CI/CD env: GRADLE_OPTS: -Dorg.gradle.jvmargs="-Xmx6g -Dfile.encoding=UTF-8 -XX:+HeapDumpOnOutOfMemoryError" -Dkotlin.incremental=false -XX:+UseParallelGC - CI_GRADLE_ARG_PROPERTIES: --stacktrace -PpreDexEnable=false --max-workers 8 --no-daemon --warn + CI_GRADLE_ARG_PROPERTIES: --stacktrace -PpreDexEnable=false --max-workers 8 jobs: checkScript: @@ -33,8 +33,37 @@ jobs: - name: Search for invalid screenshot files run: ./tools/test/checkInvalidScreenshots.py - check: - name: Project Check Suite + # Code checks + konsist: + name: Konsist tests + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + # Ensure we are building the branch and not the branch after being merged on develop + # https://github.com/actions/checkout/issues/881 + ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.ref }} + - name: Use JDK 17 + uses: actions/setup-java@v4 + with: + distribution: 'temurin' # See 'Supported distributions' for available options + java-version: '17' + - name: Configure gradle + uses: gradle/actions/setup-gradle@v3 + with: + cache-read-only: ${{ github.ref != 'refs/heads/develop' }} + - name: Run Konsist tests + run: ./gradlew :tests:konsist:testDebugUnitTest $CI_GRADLE_ARG_PROPERTIES --no-daemon + - name: Upload reports + if: always() + uses: actions/upload-artifact@v4 + with: + name: konsist-report + path: | + **/build/reports/**/*.* + + lint: + name: Lint checks runs-on: ubuntu-latest # Allow all jobs on main and develop. Just one per PR. concurrency: @@ -55,8 +84,10 @@ jobs: uses: gradle/actions/setup-gradle@v3 with: cache-read-only: ${{ github.ref != 'refs/heads/develop' }} - - name: Run code quality check suite - run: ./gradlew runQualityChecks $CI_GRADLE_ARG_PROPERTIES + - name: Run lint + run: ./gradlew lintDebug $CI_GRADLE_ARG_PROPERTIES + - name: Run ktlint + run: ./gradlew ktlintCheck $CI_GRADLE_ARG_PROPERTIES - name: Upload reports if: always() uses: actions/upload-artifact@v4 @@ -64,6 +95,71 @@ jobs: name: linting-report path: | **/build/reports/**/*.* + + detekt: + name: Detekt checks + runs-on: ubuntu-latest + # Allow all jobs on main and develop. Just one per PR. + concurrency: + group: ${{ github.ref == 'refs/heads/main' && format('check-main-{0}', github.sha) || github.ref == 'refs/heads/develop' && format('check-develop-{0}', github.sha) || format('check-{0}', github.ref) }} + cancel-in-progress: true + steps: + - uses: actions/checkout@v4 + with: + # Ensure we are building the branch and not the branch after being merged on develop + # https://github.com/actions/checkout/issues/881 + ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.ref }} + - name: Use JDK 17 + uses: actions/setup-java@v4 + with: + distribution: 'temurin' # See 'Supported distributions' for available options + java-version: '17' + - name: Configure gradle + uses: gradle/actions/setup-gradle@v3 + with: + cache-read-only: ${{ github.ref != 'refs/heads/develop' }} + - name: Run Detekt + run: ./gradlew detekt $CI_GRADLE_ARG_PROPERTIES --no-daemon + - name: Upload reports + if: always() + uses: actions/upload-artifact@v4 + with: + name: detekt-report + path: | + **/build/reports/**/*.* + + knit: + name: Knit checks + runs-on: ubuntu-latest + # Allow all jobs on main and develop. Just one per PR. + concurrency: + group: ${{ github.ref == 'refs/heads/main' && format('check-main-{0}', github.sha) || github.ref == 'refs/heads/develop' && format('check-develop-{0}', github.sha) || format('check-{0}', github.ref) }} + cancel-in-progress: true + steps: + - uses: actions/checkout@v4 + with: + # Ensure we are building the branch and not the branch after being merged on develop + # https://github.com/actions/checkout/issues/881 + ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.ref }} + - name: Use JDK 17 + uses: actions/setup-java@v4 + with: + distribution: 'temurin' # See 'Supported distributions' for available options + java-version: '17' + - name: Configure gradle + uses: gradle/actions/setup-gradle@v3 + with: + cache-read-only: ${{ github.ref != 'refs/heads/develop' }} + - name: Run Knit + run: ./gradlew knitCheck $CI_GRADLE_ARG_PROPERTIES --no-daemon + + upload_reports: + name: Quality checks reports + runs-on: ubuntu-latest + needs: [konsist, lint, detekt, knit] + steps: + - name: Download reports from previous jobs + uses: actions/download-artifact@v4 - name: Prepare Danger if: always() run: | From ebdc10c3d320aac69c76b983a57120ef7706cdca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20Mart=C3=ADn?= Date: Mon, 20 May 2024 09:58:27 +0200 Subject: [PATCH 3/8] Fix concurrency --- .github/workflows/quality.yml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/quality.yml b/.github/workflows/quality.yml index a972f583271..a76ad0e2f3f 100644 --- a/.github/workflows/quality.yml +++ b/.github/workflows/quality.yml @@ -37,6 +37,10 @@ jobs: konsist: name: Konsist tests runs-on: ubuntu-latest + # Allow all jobs on main and develop. Just one per PR. + concurrency: + group: ${{ github.ref == 'refs/heads/main' && format('check-konsist-main-{0}', github.sha) || github.ref == 'refs/heads/develop' && format('check-konsist-develop-{0}', github.sha) || format('check-konsist-{0}', github.ref) }} + cancel-in-progress: true steps: - uses: actions/checkout@v4 with: @@ -67,7 +71,7 @@ jobs: runs-on: ubuntu-latest # Allow all jobs on main and develop. Just one per PR. concurrency: - group: ${{ github.ref == 'refs/heads/main' && format('check-main-{0}', github.sha) || github.ref == 'refs/heads/develop' && format('check-develop-{0}', github.sha) || format('check-{0}', github.ref) }} + group: ${{ github.ref == 'refs/heads/main' && format('check-lint-main-{0}', github.sha) || github.ref == 'refs/heads/develop' && format('check-lint-develop-{0}', github.sha) || format('check-lint-{0}', github.ref) }} cancel-in-progress: true steps: - uses: actions/checkout@v4 @@ -101,7 +105,7 @@ jobs: runs-on: ubuntu-latest # Allow all jobs on main and develop. Just one per PR. concurrency: - group: ${{ github.ref == 'refs/heads/main' && format('check-main-{0}', github.sha) || github.ref == 'refs/heads/develop' && format('check-develop-{0}', github.sha) || format('check-{0}', github.ref) }} + group: ${{ github.ref == 'refs/heads/main' && format('check-detekt-main-{0}', github.sha) || github.ref == 'refs/heads/develop' && format('check-detekt-develop-{0}', github.sha) || format('check-detekt-{0}', github.ref) }} cancel-in-progress: true steps: - uses: actions/checkout@v4 @@ -133,7 +137,7 @@ jobs: runs-on: ubuntu-latest # Allow all jobs on main and develop. Just one per PR. concurrency: - group: ${{ github.ref == 'refs/heads/main' && format('check-main-{0}', github.sha) || github.ref == 'refs/heads/develop' && format('check-develop-{0}', github.sha) || format('check-{0}', github.ref) }} + group: ${{ github.ref == 'refs/heads/main' && format('check-knit-main-{0}', github.sha) || github.ref == 'refs/heads/develop' && format('check-knit-develop-{0}', github.sha) || format('check-knit-{0}', github.ref) }} cancel-in-progress: true steps: - uses: actions/checkout@v4 From d47ed5121e4eb6cad1590681d975f54ee29b591c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20Mart=C3=ADn?= Date: Mon, 20 May 2024 10:05:14 +0200 Subject: [PATCH 4/8] No need to depend on `knit` for reports --- .github/workflows/quality.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/quality.yml b/.github/workflows/quality.yml index a76ad0e2f3f..ab8cb08ef29 100644 --- a/.github/workflows/quality.yml +++ b/.github/workflows/quality.yml @@ -160,7 +160,7 @@ jobs: upload_reports: name: Quality checks reports runs-on: ubuntu-latest - needs: [konsist, lint, detekt, knit] + needs: [konsist, lint, detekt] steps: - name: Download reports from previous jobs uses: actions/download-artifact@v4 From c5b199f246a4f219f72511aac83571a1f19b9e53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20Mart=C3=ADn?= Date: Mon, 20 May 2024 10:17:09 +0200 Subject: [PATCH 5/8] Split lint and ktlint, try simplifying lint one --- .github/workflows/quality.yml | 40 ++++++++++++++++++++++++++++++----- 1 file changed, 35 insertions(+), 5 deletions(-) diff --git a/.github/workflows/quality.yml b/.github/workflows/quality.yml index ab8cb08ef29..42f34debf3d 100644 --- a/.github/workflows/quality.yml +++ b/.github/workflows/quality.yml @@ -67,7 +67,7 @@ jobs: **/build/reports/**/*.* lint: - name: Lint checks + name: Android lint check runs-on: ubuntu-latest # Allow all jobs on main and develop. Just one per PR. concurrency: @@ -89,9 +89,7 @@ jobs: with: cache-read-only: ${{ github.ref != 'refs/heads/develop' }} - name: Run lint - run: ./gradlew lintDebug $CI_GRADLE_ARG_PROPERTIES - - name: Run ktlint - run: ./gradlew ktlintCheck $CI_GRADLE_ARG_PROPERTIES + run: ./gradlew :app:lintGplayDebug :app:lintFdroidDebug $CI_GRADLE_ARG_PROPERTIES - name: Upload reports if: always() uses: actions/upload-artifact@v4 @@ -132,6 +130,38 @@ jobs: path: | **/build/reports/**/*.* + ktlint: + name: Ktlint checks + runs-on: ubuntu-latest + # Allow all jobs on main and develop. Just one per PR. + concurrency: + group: ${{ github.ref == 'refs/heads/main' && format('check-ktlint-main-{0}', github.sha) || github.ref == 'refs/heads/develop' && format('check-ktlint-develop-{0}', github.sha) || format('check-ktlint-{0}', github.ref) }} + cancel-in-progress: true + steps: + - uses: actions/checkout@v4 + with: + # Ensure we are building the branch and not the branch after being merged on develop + # https://github.com/actions/checkout/issues/881 + ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.ref }} + - name: Use JDK 17 + uses: actions/setup-java@v4 + with: + distribution: 'temurin' # See 'Supported distributions' for available options + java-version: '17' + - name: Configure gradle + uses: gradle/actions/setup-gradle@v3 + with: + cache-read-only: ${{ github.ref != 'refs/heads/develop' }} + - name: Run Ktlint check + run: ./gradlew ktlintCheck $CI_GRADLE_ARG_PROPERTIES --no-daemon + - name: Upload reports + if: always() + uses: actions/upload-artifact@v4 + with: + name: ktlint-report + path: | + **/build/reports/**/*.* + knit: name: Knit checks runs-on: ubuntu-latest @@ -160,7 +190,7 @@ jobs: upload_reports: name: Quality checks reports runs-on: ubuntu-latest - needs: [konsist, lint, detekt] + needs: [konsist, lint, ktlint, detekt] steps: - name: Download reports from previous jobs uses: actions/download-artifact@v4 From 236e4cca5c474d355f92b4142f78b4c53fa39129 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20Mart=C3=ADn?= Date: Mon, 20 May 2024 10:39:17 +0200 Subject: [PATCH 6/8] Add back `--no-daemon` to the default properties --- .github/workflows/quality.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/quality.yml b/.github/workflows/quality.yml index 42f34debf3d..497353ec650 100644 --- a/.github/workflows/quality.yml +++ b/.github/workflows/quality.yml @@ -10,7 +10,7 @@ on: # Enrich gradle.properties for CI/CD env: GRADLE_OPTS: -Dorg.gradle.jvmargs="-Xmx6g -Dfile.encoding=UTF-8 -XX:+HeapDumpOnOutOfMemoryError" -Dkotlin.incremental=false -XX:+UseParallelGC - CI_GRADLE_ARG_PROPERTIES: --stacktrace -PpreDexEnable=false --max-workers 8 + CI_GRADLE_ARG_PROPERTIES: --stacktrace -PpreDexEnable=false --max-workers 8 --no-daemon jobs: checkScript: @@ -153,7 +153,7 @@ jobs: with: cache-read-only: ${{ github.ref != 'refs/heads/develop' }} - name: Run Ktlint check - run: ./gradlew ktlintCheck $CI_GRADLE_ARG_PROPERTIES --no-daemon + run: ./gradlew ktlintCheck $CI_GRADLE_ARG_PROPERTIES - name: Upload reports if: always() uses: actions/upload-artifact@v4 @@ -185,7 +185,7 @@ jobs: with: cache-read-only: ${{ github.ref != 'refs/heads/develop' }} - name: Run Knit - run: ./gradlew knitCheck $CI_GRADLE_ARG_PROPERTIES --no-daemon + run: ./gradlew knitCheck $CI_GRADLE_ARG_PROPERTIES upload_reports: name: Quality checks reports From c0943eeeacecfb8fbd21ff2f1467b8cadf87dd13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20Mart=C3=ADn?= Date: Mon, 20 May 2024 11:29:18 +0200 Subject: [PATCH 7/8] Checkout the repo in the upload reports job --- .github/workflows/quality.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/quality.yml b/.github/workflows/quality.yml index 497353ec650..7e495afe28d 100644 --- a/.github/workflows/quality.yml +++ b/.github/workflows/quality.yml @@ -192,6 +192,11 @@ jobs: runs-on: ubuntu-latest needs: [konsist, lint, ktlint, detekt] steps: + - uses: actions/checkout@v4 + with: + # Ensure we are building the branch and not the branch after being merged on develop + # https://github.com/actions/checkout/issues/881 + ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.ref }} - name: Download reports from previous jobs uses: actions/download-artifact@v4 - name: Prepare Danger From 649c63dccd8728abeb36fe328eaba9622657282d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20Mart=C3=ADn?= Date: Mon, 20 May 2024 11:56:22 +0200 Subject: [PATCH 8/8] Use the right name for the upload job so it's required --- .github/workflows/quality.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/quality.yml b/.github/workflows/quality.yml index 7e495afe28d..c3e29a23067 100644 --- a/.github/workflows/quality.yml +++ b/.github/workflows/quality.yml @@ -188,7 +188,7 @@ jobs: run: ./gradlew knitCheck $CI_GRADLE_ARG_PROPERTIES upload_reports: - name: Quality checks reports + name: Project Check Suite runs-on: ubuntu-latest needs: [konsist, lint, ktlint, detekt] steps: