github-action icon indicating copy to clipboard operation
github-action copied to clipboard

Instructions for Java/JaCoCo

Open lorenzleutgeb opened this issue 6 years ago • 10 comments

I am using kt3k/coveralls-gradle-plugin now, together with JaCoCo. I am trying to migrate my build to GitHub Actions. Running it with just the GitHub token configured, I get:

Run coverallsapp/github-action@master
Using lcov file: ./coverage/lcov.info
##[error]Lcov file not found.
##[error]Node run failed with exit code 1

Probably I need to point the GitHub action at the XML file generated by JaCoCo, but I don't know how.

lorenzleutgeb avatar Nov 11 '19 16:11 lorenzleutgeb

Also would like to know how to do this.

mkrakowitzer avatar Nov 13 '19 15:11 mkrakowitzer

I defined the path-to-lcov property, pointing it at my JaCoCo xml file and hoping it would just work. No luck. Judging from the error, it specifically needs LCOV input:

Using lcov file: ./back/build/reports/jacoco/test/jacocoTestReport.xml
[error] "2019-11-16T16:25:38.355Z"  'error from lcovParse: ' 'Failed to parse string'
[error] "2019-11-16T16:25:38.356Z"  'input: ' '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><!DOCTYPE report ' +

@nickmerwin is there any chance this will be expanded to support a range of reports more inline with what Coveralls has supported in the past? Guessing this was a choice to cover the most widely used tool first (Node e.g. lcov), and eventually loop back around for the rest of us.

jamesdh avatar Nov 16 '19 16:11 jamesdh

This is probably going to become a bigger request now that GitHub Actions are open to the masses.

jamesdh avatar Nov 16 '19 16:11 jamesdh

https://github.com/danielpalme/ReportGenerator looks like it could convert from jacoco to lcov. Not sure how to set it up, since it's .NET...

whiskeysierra avatar Nov 19 '19 10:11 whiskeysierra

Any update about this?

JavierSegoviaCordoba avatar Apr 03 '20 08:04 JavierSegoviaCordoba

This is also relevant to me. Currently, I use Jacoco gradle plugin. Jacoco not support output test report in lcov format! Can there be alternatives to Jacoco?

eaxdev avatar Jun 07 '20 11:06 eaxdev

I am running coveralls using the following actions:

    - env:
        BRANCH_NAME_OR_REF: ${{ github.head_ref || github.ref }}
      run: echo "::set-env name=BRANCH_NAME::${BRANCH_NAME_OR_REF#refs/heads/}"
    - run: |
        echo "::set-env name=PR_NUMBER::$(jq --raw-output .pull_request.number "$GITHUB_EVENT_PATH")"
    - name: Coveralls Maven plugin
      run: |
        mvn coveralls:report \
        --no-transfer-progress \
        -D repoToken=${{ secrets.COVERALLS_TOKEN }} \
        -D serviceName=github \
        -D serviceBuildUrl=https://github.com/${{ github.repository }}/commit/${{ github.sha }}/checks \
        -D branch=$BRANCH_NAME \
        -D pullRequest=$PR_NUMBER

Only issue is the branch command line argument gets set to the commit hash when built from a detached head. See here: https://github.com/trautonen/coveralls-maven-plugin/issues/136#issuecomment-664679270

derekm avatar Jul 27 '20 23:07 derekm

This is also a problem for @yonatankarp and me. We are using Jacoco and need to be able to feed our XML report to Coveralls (Jacoco seems not to support the lcov file format).

bixu avatar Oct 13 '20 17:10 bixu

Wondering if there has been any update on this. Thanks

keith-miller avatar Jan 21 '21 20:01 keith-miller

If the coveralls GitHub action does not support JaCoCo and Java atm, it seems one is forced to switch to https://about.codecov.io/ (as for example done at cucumber-jvm: https://github.com/cucumber/cucumber-jvm/blob/main/.github/workflows/build.yml).

jonashackt avatar Feb 07 '21 16:02 jonashackt

I was able to get coveralls working with jacoco in github actions. You need to set a COVERALLS_REPO_TOKEN secret environment variable.

Here's a reference pull request https://github.com/samrocketman/jervis/pull/155

samrocketman avatar Jan 26 '23 07:01 samrocketman

@jamesdh it is; people are here to be productive and filed this issue because they wanted code coverage. So while this action lacks features I provided a workaround for those who want code coverage now and not wait for this issue to eventually support it (maybe not ever; this issue has been open for almost 3 years).

samrocketman avatar Feb 07 '23 19:02 samrocketman

Hey guys! New version of github action coverallsapp/github-action@v2 provides the support for Jacoco format. Please, try it out.

Configuration example:

- name: Coveralls
  uses: coverallsapp/github-action@v2
  with:
    # *base-path* is prepended to all paths in order to correctly reference source files on coveralls.io
    base-path: src/main/java 
    
    # *file* is optional, but good to have. By default coveralls will try to find the report automatically.
    file: target/jacoco-report/jacoco.xml

Please note that v2 is a pre-release. If you notice any issues please write about them, I'll fix them as soon as possible.

mrexox avatar Mar 07 '23 11:03 mrexox

I'm going to close the issue, but feel free to reopen it or create a new one if you face any issues.

mrexox avatar Mar 08 '23 09:03 mrexox