简体   繁体   English

不同的 jacoco 覆盖导致 github 动作环境

[英]Different jacoco coverage results in a github action environment

is there any reason for a jacoco coverage report to produce different results when running it in a CI environment? jacoco 覆盖率报告在 CI 环境中运行时是否有任何理由产生不同的结果?

I have the following situation after migrating to Java 17. when I run ./gradlew clean build the report is generated and the jacocoTestCoverageVerification doesnt fail.迁移到 Java 17 后,我遇到以下情况。当我运行./gradlew clean build时,会生成报告并且jacocoTestCoverageVerification不会失败。

But when the same command is executed in a github runner I have a very different result, the coverage report is also created with different coverage values and some classes just fail the coverage verification.但是,当在 github 跑步者中执行相同的命令时,我得到了非常不同的结果,覆盖率报告也使用不同的覆盖率值创建,并且某些类只是未能通过覆盖率验证。

Unfortunately, I cannot provide code snippets but I already tried this:不幸的是,我无法提供代码片段,但我已经尝试过:

  • Run the github runner on my machine, with the same jdk and it produces a different result if I just run the build in the command line:(在我的机器上运行 github 运行程序,使用相同的 jdk,如果我只是在命令行中运行构建,它会产生不同的结果:(
  • add jvmargs noverify for tests tasks为测试任务添加 jvmargs noverify
  • run the github action in a container instead of a self-hosted, same result在容器中运行 github 操作而不是自托管,结果相同
  • other devs have also built the project on different machines without error其他开发人员也在不同的机器上构建了该项目而没有错误
  • run the same build command of the ci运行与 ci 相同的构建命令

So it seems that something in a github action env produces this behavior.所以似乎 github 动作环境中的某些东西会产生这种行为。

versions:版本:

  • jacoco plugin: 0.8.7 jacoco 插件:0.8.7
  • gradle 7.3 gradle 7.3
  • java 17 java 17

The problem here was lombok config files.这里的问题是 lombok 配置文件。 It turns out that the new version of lombok plugin compatible with java 17 and Gradle 7.3 does not generate the lombok.config files anymore.事实证明,与 java 17 和 Gradle 7.3 兼容的新版 lombok 插件不再生成lombok.config文件。

In the previous version, these files were generated by io.freefair.lombok plugin, and we had them in.gitignore.在以前的版本中,这些文件是由io.freefair.lombok插件生成的,我们将它们放在.gitignore 中。 Because of that, a local build worked just fine, since the files were still there.因此,本地构建工作得很好,因为文件仍然存在。

I realized this by looking at the generated reports and I noticed that lombok classes were being analyzed only by the CI.我通过查看生成的报告意识到了这一点,我注意到 lombok 类仅由 CI 分析。

In other cases, a similar problem could be related to this: https://www.eclemma.org/jacoco/trunk/doc/classids.html在其他情况下,类似的问题可能与此有关: https://www.eclemma.org/jacoco/trunk/doc/classids.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM