MishaKav/jest-coverage-comment

When create-new-comment is false, Report-only-changed-files should report the coverage for all files changed in the PR, not just the ones in the most recent commit

Closed this issue · 9 comments

This PR I have has a ton of changes. and before the most recent commit was correctly showing the coverage amount for the changed files.
image

but after the most recent commit for some reason is showing no coverage.
image

I have it so that its editing the comment every time (create-new-comment is false). In my opinion the expected behavior is that the comment should report coverage for files changed IN THE PR rather in the last commit when it is set like that

I run some tests and check your issue, what I see from my tests, and also code. It should report all changed files in PR (pull_request event).
It looks that what you describe is a push event. You also have an option to see the commits.
Maybe you run this action on a push event?

image

norb-c commented

I have the same issue here @MishaKav
When create-new-comment: false and report-only-changed-files: true, subsequent push events are not captured on the changed files.

Would be nice if it always compares the base branch and the current branch, unless I missed something

comparing the base branch and the current branch may be done only in pull_request.
When you do a push event GitHub does not provide on which PR you did the push.
At the same time one branch may be open in dozens of PRs, this is why it's called push - it is relevant only on files that are pushed in this commit.

norb-c commented

OK, I didn't explain clearly.
We have a pull request created between say, the dev branch to the staging branch.

Our configuration

          hide-comment: false
          create-new-comment: false
          hide-summary: false
          report-only-changed-files: true

The coverage comment
image

I still not got the issue that you describe, can you please read this comment #18 (comment) carefully and check:

  • On which event do you run pull_request or push?
  • Do you see the changed files when you run the GitHub action?
norb-c commented
  • We run on both pull_request and push
  • Yes they were changed files

image

hm, it looks like the real issue, when I will have some time I will try to reproduce it locally and understand where the problem is. Will open the issue for now.

I successfully reproduced and understood what was going on.
The action can generate "the report" that you want only from coverage-path and can't do it from coverage-summary-path.
You can see this as a warning in your screenshot in line 46, that the ./coverage.txt doesn't exist.
I'm suggesting you add something similar to (the last line is important):

- name: Run Tests
  run: npm run coverage | tee ./coverage.txt

- name: Jest Coverage Comment
  uses: MishaKav/jest-coverage-comment@main
  with:
    hide-comment: false
    create-new-comment: false
    hide-summary: false
    report-only-changed-files: true
    coverage-path: ./coverage.txt
norb-c commented

Thanks, The issue was that I didn't add | tee ./coverage.txt to my test command