cicirello / jacoco-badge-generator

Coverage badges, and pull request coverage checks, from JaCoCo reports in GitHub Actions
https://actions.cicirello.org/jacoco-badge-generator/
MIT License
101 stars 42 forks source link

Add Code Coverage badge example repo #19

Closed nachg closed 3 years ago

nachg commented 3 years ago

It will be great to have any link to the working example

cicirello commented 3 years ago

I'm using it myself in multiple repositories. Would adding a link to the following work as an example: example workflow and the maven pom.xml? In that project, I have jacoco configured in a profile in the pom.xml. Or are you looking for a more minimal example?

nachg commented 3 years ago

I think it will be enough. I have injected your badge into my project: https://github.com/nachg/xpathqs also. It is working great! My suggestion is to add an example badge snippet to the readme.md with the default config: [![Coverage](.github/badges/jacoco.svg)](jacoco.svg)

And add an example of committing changes in the most simple way (buid.yml):

  - name: Commit changes
        uses: EndBug/add-and-commit@v7
        with:
          default_author: github_actions
          message: 'upload badge'
          add: '*.svg'
cicirello commented 3 years ago

@nachg Great documentation suggestions. Thanks. I noticed that your project uses gradle. If you don't mind, I might link to it to have an example of a gradle project that is using the action. All of my projects use maven. In the examples of my own projects that I just linked to, I linked directly to the relevant workflow as well as to the maven pom.xml to make it easy to see how jacoco is configured. I don't use gradle, so not sure what gradle's equivalent is. Where are plugins configured in gradle?

nachg commented 3 years ago

If you don't mind, I might link to it to have an example of a gradle project

Sure, it will be great!

Where are plugins configured in gradle?

In build.gradle.kts. There are just two simple steps required To add Jacoco as a plugin:

plugins {
    jacoco
}

And to enable .csv (which is required for the jacoco-badge-generator):

tasks.jacocoTestReport {
    reports {
        csv.isEnabled = true
    }
}

And jobs/steps example:

      - name: Run Tests
        run: ./gradlew test

      - name: Run Test Coverage
        run: ./gradlew jacocoTestReport

      - name: Generate JaCoCo Badge
        id: jacoco
        uses: cicirello/jacoco-badge-generator@v2.1.0
        with:
          generate-branches-badge: true
          jacoco-csv-file: build/reports/jacoco/test/jacocoTestReport.csv