Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

only_changed_files option not working #88

Open
PascalArdex opened this issue Sep 4, 2023 · 4 comments
Open

only_changed_files option not working #88

PascalArdex opened this issue Sep 4, 2023 · 4 comments

Comments

@PascalArdex
Copy link

PascalArdex commented Sep 4, 2023

I have a dotnet / C# project using 5monkeys/cobertura-action@v13, it works great with default values

Just tried to add the option only_changed_files: true as the project is getting bigger but it does not seem to have any effect.
More precisely, the report is still created but only shows the header line for All files
Screenshot 2023-09-04 at 13-36-14 epona_ github_workflows at main · ardextech_epona

Here is an extract of my GitHub workflow

  test:
    runs-on: ubuntu-latest
    permissions:
      statuses: write
      checks: write
      contents: write
      pull-requests: write
      actions: write
    steps:
    - uses: actions/checkout@v3
    - name: Setup .NET
      uses: actions/setup-dotnet@v3
      with:
        dotnet-version: 7.0.x
    - name: Test
      run: dotnet test --logger "trx;LogFileName=test-results.trx" --collect:"XPlat Code Coverage"
    - name: Coverage Report
      uses: 5monkeys/cobertura-action@v13
      with:
        path: backend-api/tests/TestResults/*/*.xml
        minimum_coverage: 70
        skip_covered: false
        show_line: true
        show_branch: true
        show_class_names: false
        only_changed_files: true

Action executes without any problem
Screenshot 2023-09-04 at 14-23-38 EPN-34 Generate and Send New User Invite Email · ardextech_epona@9a3c2ae

@PascalArdex PascalArdex changed the title only_changed_files option not working only_changed_files option not working Sep 4, 2023
@arturs-at-levelpath
Copy link

Having exactly the same problem.

@PascalArdex
Copy link
Author

I found the following ugly workaround (since I don't really know how to debug GitHub actions)

    - name: Pre-processing Coverage Report
      run: sed -i 's#filename="#filename="backend-api/src/#g' tests/TestResults/*/*.xml
    - name: Coverage Report
      uses: 5monkeys/cobertura-action@v13
      ...

I backtracked to the following line

(file) => filteredFiles == null || filteredFiles.includes(file.filename)

In order to work as expected, the action needs to find an exact match between the filename found in the XML report and the list of files in the pull request.

Now a very likely structure for dotnet projects using XUnit is to have a top level solution file and two folders src and tests.
In my case I am using a mono-repo structure so it is even more complex than that.

The filenames matching could be more complex.
We can compute the absolute path to the filename attributes in the XML using the tag.

Anyway, just wanted to say this GitHub action is awesome!!!
And I don't understand why Microsoft is not doing first class citizen actions for dotnet but that's another story....

@arturs-at-levelpath
Copy link

We are using monorepo as well on our end and it seems like this PR fixes all issues and it works fine.

#74

Problem it seems is getting it in main branch 😞

@LensArt
Copy link

LensArt commented May 14, 2024

I encountered the same issue, is there a plan to fix this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants