Skip to content

Add support for test/retest command in pull request comment#95

Open
glefloch wants to merge 6 commits into
quarkusio:mainfrom
glefloch:fix/71
Open

Add support for test/retest command in pull request comment#95
glefloch wants to merge 6 commits into
quarkusio:mainfrom
glefloch:fix/71

Conversation

@glefloch

Copy link
Copy Markdown
Member

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?

private static final Logger LOG = Logger.getLogger(PullRequestCommandHandler.class);

private static final String QUARKUS_BOT_NAME = "quarkus-bot";
private static final String QUARKUS_TEAM_MEMBERS = "quarkus-push";

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be externalized to ease development on test repo

@glefloch glefloch force-pushed the fix/71 branch 2 times, most recently from 7555b0a to 97c8931 Compare April 29, 2021 14:28

@gsmet gsmet left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool! I added a bunch of comments, mostly about details.

As for the rerunning the workflow, AFAIK the API silently ignore these calls if you don't have the permissions. I got hit by that too.

You need to go to this page (well the one of your instance): https://github.com/organizations/quarkusio/settings/apps/quarkus-bot/permissions and make sure you have Read & Write for Actions. Also, you will receive an email asking you to confirm the new privileges. If you don't do it, they won't be taken into account.

Comment thread src/main/java/io/quarkus/bot/PullRequestCommandHandler.java Outdated
Comment thread src/main/java/io/quarkus/bot/PullRequestCommandHandler.java Outdated
Comment thread src/main/java/io/quarkus/bot/PullRequestCommandHandler.java Outdated
Comment thread src/main/java/io/quarkus/bot/PullRequestCommandHandler.java Outdated
Comment thread src/main/java/io/quarkus/bot/PullRequestCommandHandler.java Outdated
Comment thread src/main/java/io/quarkus/bot/command/RerunWorkflowCommand.java Outdated
Comment thread src/main/java/io/quarkus/bot/command/RerunWorkflowCommand.java Outdated
Comment thread src/main/java/io/quarkus/bot/command/RerunWorkflowCommand.java Outdated
Comment thread src/main/java/io/quarkus/bot/command/RerunWorkflowCommand.java Outdated
Comment thread src/main/java/io/quarkus/bot/PullRequestCommandHandler.java Outdated
@glefloch glefloch force-pushed the fix/71 branch 2 times, most recently from 8f78217 to 6d8374f Compare May 3, 2021 07:27
@glefloch

glefloch commented May 3, 2021

Copy link
Copy Markdown
Member Author

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 glefloch marked this pull request as ready for review May 3, 2021 16:00
@gsmet

gsmet commented May 6, 2021

Copy link
Copy Markdown
Member

@glefloch I'll have a look tomorrow.

@gsmet gsmet changed the title Add support for test/restest command in pull request comment Add support for test/retest command in pull request comment May 7, 2021
@gsmet

gsmet commented May 7, 2021

Copy link
Copy Markdown
Member

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

@gsmet

gsmet commented May 7, 2021

Copy link
Copy Markdown
Member

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

gsmet commented May 7, 2021

Copy link
Copy Markdown
Member

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

@glefloch

glefloch commented May 7, 2021

Copy link
Copy Markdown
Member Author

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

@gsmet

gsmet commented May 7, 2021

Copy link
Copy Markdown
Member

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

gsmet commented May 7, 2021

Copy link
Copy Markdown
Member

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.

@glefloch

glefloch commented May 7, 2021

Copy link
Copy Markdown
Member Author

Thanks a lot for the investigation @gsmet !

@gsmet

gsmet commented May 10, 2021

Copy link
Copy Markdown
Member

@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.

@glefloch

Copy link
Copy Markdown
Member Author

Nice thanks!

There is a bug in the GitHub API and for now it's not possible to
trigger a rerun with an installation token. We have no ETA for the fix
so using a personal access token is the only workaround for now.
@gsmet

gsmet commented May 10, 2021

Copy link
Copy Markdown
Member

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

@glefloch

Copy link
Copy Markdown
Member Author

@gsmet it looks good to me!

@glefloch

Copy link
Copy Markdown
Member Author

@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 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants