lucassabreu / comment-coverage-clover

Github Action that automatically adds a comment with a summary of coverage reports (clover)
https://github.com/marketplace/actions/coverage-report-as-comment-clover
17 stars 4 forks source link

Table links to wrong file (folder missing) #33

Closed klippx closed 1 year ago

klippx commented 1 year ago

I have a clover coverage xml on this format

<?xml version="1.0" encoding="UTF-8"?>
<coverage generated="1684932596677" clover="3.2.0">
  <project timestamp="1684932596677" name="All files">
    <metrics statements="794" coveredstatements="716" conditionals="252" coveredconditionals="178" methods="130" coveredmethods="106" elements="1176" coveredelements="1000" complexity="0" loc="794" ncloc="794" packages="8" files="24" classes="24"/>
    <package name="create-server">
      <metrics statements="39" coveredstatements="33" conditionals="14" coveredconditionals="7" methods="5" coveredmethods="5"/>
      <file name="response-cache-plugin.ts" path="/Users/MKLIPPIN/repos/graphql-federation-mono/dgs/environmental/create-server/response-cache-plugin.ts">
        <metrics statements="23" coveredstatements="23" conditionals="6" coveredconditionals="5" methods="2" coveredmethods="2"/>

I am running the GH Action with this config:

    - name: Coverage Report as Comment (Clover)
      uses: lucassabreu/comment-coverage-clover@v0.3.0
      with:
        github-token: '${{ secrets.GH_PAT }}'
        file: ./dgs/${{ inputs.service_name }}/coverage/clover.xml
        dir-prefix-keep: dgs/${{ inputs.service_name }}

So if we consider the path in clover which in my example is /Users/MKLIPPIN/repos/graphql-federation-mono then on CI it should be whatever, maybe it is /home/runner/work/graphql-federation-mono.

But when it generates the table all the links are wrong, it is completely missing folder:

https://github.com/%COMPANY%/graphql-federation-mono/blob/%sha%/dgs/environmental//response-cache-plugin.ts

, in this case it is missing the path segment create-server.

But if there are multiple levels of folder, it removes them all and replaces with emty string.

What's wrong? Something unexpected in my clover xml?

I have also tried experimenting with dir-prefix but not found anything that works.

Screenshot 2023-05-24 at 16 22 18

This is how my table looks, there is no folder information here either, perhaps a clue? It just appears as a flat structure, which is confusing when a lot of files are called index.ts

lucassabreu commented 1 year ago

i don't think the action accepts relative paths, instead of./dgs try ${{ github.workspace }}/dgs

it may fix the problem

later i will look into accepting relative paths

klippx commented 1 year ago

Thanks for reply! And I like your project, it has nice config options and Im happy that you are working with it actively.

I think it might be your assumption when you wrote the script, if we look at this example clover file https://github.com/lucassabreu/comment-coverage-clover/blob/main/clover.example.xml

<file name="/var/www/html/src/main/php/PHPMD/AbstractNode.php">

It doesn't look like mine:

<file name="index.ts" path="/Users/MKLIPPIN/repos/graphql-federation-mono/dgs/environmental/create-server/index.ts">

Since you have only seen everything in name you have had no reason to deal with the clover files that have split it into name and path?

My setup is that I run two different jest processes (integration and unit) which outputs istanbul json coverage reporter files. I then merge these two different files using nyc merge into a single json. Then I use nyc report to create a clover xml output from the final json which has the <file name=".." path=".."> format

Not super relevant but I am using very popular JS community tools here, if we can make it work for me then it will work for most JS/TS community members 🎉

lucassabreu commented 1 year ago

i did not saw the path attribute.

i will look into it later today

lucassabreu commented 1 year ago

@klippx on release v0.9.1 we added support for the path field, the person used jest and improved the code

since you are still at v0.3.0 the improvement is not there.

https://github.com/lucassabreu/comment-coverage-clover/releases/tag/v0.9.1

klippx commented 1 year ago

Houston, we have v0.9.1? When I look at marketplace 0.3.0 is the "latest" 😅 What's going on there, you might want to look into that.

Screenshot 2023-05-25 at 07 50 15

lucassabreu commented 1 year ago

looks like the marketplace does not pull the new releases automatically, i forced the update now.

lucassabreu commented 1 year ago

hi @klippx were you able to test it with the newest version?

klippx commented 1 year ago

The links now work perfectly, thanks!