Skip to content

Jacoco Gradle plugin does not restore coverage reports when using Gradle cache #35008

Open
@FWest98

Description

Describe the bug

I am using the quarkus-jacoco plugin in my CI/CD pipeline to automatically generate coverage reports for my tests. This works fine: I can parse build/jacoco-report/jacoco.xml and have GitLab CI interpret it following their example: https://docs.gitlab.com/ee/ci/testing/test_coverage_visualization.html#gradle-example

However, this breaks as soon as there are no changes in the code (for example, when configuring the CI or a test job is rerun). Then, Gradle will restore the test results from its cache, as expected, but it won't regenerate or restore the jacoco report. My CI job then fails since the coverage report cannot be found - even though all tests still pass.

Example output log:

> Task :test FROM-CACHE
Custom actions are attached to task ':test'.
Build cache key for task ':test' is 4436b1405b237673aa70cf1d45994e91
Task ':test' is not up-to-date because:
  No history is available.
Loaded cache entry for task ':test' with cache key 4436b1405b237673aa70cf1d45994e91

....

BUILD SUCCESSFUL in 17s
7 actionable tasks: 2 executed, 5 from cache

......

Uploading artifacts...
WARNING: build/jacoco-report/jacoco.xml: no matching files. Ensure that the artifact path is relative to the working directory (/builds/foo/bar/path) 
ERROR: No files to upload

Is this scenario unsupported? Or how do I deal with this?

How to Reproduce?

On a Gradle project with the jacoco plugin enabled following the Quarkus instructions, do the following:

  • Run ./gradlew --build-cache test
  • Check that indeed build/jacoco-report exists
  • Run rm -r build to remove the build folder
  • Again run ./gradlew --build-cache test
  • Check that the test results in build/test-results have been restored, but that build/jacoco-report is missing.

Output of java -version

openjdk version "17.0.7" 2023-04-18

Quarkus version or git rev

3.2.2.Final

Build tool (ie. output of mvnw --version or gradlew --version)

Gradle 8.1.1

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions