Coveralls GitHub Action – 错误: 找不到 Lcov 文件

huangapple go评论163阅读模式
英文:

Coveralls GitHub Action - Error: Lcov file not found

问题

我正在使用 GitHub Action 配置 Coveralls。

我搜索了,但是我找不到应该如何生成 ./coverage/lcov.info 文件的方法。
当操作运行时,由于我没有这个文件,我会得到:

  1. 使用 lcov 文件:./coverage/lcov.info
  2. 错误:找不到 Lcov 文件。

我尝试使用 IntelliJ 进行覆盖测试,但是我能够生成的唯一导出格式是 HTML 格式。

我如何生成 lcov.info 文件?

编辑 - 根据评论添加我的工作流程以供参考

  1. # 对于大多数项目,此工作流文件不需要更改;您只需将其提交到您的存储库。
  2. #
  3. # 您可能希望修改此文件以覆盖要分析的语言集,
  4. # 或提供自定义查询或构建逻辑。
  5. name: "CodeQL"
  6. on:
  7. push:
  8. branches: [master]
  9. pull_request:
  10. # 下面的分支必须是上面的分支的子集
  11. branches: [master]
  12. schedule:
  13. - cron: '0 14 * * 4'
  14. jobs:
  15. analyze:
  16. name: Analyze
  17. runs-on: ubuntu-latest
  18. strategy:
  19. fail-fast: false
  20. matrix:
  21. # 通过更改以下列表来覆盖自动语言检测
  22. # 支持的选项有 ['csharp', 'cpp', 'go', 'java', 'javascript', 'python']
  23. language: ['java']
  24. # 了解更多...
  25. # https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#overriding-automatic-language-detection
  26. java: [11]
  27. steps:
  28. - name: Checkout repository
  29. uses: actions/checkout@v2
  30. with:
  31. # 我们必须至少获取直接父级,以便如果这是一个拉取请求,我们可以检出头部。
  32. fetch-depth: 2
  33. # 如果此运行是由拉取请求事件触发的,则检出
  34. # 拉取请求的头部,而不是合并提交。
  35. - run: git checkout HEAD^2
  36. if: ${{ github.event_name == 'pull_request' }}
  37. - name: Set up Java JDK
  38. uses: actions/setup-java@v1
  39. with:
  40. java-version: ${{ matrix.java }}
  41. # 初始化用于扫描的 CodeQL 工具。
  42. - name: Initialize CodeQL
  43. uses: github/codeql-action/init@v1
  44. with:
  45. languages: ${{ matrix.language }}
  46. # 如果您想指定自定义查询,可以在此处或配置文件中执行。
  47. # 默认情况下,此处列出的查询将覆盖在配置文件中指定的任何查询。
  48. # queries: ./path/to/local/query, your-org/your-repo/queries@main
  49. # Autobuild 尝试构建任何编译语言(C/C++、C# 或 Java)。
  50. # 如果此步骤失败,则应删除它并手动运行构建(见下文)
  51. - name: Autobuild
  52. uses: github/codeql-action/autobuild@v1
  53. # ℹ️ 使用操作系统 shell 运行的命令行程序。
  54. # 📚 https://git.io/JvXDl
  55. # ✏️ 如果上面的 Autobuild 失败,请删除它,并取消下面三行的注释
  56. # 并修改它们(或添加更多)以构建您的代码,如果您的项目
  57. # 使用编译语言
  58. #- run: |
  59. # make bootstrap
  60. # make release
  61. - name: 执行 CodeQL 分析
  62. uses: github/codeql-action/analyze@v1
英文:

I am configuring Coveralls using a GitHub Action.

I searched but I cannot find how I should be able to generate the ./coverage/lcov.info file.
When the action runs, since I don't have such file, I get:

  1. Using lcov file: ./coverage/lcov.info
  2. Error: Lcov file not found.

I tried running test with Coverage via IntelliJ but the only export I can produce is in HTML format.

How can I generate the lcov.info file?

