Closed SirPhemmiey closed 5 months ago
@MishaKav
From what I see in the screenshot, your file contains \n
as text and not as a break-line
.
Try to play with your file generation.
Hi @MishaKav, i fixed the format and it's still the same
The paths you provide start with "coverage-report/...", as you can see in #72 the paths should be relative or be absolute or start with "./coverage-report/..." or similar. Please try this.
Happy to say it worked when i used another file reader github action.
Here's the full working version (without formatting the YAML) for anyone having the same issue
- name: Prepare coverage input
id: prepare-coverage-input
run: |
input=""
for dir in coverage-report/*/*/coverage-summary.json; do
appname=$(basename $(dirname $(dirname $dir)))
input="${input}${appname}, ${dir}\n"
done
printf "${input}" > coverage-input.txt
- name: Read coverage-inputs.txt
id: multiplefiles
uses: juliangruber/read-file-action@v1
with:
path: coverage-input.txt
- name: Jest Coverage Comment
uses: MishaKav/jest-coverage-comment@main
if: github.event_name == 'pull_request'
with:
title: Test Coverage Summary
summary-title: Summary
badge-title: Coverage
hide-comment: false
create-new-comment: false
hide-summary: false
coverage-title: Coverage Analysis
coverage-path: coverage-input.txt
multiple-files: ${{ steps.multiplefiles.outputs.content }}
Thank you @MishaKav !
Thank you for sharing the whole solution.
Hi @MishaKav, quick question.
When using the multiple files approach can i still put a value to coverage-path
? if yes, what should the value be?
Yes, you can using multiple-files
with coverage-path
. In the main readme, you have an example.
It can be something like this:
- name: Run Tests
run: npm run coverage | tee ./coverage.txt && exit ${PIPESTATUS[0]}
- name: Jest Coverage Comment
uses: MishaKav/jest-coverage-comment@main
with:
coverage-path: ./coverage.txt
multiple-files: |
My-Title-1, ./coverage/coverage-summary.json
My-Title-2, ./coverage/coverage-summary.json
The result will be as in the screenshot below:
@MishaKav What's the expected content of coverage.txt
? When i run a command similar to npm run coverage
, it emits/outputs other things because i'm using nx
monorepo.
it's the output
of jest
itself. Here you can see the whole example with all commands and output
https://github.com/MishaKav/api-testing-example/actions/runs/9108937444/job/25040742353
@MishaKav i see. I think you should add it in the docs that the jest.config.ts
should have the coverage reporters: ['json-summary', 'text', 'text-summary']
. Not everyone would usually use those coverage reporters
It's not exactly the truth. Specific in your case you may use only ['text']
to achieve what you want.
text-summary
- does not appear in report
in any wayjson-summary
- you need only when you provide coverage-summary.json
to the action
It's sortof a duplicate to this but the answer there didn't help me.
here's a snippet of my workflow
I am getting this error when i am not even passing
/coverage/coverage-summary.json
:This is also the content of
coverage-inputs.txt
to show that it's not emptyLooking forward to your help on this, thanks!