romeovs / lcov-reporter-action

Comments a pull request with the code coverage generated by your tests.
MIT License
162 stars 100 forks source link

The action fails with undefined error #41

Open charklewis opened 2 years ago

charklewis commented 2 years ago

I am trying to use this action however it always fails with:

TypeError: Cannot read property 'number' of undefined
[5](https://github.com/my-repo/runs/6051899683?check_suite_focus=true#step:7:5)
    at main$1 (/home/runner/work/_actions/romeovs/lcov-reporter-action/v0.2.11/dist/main.js:22921:2[6](https://github.com/my-repo/runs/6051899683?check_suite_focus=true#step:7:6))
6
Error: Cannot read property 'number' of undefined

Can you help me debug this?

Birdi7 commented 2 years ago

I have the same issue just using the example with workflow_dispatch event trigger

- name: publish
   uses: romeovs/lcov-reporter-action@v0.2.16
   with:
     lcov-file: ./coverage.lcov

@romeovs hello! do you have any time to check this?

guilhermeagostinelli commented 2 years ago

This error usually occurs when the workflow did not run on a "pull_request" event (e.g. ran on a "push").

You can inspect the github.event_name context property (https://docs.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions#github-context) which contains the name of the event that triggered the workflow run to ensure that the code coverage report step will only run on PRs.

For example:

- uses: romeovs/lcov-reporter-action@v0.2.16
  if: github.event_name == 'pull_request'
hramrach commented 10 months ago

How can I run the coverage report on a pull request, then?

The even I get when a pull request is updated is 'push'.

hramrach commented 10 months ago

Nevermind, that's determined by the selected action type in the workflow, both push and pull_request happen on updating a PR.