quarkus-github-bot icon indicating copy to clipboard operation
quarkus-github-bot copied to clipboard

Add support for test/retest command in pull request comment

Open glefloch opened this issue 3 years ago • 14 comments

This branch aims to add commands handling on pull request command.

On a pull request comment, it :

  • check this is a comment on a pull request
  • the user that commented this is not @quarkus-bot
  • validate the user is part the quarkus-push teams

Once it is ok, it looks for a Command bean that match the comment body.

The RerunWorkflowCommand accepts test and retest allowing:

  • @quarkus-bot test command
  • @quarkus-bot retest command

Regarding the workflow, it looks for Quarkus CI WorkflowRun, take the last one, and rerun it.

I created the PR in draft as I'm not able to get a working rerun, no error, is thrown by the API. When I log the url of the workflow that should be rerun, it is the correct one. This may come from my repo not providing enough permissions but I'm not able to find what's missing, maybe @gsmet you will have some hints?

glefloch avatar Apr 29 '21 10:04 glefloch

Thanks @gsmet, returning a ReactionContent is a really good idea.

I'm still unable to get a rerun running. My app request Read & Write permissions on actions. And I review those permissions in the repo but nothing change.

glefloch avatar May 03 '21 07:05 glefloch

@glefloch I'll have a look tomorrow.

gsmet avatar May 06 '21 07:05 gsmet

Rebased and pushed a formatting fix. I will have a look to the behavior now.

gsmet avatar May 07 '21 05:05 gsmet

I pushed a few improvements but... I have the same issue you have. Root cause is we get a 403 with this error:

Caused by: org.kohsuke.github.GHFileNotFoundException: https://api.github.com/repos/gsmet/quarkus-bot-java-playground/actions/runs/764523023/rerun {"message":"Invalid run_id `764523023`","documentation_url":"https://docs.github.com/rest/reference/actions#re-run-a-workflow"}

gsmet avatar May 07 '21 08:05 gsmet

Rerun is working fine in the GitHub API tests so I'm not sure what is going on here...

gsmet avatar May 07 '21 08:05 gsmet

It's working fine with the same ID? the url built by the client looks correct.

glefloch avatar May 07 '21 08:05 glefloch

Yeah the URL looks correct and is the exact same than the one provided by GitHub in the cancelUrl field of the workflow run object. There's definitely something fishy going on but I have no idea what :/

gsmet avatar May 07 '21 08:05 gsmet

I experimented a lot with this.

There seems to be a problem on the GitHub side. Doing the exact same call with a personal access token works and I'm positive the permissions are correct given I can cancel a workflow.

I contacted the GitHub support. I'll let you know how it goes.

gsmet avatar May 07 '21 14:05 gsmet

Thanks a lot for the investigation @gsmet !

glefloch avatar May 07 '21 14:05 glefloch

@glefloch so the GitHub team confirmed to me it's a bug on their side. No ETA for the fix, I'll work on a workaround tonight and push a commit for you to review.

gsmet avatar May 10 '21 15:05 gsmet

Nice thanks!

glefloch avatar May 10 '21 16:05 glefloch

@glefloch I pushed the workaround, could you have a look? I tested it and it seems to work.

gsmet avatar May 10 '21 17:05 gsmet

@gsmet it looks good to me!

glefloch avatar May 10 '21 18:05 glefloch

@gsmet, I tested it with my playground bot and it works well. WDYT of keeping 2 separate commits, one with the handler and one with the custom rerun code ?

glefloch avatar May 13 '21 18:05 glefloch