Instructions for Java/JaCoCo
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.
Also would like to know how to do this.
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.
This is probably going to become a bigger request now that GitHub Actions are open to the masses.
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...
Any update about this?
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?
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
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).
Wondering if there has been any update on this. Thanks
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).
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
@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).
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.
I'm going to close the issue, but feel free to reopen it or create a new one if you face any issues.