Error: Error on generating summary report. Cannot read properties of undefined (reading 'testsuite')
sohilnandu opened this issue · comments
When using this workflow, both the .xml and the .txt file seem to be read fine, but there is an error when generating the summary report:
Generating coverage report
File read successfully "/home/runner/work/origami-flask/origami-flask/./backend/coverage.xml"
Error: Error on generating summary report. Cannot read properties of undefined (reading 'testsuite')
File read successfully "/home/runner/work/origami-flask/origami-flask/./backend/pytest-coverage.txt"
Generating coverage report
What is causing this error?
Can you please share with me one of the files, so I can debug it?
@MishaKav Sure. I was not certain I wanted to post the files here so I have emailed them to you.
Thanks for helping!
Thanks for sharing, I rerun it several times and successfully generated all kinds of reports.
From the error message that you share, I assume that you provide the coverage.xml
to the wrong parameter, it should be pytest-xml-coverage-path: ./coverage.xml
and not junitxml-path: ./coverage.xml
(because the word testsuite
relevant only for junit
format).
Can you check it please ?
Thanks @MishaKav
I made the change you suggested and it removed the error when generating the summary report. However, I still do not see the summary report output in the comment. I tried to echo the summary report and got this error message:
Run echo "Coverage Percantage - {"name":"TOTAL","stmts":788,"miss":302,"cover":"61%"}"
Coverage Percantage - {name:TOTAL,stmts:788,miss:302,cover:61%}
Coverage Color - yellow
/home/runner/work/_temp/7b5abaae-4fb1-470a-b7db-67e915eefaa1.sh: line 3: syntax error near unexpected token `<'
Error: Process completed with exit code 2.
Also, the coverage report in the commit comment now shows every value in the "Stmts" column as 0. Before the change you suggested, it had the correct values.
-
when you try to get a coverage report from
coverage.xml
theStmts
will be always0
because they are not provided inxml
report. You can generate the same report frompytest-coverage.txt
that always hasStmts
-
when you try to print the output it yields that has unsupported characters because it
HTML
characters. If you want to output it, I can suggest you this, it will print the output insummary
of the action
- name: Add Summary
uses: actions/github-script@v6
with:
script: |
core.summary.addRaw(${{ steps.coverageComment.outputs.summaryReport }}).write()
- Ok, that makes sense. I am able to see
Stmts
when usingpytest-coverage.txt
- I was able to use your method to output the summary HTML and verify that it is actually there.
- For some reason, the summary is not being added to the commit comments. Below is all the info for my setup. I think there is something very simple that I am doing wrong.
- name: Run unit tests
working-directory: ./backend
run: |
pipenv run pytest --cov --cov-report "xml:coverage.xml" --cov-report=term-missing:skip-covered tests/ | tee pytest-coverage.txt
- name: Pytest coverage comment
id: coverageComment
uses: MishaKav/pytest-coverage-comment@main
with:
pytest-coverage-path: ./backend/pytest-coverage.txt
default-branch: master
coverage-path-prefix: backend/
- name: Add Summary
uses: actions/github-script@v6
with:
script: |
core.summary.addRaw(${{ steps.coverageComment.outputs.summaryReport }}).write()
The above workflow produced this commit comment without the summary:
Any help with debugging this is greatly appreciated 🙏🏽
From what I see the comment was generated exactly as you provide the inputs.
When you talk about summary
, which summary do you mean?
for this report you should provide junitxml-path: ./pytest.xml
.
You can generate it by pytest --junitxml=pytest.xml