coverage icon indicating copy to clipboard operation
coverage copied to clipboard

Why running only for pull requests events?

Open uilianries opened this issue 1 year ago • 2 comments

Hello and thank you for providing this project, it's really useful!

Currently I'm trying to use it for a project, but it seems like I can not decide about the logic involving the event due the follow condition:

https://github.com/orgoro/coverage/blob/c65003f41276ea33fe3a3a5d53df8b340462e8fa/src/index.ts#L14

const eventName = context.eventName
    if (eventName !== 'pull_request') {
      core.setFailed(`action support only pull requests but event is ${eventName}`)
      return
    }

So, basically we are only running nightly and manual workflow_dispatch CI jobs, which means, this project can not be used, because we still are not running for pull requests.

I would like to ask to raise that condition if possible, so users could decide the logic directly in their CI flow, instead:

- name: Coverage report
  if: github.event_name == 'pull_request'
  uses: orgoro/[email protected]
  with:
    coverageFile: xmlcov/coverage.xml
    token: ${{ secrets.GITHUB_TOKEN }}

Regards!

uilianries avatar Mar 02 '24 17:03 uilianries

it will require changes to the underlaying code to support the different events I see one type of event is addressed here - https://github.com/orgoro/coverage/pull/281

I will merge that PR to support the new event once it's fixed

orgoro avatar Mar 29 '24 07:03 orgoro

This isn't as trivial as it might seem on the surface, as it is building a report on coverage when compared to the base reference, which is incredibly context specific.

From the environment variable docs

The name of the base ref or target branch of the pull request in a workflow run. This is only set when the event that triggers a workflow run is either pull_request or pull_request_target. For example, main.

Now, could this information be gathered for other event types, certainly. But what would be gained over simply calling something like, beyond a pretty summary for the work flow?

- name: Check Cover
  run: coverage report --fail-under=80

It would likely require an event parser, and potentially more complex configuration interface. Which might be out of scope for the goals of the action.

techman83 avatar Mar 30 '24 03:03 techman83