Closed mindrunner closed 1 year ago
You can't see the full output, because you missed an Id, try to add it:
- name: Jest Coverage Comment
id: coverageComment
uses: MishaKav/jest-coverage-comment@main
why its not posted posted to my PR I need to see the full workflow and by which trigger you try to run it.
Alright, some issues are solved. But not all of them. It seems like a comment is created as soon as I add the pull_request
trigger. On push
trigger, it does not work. Would that be expected? What I want to achieve is:
1) run test suite on every push 2) post results in open PR (if one exist)
If I have pull_request
and push
trigger. Tests are ran twice when I push new code to an open PR, which seem senseless to me.
Other issue is the coverage-path
parameter. I am supposed to pass the stdout
of jest there, right? If I do pass it on to tee
as you do in your example, I only get an empty file. If I also redirect stderr
, I get the content I would expect, but parsing seems broken:
File read successfully "./build/test/unit/out.txt"
Coverage Report
coverage: 0
color: red
branches: 0
functions: 0
lines: 0
statements: 0
coverageHtml: <details><summary>Coverage Report (<b>0%</b>)</summary><table><tr><th>File</th><th>% Stmts</th><th>% Branch</th><th>% Funcs</th><th>% Lines</th><th>Uncovered Line #s</th></tr><tbody> </tbody></table></details>
Simplified example:
name: Test
on:
- push
- pull_request
jobs:
unit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/yarn-install
- name: Create coverage directory
run: mkdir -p build/test/unit/
- name: Unit
run: yarn test:unit --coverage 2>&1 | tee ./build/test/unit/out.txt
- name: Jest Coverage Comment
id: coverageComment
uses: MishaKav/jest-coverage-comment@main
with:
unique-id-for-comment: unit
github-token: ${{ secrets.GITHUB_TOKEN }}
title: Unit Test Coverage
coverage-path: ./build/test/unit/out.txt
coverage-summary-path: ./build/test/unit/coverage/coverage-summary.json
junitxml-path: ./build/test/unit/junit.xml
Enabling more coverage reporters seems to solve some of my issues already:
coverageReporters: [
'html',
'json',
'json-summary',
'text',
'text-summary'
],
You can't achieve both targets on the same run, because of the way that GitHub work (1. run test suite on every push 2. post results in open PR (if one exist))
push
every comment will be attached to that commit (you can't update these comments because they are related to a specific commit).pull_request
, you can update the same comment as much as you run, because every run on PR belongs to the same PR. push
and attach results to the PR
(you may do it by custom code)About the second issue, I'm not sure that I understand your point. If it is something that is related to tee
, can you please look at this issue #15
Nice, thanks for the information. I am still workin on this and have some roadblocks to get it merged (mainly with sharding of big test suites), but I think that's out of scope of this conversation. Guess we can close
Something seems broken and I cannot figure out what. It seems like my coverage files were parsed correctly, but then there is no output generated, nor is a comment posted to my PR. What am I missing here?