Edit - Adding my workflow for reference, as requested in comments

  1. # For most projects, this workflow file will not need changing; you simply need
  2. # to commit it to your repository.
  3. #
  4. # You may wish to alter this file to override the set of languages analyzed,
  5. # or to provide custom queries or build logic.
  6. name: "CodeQL"
  7. on:
  8. push:
  9. branches: [master]
  10. pull_request:
  11. # The branches below must be a subset of the branches above
  12. branches: [master]
  13. schedule:
  14. - cron: '0 14 * * 4'
  15. jobs:
  16. analyze:
  17. name: Analyze
  18. runs-on: ubuntu-latest
  19. strategy:
  20. fail-fast: false
  21. matrix:
  22. # Override automatic language detection by changing the below list
  23. # Supported options are ['csharp', 'cpp', 'go', 'java', 'javascript', 'python']
  24. language: ['java']
  25. # Learn more...
  26. # https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#overriding-automatic-language-detection
  27. java: [11]
  28. steps:
  29. - name: Checkout repository
  30. uses: actions/checkout@v2
  31. with:
  32. # We must fetch at least the immediate parents so that if this is
  33. # a pull request then we can checkout the head.
  34. fetch-depth: 2
  35. # If this run was triggered by a pull request event, then checkout
  36. # the head of the pull request instead of the merge commit.
  37. - run: git checkout HEAD^2
  38. if: ${{ github.event_name == 'pull_request' }}
  39. - name: Set up Java JDK
  40. uses: actions/setup-java@v1
  41. with:
  42. java-version: ${{ matrix.java }}
  43. # Initializes the CodeQL tools for scanning.
  44. - name: Initialize CodeQL
  45. uses: github/codeql-action/init@v1
  46. with:
  47. languages: ${{ matrix.language }}
  48. # If you wish to specify custom queries, you can do so here or in a config file.
  49. # By default, queries listed here will override any specified in a config file.
  50. # Prefix the list here with "+" to use these queries and those in the config file.
  51. # queries: ./path/to/local/query, your-org/your-repo/queries@main
  52. # Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
  53. # If this step fails, then you should remove it and run the build manually (see below)
  54. - name: Autobuild
  55. uses: github/codeql-action/autobuild@v1
  56. # ℹ️ Command-line programs to run using the OS shell.
  57. # 📚 https://git.io/JvXDl
  58. # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
  59. # and modify them (or add more) to build your code if your project
  60. # uses a compiled language
  61. #- run: |
  62. # make bootstrap
  63. # make release
  64. - name: Perform CodeQL Analysis
  65. uses: github/codeql-action/analyze@v1

答案1

得分: 1

在GitHub Actions上,我遇到了相同的错误(请参阅此构建日志),但我有一个略微不同的GitHub Action workflow.yml(在Java / Maven设置中可能更加“默认”):

  1. name: build
  2. on: [push]
  3. jobs:
  4. coverage:
  5. runs-on: ubuntu-latest
  6. steps:
  7. - uses: actions/checkout@v2
  8. - uses: actions/setup-java@v1
  9. with:
  10. java-version: 15
  11. - run: mvn -B test -P coverage --no-transfer-progress
  12. - uses: coverallsapp/github-action@master
  13. with:
  14. github-token: ${{ secrets.GITHUB_TOKEN }}

并且在我的pom.xml中有以下配置,用于jacoco-maven-plugincoveralls-maven-plugin

  1. <profiles>
  2. <profile>
  3. <id>coverage</id>
  4. <build>
  5. <plugins>
  6. <plugin>
  7. <groupId>org.jacoco</groupId>
  8. <artifactId>jacoco-maven-plugin</artifactId>
  9. <version>${build-plugin.jacoco.version}</version>
  10. <executions>
  11. <!-- Prepares the property pointing to the JaCoCo
  12. runtime agent which is passed as VM argument when Maven the Surefire plugin
  13. is executed. -->
  14. <execution>
  15. <id>pre-unit-test</id>
  16. <goals>
  17. <goal>prepare-agent</goal>
  18. </goals>
  19. </execution>
  20. <!-- Ensures that the code coverage report for
  21. unit tests is created after unit tests have been run. -->
  22. <execution>
  23. <id>post-unit-test</id>
  24. <phase>test</phase>
  25. <goals>
  26. <goal>report</goal>
  27. </goals>
  28. </execution>
  29. </executions>
  30. </plugin>
  31. <plugin>
  32. <groupId>org.eluder.coveralls</groupId>
  33. <artifactId>coveralls-maven-plugin</artifactId>
  34. <version>${build-plugin.coveralls.version}</version>
  35. </plugin>
  36. </plugins>
  37. </build>
  38. </profile>
  39. </profiles>

经过一些调查,我发现了这个问题,其中提到 基本上目前coverallsapp/github-action不支持使用JaCoCo进行Coveralls操作。

因此,我别无选择,只能切换到https://codecov.io 并使用匹配的https://github.com/codecov/codecov-action(就像cucumber-jvm团队也这样做了)。我们可以从pom.xml中删除coveralls-maven-plugin。我的workflow.yml现在如下所示:

  1. name: build
  2. on: [push]
  3. jobs:
  4. coverage:
  5. runs-on: ubuntu-latest
  6. steps:
  7. - uses: actions/checkout@v2
  8. - uses: actions/setup-java@v1
  9. with:
  10. java-version: 15
  11. - run: mvn -B test -P coverage --no-transfer-progress
  12. - uses: codecov/codecov-action@v1
  13. with:
  14. file: ./**/target/site/jacoco/jacoco.xml
  15. name: codecov

