Using `report-only-changed-files` shows no files
psontag opened this issue · 8 comments
We have a repository with the following structure:
.
└── src
├── package1
├── package2
...
We use the following configuration for this action
- name: "Pytest coverage comment"
uses: "MishaKav/pytest-coverage-comment@main"
with:
title: "Unit Tests"
junitxml-title: "Unit Tests"
coverage-path-prefix: "src/package1/package1" # this fixes the links since this is the actual location of the files in the repo
report-only-changed-files: true
pytest-coverage-path: "artifacts/python-coverage/coverage-report.txt"
junitxml-path: "artifacts/unit-test-result/result.xml"
We run our tests in the src/package1
directory. After the tests are done we get the following comment on the PR:
As you can see the coverage report does not list any files, even though files were changed and the changed files are not fully covered by our tests.
Could the problem be that the files in the coverage report do not have the "src/package1/package1"
prefix which is required to actually map them to the correct files in the repository and therefore the changed file detection of this action is not working correctly? E.g
- We changed the
src/package1/package1/main.py
and it is not covered by tests - It will show up as
main.py
in the coverage report - When we look at the changed files we only see that the
src/package1/package1/main.py
notmain.py
so it
is not included in the report
This issue is stale because it has been open 30 days with no activity
Hi @MishaKav
I suspect that I'm running into either this or a similar issue. I'm running with these settings, but don't see any lines in the coverage comment:
with:
hide-comment: false
report-only-changed-files: true
create-new-comment: true
I've confirmed that the "Changed files" pull-down in the Actions output shows a list of Python files that I've changed (shown here with light redaction):
Changed files
Base commit: 1e..7f
Head commit: 7f...43
All: .github/workflows/test.yml,path/file1.py, path/file2.py, path/file3.py
Added:
Modified: .github/workflows/test.yml, path/file1.py, path/file2.py, path/file3.py
Removed:
Renamed:
Added or modified: .github/workflows/test.yml, path/file1.py, path/file2.py, path/file3.py
But the resulting comment shows no changes:
Coverage
Coverage Report •
File Stmts Miss Cover Missing
TOTAL 18364 5678 69%
report-only-changed-files is enabled. No files were changed during this commit :)
The associated logic appears to be in the toTable
method: https://github.com/MishaKav/pytest-coverage-comment/blob/main/src/parse.js#L245
But I didn't trace any further to see whether the filtering logic was accidentally filtering out all the files.
the login for filtering files is here:
Just want to mention report-only-changed-files
:
- on
pull_request
event, it counts all changed files in the PR - on
push
event, it counts only files that changed in the current commit
To give you more help I need to look at the files that were generated in Changed files
vs pytest-coverage.txt
...
(@andrzej-agathos as FYI)
Thanks @MishaKav for the quick response!
I'm looking a little closer at the output in my log.
As a concrete example, I see this string in the output of "Changed Files":
processing/consolidate/tasks/decode.py
The corresponding output that gets captured into pytest-coverage.txt is this:
processing/consolidate/tasks/decode.py 90 22 76% 83, 87-91, 94-118, 127-134
So, it appears that there is an exact string match for the filename in both of these cases.
Hi @MishaKav , was that enough context, or should I add additional information? Thanks!
Success to reproduce the bug, made a fix, you can try the last version @v1.1.35
ar the @main
- name: Pytest Coverage Comment
uses: MishaKav/pytest-coverage-comment@main
or use specific version
- name: Pytest Coverage Comment
uses: MishaKav/pytest-coverage-comment@v1.1.35
Thanks a bunch @MishaKav ! I've confirmed from recent runs of this GitHub action that we're now seeing coverage on changed files in comments!