Skip to content
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

Add an option to use github's auto merge #302

Merged
merged 1 commit into from Nov 9, 2022

Conversation

shouichi
Copy link
Contributor

@shouichi shouichi commented Nov 2, 2022

Close #301.

@shouichi shouichi marked this pull request as draft November 2, 2022 11:31
@shouichi shouichi force-pushed the github-auto-merge branch 3 times, most recently from 95016ad to f337f3e Compare November 4, 2022 02:04
@shouichi shouichi marked this pull request as ready for review November 4, 2022 02:18
src/github-client.js Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
async enableAutoMergePullRequest(pullRequestId, mergeMethod) {
const query = `
mutation ($pullRequestId: ID!, $mergeMethod: PullRequestMergeMethod!) {
enablePullRequestAutoMerge(input: {
Copy link
Member

Choose a reason for hiding this comment

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

Where did you tested it?
I wonder if the GHUser that runs this GHA has the permission to execute this mutation

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tried in a private repo of the company I work for but I'm gonna create a public repo and paste the url soon.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You can see it in action shouichi#1

README.md Show resolved Hide resolved
Copy link
Contributor

@marco-ippolito marco-ippolito left a comment

Choose a reason for hiding this comment

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

What happens if the mutation fails (ex: user does not have the permission )? Can you add a test for the failed mutation?

test/github-client.test.js Show resolved Hide resolved
src/github-client.js Show resolved Hide resolved
@shouichi
Copy link
Contributor Author

shouichi commented Nov 7, 2022

What happens if the mutation fails (ex: user does not have the permission )? Can you add a test for the failed mutation?

Do you mean a uni test or an integration test?

@marco-ippolito
Copy link
Contributor

marco-ippolito commented Nov 7, 2022

What happens if the mutation fails (ex: user does not have the permission )? Can you add a test for the failed mutation?

Do you mean a uni test or an integration test?

the ideal would be to test it in a real case scenario and add a unit test to simulate the github error (I'm not 100% what happens if the Github user doesn't have permission or if it is required)

@shouichi
Copy link
Contributor Author

shouichi commented Nov 7, 2022

But existing tests only cover happy paths and github-actoions.js doesn't even check the return value from the api...

@shouichi
Copy link
Contributor Author

shouichi commented Nov 7, 2022

Ok here's my logical answer.

That kind of test won't really add value because it only tests GitHub behavior, no the script. The behavior of the script is already covered and that should be enough. What do you think?

@marco-ippolito
Copy link
Contributor

I've tested it on my repo, LGTM

@shouichi
Copy link
Contributor Author

shouichi commented Nov 7, 2022

Thank you!

@marco-ippolito
Copy link
Contributor

marco-ippolito commented Nov 7, 2022

I think enable-auto-merge is too generic and does not convey the fact that this feat skips the checks and does a native github merge.
I would rename it to something like merge-skip-check or auto-merge-no-check . Also I'd add an example to the documentation, and spend a few words to highlight the fact that checks are skipped and it is merge automatically

@shouichi
Copy link
Contributor Author

shouichi commented Nov 8, 2022

It does not skip status checks, it only merges when all required status checks were successful. How about use-github-auto-merge and link the official document in README? I don't really want to describe the github feature (it can be wrong or will be outdated).

@simoneb
Copy link
Collaborator

simoneb commented Nov 8, 2022

How about use-github-auto-merge and link the official document in README?

👍

@shouichi
Copy link
Contributor Author

shouichi commented Nov 8, 2022

Fixed. Could you take a look?

@shouichi
Copy link
Contributor Author

shouichi commented Nov 8, 2022

Sorry, forgot to rename the option name in the test. Fixed and confirmed tests were passed.

README.md Outdated Show resolved Hide resolved
action.yml Outdated Show resolved Hide resolved
src/github-client.js Outdated Show resolved Hide resolved
@simoneb simoneb merged commit 8162450 into fastify:main Nov 9, 2022
@shouichi
Copy link
Contributor Author

shouichi commented Nov 9, 2022

Thank you!

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.

Option an option to use github's auto-merge feature
4 participants