-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PMD annotations are added in an (Unknown event) in a (Unnamed workflow) when used in a pull request build #2
Comments
Hi, I noticed this myself too (see the same issue here as well: jwgmeligmeyling/spotbugs-github-action#2 ). I don't think this action should be used on the I am just going to encourage users to use the For example; - uses: jwgmeligmeyling/spotbugs-github-action@master
if: ${{ github.event_name == 'push' }}
with:
path: '**/spotbugsXml.xml'
- uses: jwgmeligmeyling/pmd-github-action@master
if: ${{ github.event_name == 'push' }}
with:
path: '**/pmd.xml'
- uses: jwgmeligmeyling/checkstyle-github-action@master
if: ${{ github.event_name == 'push' }}
with:
path: '**/checkstyle-result.xml' I could consider though to still push the result to |
In fact when I add the above You can see on this build that for the |
Yes allright, but it defeats the purpose of a build on the I by the way cant use the |
Yes this is why I made two jobs, one for the tests on the results of the merge and one for the codestyle on the head of the pull request. But I don't want to trigger this action on each push on every branch. I want to keep the trigger only on pull requests to master. I mean, as you said, running this type of checks on a merge does not make a lot of sense but the reason why I run them on the pull request is only to limit the number of builds. |
So then you're suggestion would be to document these two approaches in the README? Or would you still see a way to properly handle this programatically? |
First, if we want to make this action work on pull request builds, the fix you mentioned in the linked issue must be added : let sha = github.context.sha
if (github.context.payload.pull_request) {
sha = github.context.payload.pull_request.head.sha
} Then you should add a warning in the readme that if someone wants to run this action on the pull request event but check on the HEAD instead of the merge, the following option must be added to the checkout action. - uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.sha }} |
Hmm I would expect Is there a way to reference the SHA for the checkout out ref? So that we can still use |
haha yes this is what I was also surprised to find out !
You mean in the parameters of the checkout action ? It does not seem so. |
Allright. I'll make the suggested change later tonight (CEST). Thanks for your detailed report! I'll also make the change available to the actions for Checkstyle and SpotBugs. |
@n-peugnet Would you mind a solution where the ref can be passed as an input, just as with checkout? This as a workaround until there's a neat solution to find the actual ref checkout by the checkout action. I'd really like to avoid issues where users report their annotations are reported on the wrong line number for pull request events (that do not checkout the pull request ref without the additional configuration you provided). |
That would be ok. But people will continue to have the (Unknown event) problem as long as it is not mentioned in the README that there is a specific configuration to apply when you want to use this action on pull request build. |
I'm still working on an other issue: the results are posted under the "push" event, but are generated from the "pull_request" event. Figuring out how to tackle that. I suppose it uses check suites under the hood, but the API on registering check runs for a specific check suite is not documented (using https://developer.github.com/v3/checks/runs/#create-a-check-run as resource). I'll keep you posted... |
Hmm after some trying out, this is going to be hard to resolve. I filed an issue on the forums: https://github.saobby.my.eu.orgmunity/t/specify-check-suite-when-creating-a-checkrun/118380?u=jwgmeligmeyling . Meanwhile I am going to apply your patch. Just a heads up that there will remain a few quirks when you have multiple workflows or events your workflow listens on. It will just pick one workflow to place the results under. Its running a bit late, so I'll finish the patch tomorrow. |
I can live with that haha !
Ok great ! Of course take your time it's not that urgent. |
Thank you it is working exactly as intended ! |
Hi, I tried to use your action but I found a bug on
pull_request
builds. It took me some builds to find out that the action was correctly reporting violations but not on the correct build.On my last attempt tried to use this option of the checkout action but strangely the check was still added to the merge commit :
I looked a little bit at your code and I wonder if using
context.ref
when the check is created instead ofcontext.sha
would solve this problem (when the above option is set in the checkout action).The text was updated successfully, but these errors were encountered: