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

Feature Req: Support glob to find jacoco csv files in multi module projects #112

Closed fwilhe closed 1 year ago

fwilhe commented 1 year ago

Hi @cicirello,

thanks for this great action, I think it is very useful.

I have one question/suggestion related to maven multi module projects.

Is your feature request related to a problem? Please describe.

In your example, all modules are listed. This works for a small number of modules, but introduces the risk that when a new module is added to the project, it is not added here.

Describe the solution you'd like

I think it would be nice if a glob pattern could be provided here instead of the full list like **/jacoco.csv.

Describe alternatives you've considered

It is possible to use this workaround, which is a bit verbose:

      - name: Find JaCoCo reports of modules
        run: |
          find . -name jacoco.csv
          echo "jacoco_csv_files=`find . -name jacoco.csv | tr '\n' ' '`" >> "$GITHUB_OUTPUT"
        id: find_jacoco
      - name: Generate JaCoCo Badge
        id: jacoco
        uses: cicirello/jacoco-badge-generator@v2
        with:
          generate-branches-badge: true
          jacoco-csv-file: >
            ${{ steps.find_jacoco.outputs.jacoco_csv_files }}

Additional context

Just an additional thought: Maybe it would even be nice to have a glob pattern as the default as opposed to 'target/site/jacoco/jacoco.csv', which should work for single and multi module projects. I don't see much downsides, except maybe that searching using the glob pattern will be a little slower as the hard coded default path.

Best, Florian

cicirello commented 1 year ago

@fwilhe thanks for the suggestion. This should be easy enough to support. I think that I'll keep the default as it is. Changing the default to a glob, once this is implemented, might break something for someone (e.g., if they have multiple modules and multiple jacoco reports, but only want to generate a coverage badge for one of them).

fwilhe commented 1 year ago

Yes, I see why changing the default might be a bad idea.

Looking forward to simplify my workflow 👍

cicirello commented 1 year ago

@fwilhe version v2.9.0 (or via the major version v2) that I released a few minutes ago now supports glob patterns. You'll need to put quotes around the glob pattern to avoid an "invalid workflow file" error from GitHub Actions. So you'd need jacoco-csv-file: "**/jacoco.csv". 🚀

fwilhe commented 1 year ago

Hi @cicirello, I've updated my workflow and it works, thanks for the quick update 💯