Skip to content

Conversation

@amonkhouse
Copy link

@amonkhouse amonkhouse commented Dec 15, 2025

Adds new logic flow to PR creation:

  1. Add automerge boolean arg to updateRepo, which defaults to false (we could make this true)
  2. Update createAndMergePullRequest to return PR node ID, needed for call to enable auto merge
  3. If automerge is true, once the PR has been created, we submit a GraphQL call to enable auto merge

https://artsyproduct.atlassian.net/browse/PHIRE-2629

@amonkhouse
Copy link
Author

@mc-jones I've tested this a few times and it's quite flaky, sometimes the call to enable auto merge fails as the PR is in a "clean" state, plus sometimes not all the checks trigger before auto merge is enabled and it merges early.

@mc-jones
Copy link
Contributor

@mc-jones I've tested this a few times and it's quite flaky, sometimes the call to enable auto merge fails as the PR is in a "clean" state, plus sometimes not all the checks trigger before auto merge is enabled and it merges early.

Is your sense that we're just inherently limited by the native functionality, or we need to code a more elegant solution?

@amonkhouse
Copy link
Author

amonkhouse commented Dec 18, 2025

@mc-jones hopefully just that we need to code a more elegant solution, but I'm not fully convinced it will work. It seems you can only mark a PR as squash/merge on green when there are checks that are running. That would be easy enough to handle, but I also had an issue where one check was running and the PR got marked as merge on green, but the check finished before any others started and it merged when it should have actually ran another 4 or so checks...

"compilerOptions": {
/* Basic Options */
"target": "es5" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */,
"target": "es2019" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */,
Copy link
Contributor

@mc-jones mc-jones Dec 23, 2025

Choose a reason for hiding this comment

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

Let's use a more modern modern version of javascript. es2019 matches force config.

Copy link
Contributor

Choose a reason for hiding this comment

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

I added a file for the graphql queries and mutations as they made the functions harder to read. But this is just a preference.

Copy link
Contributor

Choose a reason for hiding this comment

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

Similarl to the dedicated graphql-quries.ts file, I added a dedicated type file. Not everyone likes to break them out into their own file but I feel like this improved readability a bit. Can revert if we disagree.

})

status = response?.data?.repository?.pullRequest?.statusCheckRollup?.state ?? null
await new Promise((resolve) => setTimeout(resolve, 1000)) // wait for 1 second
Copy link
Contributor

Choose a reason for hiding this comment

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

There could still be some race conditions here. For example, a status check could start and finish during the 1 second timeout. We would break out of the loop but we would miss our opportunity to enable auto merge, which would be non-obvious to developers. If we see this happening we can reduce the timeout period.

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.

3 participants