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

Configuration Cache can not be used after one run #646

Closed
remcomokveld opened this issue Jun 27, 2024 · 2 comments · Fixed by #648
Closed

Configuration Cache can not be used after one run #646

remcomokveld opened this issue Jun 27, 2024 · 2 comments · Fixed by #648
Assignees
Labels
Bug Bug issue type S: ready for release Status: merged in the main branch

Comments

@remcomokveld
Copy link
Contributor

Describe the bug

When the configuration cache is enabled, the cache entry is always immediately invalidated after the first run

Errors
If present, stacktraces or files from build/kover/errors directory

Expected behavior

After invoking a command once, the configuration cache from the previous invocation should be reused

Reproducer

By applying the following patch to the project you can see that the configuration cache is not used in the first identical run because the test assertion fails

Index: kover-gradle-plugin/src/functionalTest/kotlin/kotlinx/kover/gradle/plugin/test/functional/cases/ConfigurationCacheTests.kt
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/kover-gradle-plugin/src/functionalTest/kotlin/kotlinx/kover/gradle/plugin/test/functional/cases/ConfigurationCacheTests.kt b/kover-gradle-plugin/src/functionalTest/kotlin/kotlinx/kover/gradle/plugin/test/functional/cases/ConfigurationCacheTests.kt
--- a/kover-gradle-plugin/src/functionalTest/kotlin/kotlinx/kover/gradle/plugin/test/functional/cases/ConfigurationCacheTests.kt	(revision 8ca086b84546bdac370b81039ad4444022b276b8)
+++ b/kover-gradle-plugin/src/functionalTest/kotlin/kotlinx/kover/gradle/plugin/test/functional/cases/ConfigurationCacheTests.kt	(date 1719476509768)
@@ -29,6 +29,14 @@
             "koverVerify",
             "--configuration-cache",
         )
+        run(
+            "build",
+            "koverXmlReport",
+            "koverHtmlReport",
+            "koverVerify",
+            "--configuration-cache",
+            checker = { output.match { assertContains("Reusing configuration cache.") } }
+        )
     }
 
     @GeneratedTest

In the output of this run you can see the following message

Calculating task graph as configuration cache cannot be reused because the file system entry 'build/kover/.artifact' has been created.

If you run the build three times, on the third attempt the configuration cache will be re-used, if you apply the patch below the test passes, but it should already be available after the first attempt.

Index: kover-gradle-plugin/src/functionalTest/kotlin/kotlinx/kover/gradle/plugin/test/functional/cases/ConfigurationCacheTests.kt
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/kover-gradle-plugin/src/functionalTest/kotlin/kotlinx/kover/gradle/plugin/test/functional/cases/ConfigurationCacheTests.kt b/kover-gradle-plugin/src/functionalTest/kotlin/kotlinx/kover/gradle/plugin/test/functional/cases/ConfigurationCacheTests.kt
--- a/kover-gradle-plugin/src/functionalTest/kotlin/kotlinx/kover/gradle/plugin/test/functional/cases/ConfigurationCacheTests.kt	(revision 8ca086b84546bdac370b81039ad4444022b276b8)
+++ b/kover-gradle-plugin/src/functionalTest/kotlin/kotlinx/kover/gradle/plugin/test/functional/cases/ConfigurationCacheTests.kt	(date 1719477172444)
@@ -29,6 +29,21 @@
             "koverVerify",
             "--configuration-cache",
         )
+        run(
+            "build",
+            "koverXmlReport",
+            "koverHtmlReport",
+            "koverVerify",
+            "--configuration-cache",
+        )
+        run(
+            "build",
+            "koverXmlReport",
+            "koverHtmlReport",
+            "koverVerify",
+            "--configuration-cache",
+            checker = { output.match { assertContains("Reusing configuration cache.") } }
+        )
     }
 
     @GeneratedTest

Environment

  • Kover Gradle Plugin version: 0.8.0
  • Gradle version: Any
  • Kotlin project type: Any
  • Coverage Toolset (if customized in build script): Kover only
  • Other context important for this bug: None
@remcomokveld remcomokveld added Bug Bug issue type S: untriaged Status: issue reported but unprocessed labels Jun 27, 2024
@shanshin shanshin added S: confirmed Status: bug is reproduced or present and removed S: untriaged Status: issue reported but unprocessed labels Jun 27, 2024
shanshin added a commit that referenced this issue Jun 27, 2024
Due to the fact that a file was used as task input, it was placed in the configuration cache as entry, and changing this file causes the cache invalidation.

Problem in line `localArtifact.set(variant.artifactGenTask.flatMap { task -> task.artifactFile })`.
flatMap function behaves strangely enough with the configuration cache, see also gradle/gradle#25645

Fixes #646
@shanshin
Copy link
Collaborator

Thanks for the report and the test!

shanshin added a commit that referenced this issue Jun 27, 2024
Due to the fact that a file was used as task input, it was placed in the configuration cache as entry, and changing this file causes the cache invalidation.

Problem in line `localArtifact.set(variant.artifactGenTask.flatMap { task -> task.artifactFile })`.
flatMap function behaves strangely enough with the configuration cache, see also gradle/gradle#25645

Fixes #646
shanshin added a commit that referenced this issue Jun 27, 2024
Due to the fact that a file was used as task input, it was placed in the configuration cache as entry, and changing this file causes the cache invalidation.

Problem in line `localArtifact.set(variant.artifactGenTask.flatMap { task -> task.artifactFile })`.
flatMap function behaves strangely enough with the configuration cache, see also gradle/gradle#25645

Fixes #646

PR #648
@shanshin shanshin reopened this Jun 27, 2024
@shanshin shanshin added S: ready for release Status: merged in the main branch and removed S: confirmed Status: bug is reproduced or present labels Jun 27, 2024
@shanshin
Copy link
Collaborator

Fixed in 0.8.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Bug issue type S: ready for release Status: merged in the main branch
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants