Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Coveralls GitHub Action - Error: Lcov file not found

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:

Using lcov file: ./coverage/lcov.info  
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

# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
name: "CodeQL"

on:
  push:
    branches: [master]
  pull_request:
    # The branches below must be a subset of the branches above
    branches: [master]
  schedule:
    - cron: '0 14 * * 4'

jobs:
  analyze:
    name: Analyze
    runs-on: ubuntu-latest

    strategy:
      fail-fast: false
      matrix:
        # Override automatic language detection by changing the below list
        # Supported options are ['csharp', 'cpp', 'go', 'java', 'javascript', 'python']
        language: ['java']
        # Learn more...
        # https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#overriding-automatic-language-detection
        java: [11]

    steps:
    - name: Checkout repository
      uses: actions/checkout@v2
      with:
        # We must fetch at least the immediate parents so that if this is
        # a pull request then we can checkout the head.
        fetch-depth: 2

    # If this run was triggered by a pull request event, then checkout
    # the head of the pull request instead of the merge commit.
    - run: git checkout HEAD^2
      if: ${{ github.event_name == 'pull_request' }}

    - name: Set up Java JDK
      uses: actions/setup-java@v1
      with:
        java-version: ${{ matrix.java }}

    # Initializes the CodeQL tools for scanning.
    - name: Initialize CodeQL
      uses: github/codeql-action/init@v1
      with:
        languages: ${{ matrix.language }}
        # If you wish to specify custom queries, you can do so here or in a config file.
        # By default, queries listed here will override any specified in a config file. 
        # Prefix the list here with "+" to use these queries and those in the config file.
        # queries: ./path/to/local/query, your-org/your-repo/queries@main

    # Autobuild attempts to build any compiled languages  (C/C++, C#, or Java).
    # If this step fails, then you should remove it and run the build manually (see below)
    - name: Autobuild
      uses: github/codeql-action/autobuild@v1

    # ℹī¸ Command-line programs to run using the OS shell.
    # 📚 https://git.io/JvXDl

    # ✏ī¸ If the Autobuild fails above, remove it and uncomment the following three lines
    #    and modify them (or add more) to build your code if your project
    #    uses a compiled language

    #- run: |
    #   make bootstrap
    #   make release

    - name: Perform CodeQL Analysis
      uses: github/codeql-action/analyze@v1
like image 962
Pitto Avatar asked Oct 05 '20 13:10

Pitto


1 Answers

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):

name: build

on: [push]

jobs:
  coverage:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-java@v1
        with:
          java-version: 15
      - run: mvn -B test -P coverage --no-transfer-progress

      - uses: coverallsapp/github-action@master
        with:
          github-token: ${{ secrets.GITHUB_TOKEN }}

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

<profiles>
    <profile>
        <id>coverage</id>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.jacoco</groupId>
                    <artifactId>jacoco-maven-plugin</artifactId>
                    <version>${build-plugin.jacoco.version}</version>
                    <executions>
                        <!-- Prepares the property pointing to the JaCoCo
                        runtime agent which is passed as VM argument when Maven the Surefire plugin
                        is executed. -->
                        <execution>
                            <id>pre-unit-test</id>
                            <goals>
                                <goal>prepare-agent</goal>
                            </goals>
                        </execution>
                        <!-- Ensures that the code coverage report for
                        unit tests is created after unit tests have been run. -->
                        <execution>
                            <id>post-unit-test</id>
                            <phase>test</phase>
                            <goals>
                                <goal>report</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>org.eluder.coveralls</groupId>
                    <artifactId>coveralls-maven-plugin</artifactId>
                    <version>${build-plugin.coveralls.version}</version>
                </plugin>
            </plugins>
        </build>
    </profile>
</profiles>

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:

name: build

on: [push]

jobs:
  coverage:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-java@v1
        with:
          java-version: 15
      - run: mvn -B test -P coverage --no-transfer-progress

      - uses: codecov/codecov-action@v1
        with:
          file: ./**/target/site/jacoco/jacoco.xml
          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.

like image 91
jonashackt Avatar answered Nov 07 '22 02:11

jonashackt