Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistence between koverVerify and koverVerifyJvm #667

Closed
MessiasLima opened this issue Aug 7, 2024 · 5 comments
Closed

Inconsistence between koverVerify and koverVerifyJvm #667

MessiasLima opened this issue Aug 7, 2024 · 5 comments
Assignees
Labels
Question Support request issue type S: in progress Status: implementing or design in process

Comments

@MessiasLima
Copy link

Describe the bug
In a Kotlin multiplatform environment, there is an inconsistency between the tasks koverVerify and koverVerifyJvm.

Where running the latter, the coverage verification isn't working and the tasks always succeeds.

Errors
When running regular verify

❯ ./gradlew clean koverVerify   
Reusing configuration cache.
> Task :koverVerify FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':koverVerify'.
> Rule violated:
    lines covered percentage is 0.000000, but expected minimum is 90
    instructions covered percentage is 0.000000, but expected minimum is 90


* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.

BUILD FAILED in 2s
55 actionable tasks: 50 executed, 5 up-to-date
Configuration cache entry reused.

when running the JVM variant

❯ ./gradlew clean koverVerifyJvm
Reusing configuration cache.

BUILD SUCCESSFUL in 1s
19 actionable tasks: 15 executed, 4 up-to-date
Configuration cache entry reused.

Expected behavior
Both should give the same result, since in my project, all code is on common source set

Reproducer
Kover config on root build.gradle.kts

dependencies {
    kover(project(":compose")) // compose is the shared module
}

kover {
    reports {
        filters {
            excludes {
                classes(
                    "Res*",
                )

                packages("is_cidadao.compose.generated.resources")
            }
        }

        verify {
            rule {
                disabled = false
                bound {
                    minValue = 90
                    coverageUnits = CoverageUnit.LINE
                    aggregationForGroup = AggregationType.COVERED_PERCENTAGE
                }

                bound {
                    minValue = 90
                    coverageUnits = CoverageUnit.INSTRUCTION
                    aggregationForGroup = AggregationType.COVERED_PERCENTAGE
                }

                bound {
                    minValue = 90
                    coverageUnits =  CoverageUnit.BRANCH
                    aggregationForGroup = AggregationType.COVERED_PERCENTAGE
                }
            }
        }
    }
}

on compose build gradle file I have the Kover plugin applied like..

// ./compose/build.gradle.kts
plugins {
    ...
    alias(libs.plugins.kover)
    ...
}

Reports
If applicable, report files or screenshots.

Environment

  • Kover Gradle Plugin version: 0.8.3
  • Gradle version: 8.7
  • Kotlin project type: Kotlin/Multiplatform
  • Coverage Toolset (if customized in build script): Kover
  • Other context important for this bug: [e.g. OS version]
@MessiasLima MessiasLima added Bug Bug issue type S: untriaged Status: issue reported but unprocessed labels Aug 7, 2024
@shanshin
Copy link
Collaborator

shanshin commented Aug 7, 2024

Hi, could you clarify, is there Android build variants in your project?

@MessiasLima
Copy link
Author

MessiasLima commented Aug 7, 2024

Hi, could you clarify, is there Android build variants in your project?

Hi! I currently have Android, JVM (Desktop) and iOS targets.

@shanshin
Copy link
Collaborator

shanshin commented Aug 7, 2024

Is there a jvm target in the root project?

I recommend using the full path to run tasks.

If in your case the verification rules are written in the root project, then you need to call the verification task only for this root report (:koverVerifyJvm).

If you write it down in a simple form ./gradlew clean koverVerifyJvm, then the task named koverVerifyJvm will be executed in all projects in which it is present. But for example, it may not be present in the root project, so the verification rules will not be taken into account

@MessiasLima
Copy link
Author

MessiasLima commented Aug 12, 2024

When I run :koverVerifyJvm it says this task does not exists

I created a project as a minimal setup to reproduce de issue. Could you please check it? https://github.com/MessiasLima/kover-verify-jvm-issue

@shanshin
Copy link
Collaborator

shanshin commented Aug 12, 2024

When I run :koverVerifyJvm it says this task does not exists

Yes, this is expected because there are no jvm targets in the root project.
To create merged reports, it is necessary that all projects have the same report variant.

If there are different report variants in different projects, the easiest way is to create a custom common variant, as in the example.

As well as an alternative, consider using the Aggregation settings plugin plugin. It is easier to use, however, at the moment there are no some settings, and so far there is no validation (will be added in the next release)

@shanshin shanshin added Question Support request issue type S: in progress Status: implementing or design in process and removed Bug Bug issue type S: untriaged Status: issue reported but unprocessed labels Aug 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Question Support request issue type S: in progress Status: implementing or design in process
Projects
None yet
Development

No branches or pull requests

2 participants