这里还有一个完整的示例项目:https://github.com/codecentric/cxf-spring-boot-starter/blob/master/.github/workflows/build.yml,在这个项目中我已经成功使用了codegov。

英文:

I had the same error on GitHub Actions (see this build log), but I had a slightly different GitHub Action workflow.yml (which is maybe a bit more "default" in a Java / Maven setup):

  1. name: build
  2. on: [push]
  3. jobs:
  4. coverage:
  5. runs-on: ubuntu-latest
  6. steps:
  7. - uses: actions/checkout@v2
  8. - uses: actions/setup-java@v1
  9. with:
  10. java-version: 15
  11. - run: mvn -B test -P coverage --no-transfer-progress
  12. - uses: coverallsapp/github-action@master
  13. with:
  14. github-token: ${{ secrets.GITHUB_TOKEN }}

And given the following configuration inside my pom.xml for the jacoco-maven-plugin and coveralls-maven-plugin:

  1. &lt;profiles&gt;
  2. &lt;profile&gt;
  3. &lt;id&gt;coverage&lt;/id&gt;
  4. &lt;build&gt;
  5. &lt;plugins&gt;
  6. &lt;plugin&gt;
  7. &lt;groupId&gt;org.jacoco&lt;/groupId&gt;
  8. &lt;artifactId&gt;jacoco-maven-plugin&lt;/artifactId&gt;
  9. &lt;version&gt;${build-plugin.jacoco.version}&lt;/version&gt;
  10. &lt;executions&gt;
  11. &lt;!-- Prepares the property pointing to the JaCoCo
  12. runtime agent which is passed as VM argument when Maven the Surefire plugin
  13. is executed. --&gt;
  14. &lt;execution&gt;
  15. &lt;id&gt;pre-unit-test&lt;/id&gt;
  16. &lt;goals&gt;
  17. &lt;goal&gt;prepare-agent&lt;/goal&gt;
  18. &lt;/goals&gt;
  19. &lt;/execution&gt;
  20. &lt;!-- Ensures that the code coverage report for
  21. unit tests is created after unit tests have been run. --&gt;
  22. &lt;execution&gt;
  23. &lt;id&gt;post-unit-test&lt;/id&gt;
  24. &lt;phase&gt;test&lt;/phase&gt;
  25. &lt;goals&gt;
  26. &lt;goal&gt;report&lt;/goal&gt;
  27. &lt;/goals&gt;
  28. &lt;/execution&gt;
  29. &lt;/executions&gt;
  30. &lt;/plugin&gt;
  31. &lt;plugin&gt;
  32. &lt;groupId&gt;org.eluder.coveralls&lt;/groupId&gt;
  33. &lt;artifactId&gt;coveralls-maven-plugin&lt;/artifactId&gt;
  34. &lt;version&gt;${build-plugin.coveralls.version}&lt;/version&gt;
  35. &lt;/plugin&gt;
  36. &lt;/plugins&gt;
  37. &lt;/build&gt;
  38. &lt;/profile&gt;
  39. &lt;/profiles&gt;

After some digging into the topic I found this issue of the coverallsapp/github-action which says basically that there's no support for JaCoCo with the Coveralls Action right now.

Therefore I saw no other option than to switch to https://codecov.io and the matching https://github.com/codecov/codecov-action (like the cucumber-jvm Team also did). We can remove the coveralls-maven-plugin from our pom.xml. My workflow.yml now looks like this:

  1. name: build
  2. on: [push]
  3. jobs:
  4. coverage:
  5. runs-on: ubuntu-latest
  6. steps:
  7. - uses: actions/checkout@v2
  8. - uses: actions/setup-java@v1
  9. with:
  10. java-version: 15
  11. - run: mvn -B test -P coverage --no-transfer-progress
  12. - uses: codecov/codecov-action@v1
  13. with:
  14. file: ./**/target/site/jacoco/jacoco.xml
  15. name: codecov

Here's also the a fully comprehensible example project: https://github.com/codecentric/cxf-spring-boot-starter/blob/master/.github/workflows/build.yml where I use codegov successfully now.

答案2

得分: 0

相同的配置今天可以正常工作,我猜在 GitHub 的一侧做了一些更改。

英文:

The same identical configuration works today, I guess some changes were done on the GitHub side.

huangapple
  • 本文由 发表于 2020年10月5日 21:29:47
  • 转载请务必保留本文链接:https://go.coder-hub.com/64209601.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定