MishaKav / pytest-coverage-comment

Comments a pull request with the pytest code coverage badge and full report
MIT License
181 stars 59 forks source link

Escape character seems to be failing the basic example #167

Closed HagegeR closed 5 months ago

HagegeR commented 5 months ago

Hi, @MishaKav, thanks for your fantastic action!

I am trying to enable the badge update workflow and it did not work for me, so I tested each steps separately and got to here: https://github.com/MishaKav/pytest-coverage-comment/blob/0e5d9396932b388ef7f313db17977815050b0cd5/README.md?plain=1#L153

Coverage Percentage - 82%
Coverage Color - green
Coverage Html - ""
/home/runner/_work/_temp/58ddf838-2bbf-44c9-b520-6d9de2814490.sh: line 4: syntax error near unexpected token `<'

My understanding is that the HTML result contains escape characters that the script doesn't know how to ignore. It seems like the jest version you made have some improvements in that part of the code, is it possible to try and align their code base somehow maybe?

I also saw here another issue: https://github.com/MishaKav/pytest-coverage-comment/blob/0e5d9396932b388ef7f313db17977815050b0cd5/.github/workflows/update-coverage-on-readme.yml#L32 summary_report is not a valid id

Hoping to hear back from you soon :)

MishaKav commented 5 months ago

Hey,

  1. Try to run your example without printing echo "Coverage Html..." (just remove this line)
  2. You are right, instead of summary_report, it should be coverageComment (I've already update the main branch with that)
HagegeR commented 5 months ago

thanks for the swift response! I actually need the Coverage Html because I wanted to use the example here: https://github.com/MishaKav/pytest-coverage-comment/blob/ed05a2e5134c846ceace093250fdedf697a6fe75/README.md?plain=1#L267

MishaKav commented 5 months ago

you can still use the HTML response in this line https://github.com/MishaKav/pytest-coverage-comment/blob/ed05a2e5134c846ceace093250fdedf697a6fe75/.github/workflows/update-coverage-on-readme.yml#L32

Try to remove the "echo" line with "HTML" https://github.com/MishaKav/pytest-coverage-comment/blob/0e5d9396932b388ef7f313db17977815050b0cd5/README.md?plain=1#L153

HagegeR commented 5 months ago

I'll try this, btw the first link you sent also use the wrong id

HagegeR commented 5 months ago

outputs.content is not valid, did you mean outputs.coverageHtml? I get an empty result from outputs.content

MishaKav commented 5 months ago

Yes, I mean, just remove this line

echo "Coverage Html - ${{ steps.coverageComment.outputs.coverageHtml }}" 
HagegeR commented 5 months ago

I tried many things, in the end the only thing that worked was using ${{ steps.coverageComment.outputs.summaryReport }} it adds "" that I don't need, but the content is here at least

MishaKav commented 5 months ago

Thanks for sharing