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

Implemented protype of Kover Aggregated Plugin #644

Merged
merged 7 commits into from
Jun 26, 2024
Merged

Implemented protype of Kover Aggregated Plugin #644

merged 7 commits into from
Jun 26, 2024

Conversation

shanshin
Copy link
Collaborator

Relates #608


htmlDir.convention(layout.buildDirectory.dir("reports/kover/html"))

this.onlyIf {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason to use onlyIf for logging? Won't doFirst/doLast suit this purpose better?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because onlyIf always executed, even when the task does not start and the result is taken from the cache (FROM-CACHE outcome)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's worth plunking a comment describing it then


internal object KoverParametersProcessor {
fun process(settingsExtension: KoverSettingsExtensionImpl, providers: ProviderFactory) {
if (providers.gradleProperty("kover").isPresent) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it make sense to check support values for this property? For instance, suppose someone has a project where coverage was enabled using enableCoverage DSL's call, but a user now want's to explicitly disable it via CLI by passing -Pkover=false.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case, the users can write their own condition, like

kover {
    if (providers.gradleProperty("useCoverage").toBoolean() != true) {
        enableCoverage()
    }
}

:)

In general, this is a debatable question in DSL, whether it is worth giving the enable function enableCoverage() or property coverageIsEnabled

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the users can write their own condition

That requires committing some code to a repo, so if someone want to temporary disable code coverage collection in CI, it could be problematic.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in this case, we can add only -Pkover=false, so that there is -Pkover to turn on and -Pkover=false to turn off

settingsExtension.coverageIsEnabled.set(true)
}

settingsExtension.reports.includedProjects.readAppendableArgument(providers, "kover.classes.from")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess kover.classes.from should reads as "collect coverage for classes from following projects", but for me options like kover.classes.from.excludes and kover.classes.excludes are not easily distinguishable.
Did you consider naming package-related options as kover.packages.includes and kover.packaged.excludes?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The names are not final at all and this is the first thing that came to mind.
In any case, you can come up with a lot of spelling options and they are all likely to be similar to each other in one way or another (

There will most likely be no packages - this filter is duplicated classes, and instead of kover.classes.from, we can try kover.projects and kover.projects.excludes

kover-gradle-plugin/build.gradle.kts Outdated Show resolved Hide resolved
kover-gradle-plugin/docs/aggregated.md Show resolved Hide resolved
@shanshin shanshin requested a review from fzhinkin June 25, 2024 21:21
To use the plugin, just add into a `settings.gradle.kts` file
```kotlin
plugins {
id("org.jetbrains.kotlinx.kover.settings") version "0.8.1"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure that kover.settings conveys the meaning of the plugin. Yes, it is applied in settings, but its goals are 1) reduce configuration 2) instrument only test tasks that are currently run. We may want to eventually rename it, but I don't have any good name right now except kover.onthefly

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My option is org.jetbrains.kotlinx.kover.aggregation - because the feature of this plugin is that it can aggregate coverage from all subprojects

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that we have merge in regular setup which also does some kind of aggregation and various AggregationTypes, I'm afraid that this word is already overused :(

Copy link
Collaborator Author

@shanshin shanshin Jun 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In fact, this plugin has nothing to do with old Kover plugin, but it does exactly what merge says - it creates a aggregated reports

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, if I run ./gradlew :projectA:jvmTest -Pkover koverHtmlReport, it will show me only projectA's coverage, in that case there's no aggregation

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not quite. :projectA may depends on :projectB, thus the sources from these two projects will be aggregated in the report

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can live with aggregation for now, maybe we'll find better name later

excludedProjects.add(":b")

// -Pkover.classes.includes=classes.to.exclude.*
includedClasses.add("classes.to.include.*")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe there should also be inclusions/exclusions by annotation


override val reports: ReportsSettings = objects.newInstance<ReportsSettings>()

// abstract override val variants: NamedDomainObjectContainer<VariantI>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not needed anymore?


package kotlinx.kover.gradle.aggregation.settings.dsl.intern

internal abstract class KoverProjectExtensionImpl {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This class seems unnecessary

create("KoverSettingsPlugin") {
id = "org.jetbrains.kotlinx.kover.settings"
implementationClass = "kotlinx.kover.gradle.aggregation.settings.KoverSettingsGradlePlugin"
displayName = "Gradle Plugin for Kotlin Code Coverage Tools"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It has the same displayName and description as a regular plugin. Won't it be confusing?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed it a little

@shanshin shanshin merged commit e03bc8c into main Jun 26, 2024
1 check passed
@shanshin shanshin deleted the proto branch June 26, 2024 14:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants