codechecks / monorepo

Open source platform for code review automation ✅
https://codechecks.io/
97 stars 19 forks source link

Github Actions `isFork` False Positive #80

Open tynes opened 3 years ago

tynes commented 3 years ago

I am observing an error running codechecks in Github Actions - Provider should never be in fork mode and not in PR mode! It appears as if there is a false positive as the PR is not coming from a fork. The code is here:

https://github.com/codechecks/monorepo/blob/13986fee646918b63841f04bc4a2f3d0cf9c7000/packages/client/src/getExecutionContext.ts#L20-L25

For Github actions, !pr is always true

https://github.com/codechecks/monorepo/blob/ba52ad88a50898bf4ad246fd16ce5f7f7ada4034/packages/client/src/ci-providers/GithubActions.ts#L14-L16

And isFork is always true because GITHUB_HEAD_REF is set for PRs submitted from the same repo. See the docs here: https://docs.github.com/en/actions/reference/environment-variables

https://github.com/codechecks/monorepo/blob/ba52ad88a50898bf4ad246fd16ce5f7f7ada4034/packages/client/src/ci-providers/GithubActions.ts#L27-L31

GITHUB_HEAD_REF Only set for pull request events. The name of the head branch.

Perhaps there is a better way to determine there the PR is coming from a fork, will update if I determine a good solution

krzkaczor commented 3 years ago

It should be fixed in: https://github.com/codechecks/monorepo/pull/81

beta released as: @codechecks/client@0.1.10-beta