integrations / terraform-provider-github

Terraform GitHub provider
https://www.terraform.io/docs/providers/github/
MIT License
874 stars 714 forks source link

[FEAT]: Add support for Merge queue on github. #1481

Open bhargavms opened 1 year ago

bhargavms commented 1 year ago

Describe the need

Github has come up with this new feature called merge queues I don't see any configuration support for this from the terraform provider. Please add this into the terraform provider for github.

SDK Version

No response

API Version

No response

Relevant log output

No response

Code of Conduct

kfcampbell commented 1 year ago

@bhargavms is there an associated API you could link?

zepeng811 commented 1 year ago

merge queue is now in public beta, it would be great if our provider can support this feature.

morremeyer commented 1 year ago

The API documentation does not contain any information about merge queues yet: https://docs.github.com/en/rest/branches/branch-protection?apiVersion=2022-11-28#update-branch-protection However, the go module seems to have some form of support? https://github.com/google/go-github/blob/ab8b241add175a45ea24db294e035f2580e55853/github/repos.go#L881

dzmitry-lahoda commented 1 year ago

I do not see parameters in Go code to fine tune queue, only to enable kind of. If that works, I am fully happy with default parameters it sets to queue. It is already works little better than Mergify and we switched. Will donate equivalent of 42 USD in crypto for feature which enable/disable queue.

nikwotton commented 1 year ago

Merge queue is now officially released, though I don't see an update to the API documentation yet unfortunately.

StephenWithPH commented 1 year ago

I think this is the API doc to watch for the non v3 / non REST Terraform resource: https://docs.github.com/en/graphql/reference/objects#branchprotectionrule , assuming that merge queue is indeed a feature of branch protection per https://github.blog/2023-07-12-github-merge-queue-is-generally-available/ .

https://github.com/github/roadmap/issues/370 does not have any commentary about GraphQL changes.

https://docs.github.com/en/graphql/overview/changelog shows that there were some API changes regarding merge queues, but nothing on the branch protection resource.

StephenWithPH commented 1 year ago

@kfcampbell ... do you have internal visibility regarding upcoming GraphQL changes that would enable terraforming this?

reedloden commented 1 year ago

https://docs.github.com/en/graphql/reference/objects#mergequeueconfiguration seems like it would be where such configuration would go, but I'm not seeing it listed under https://docs.github.com/en/graphql/reference/objects#branchprotectionrule yet. However, this is still probably enough to get a rough draft of the code written.

kfcampbell commented 1 year ago

do you have internal visibility regarding upcoming GraphQL changes that would enable terraforming this?

I don't, sorry. A good way to request changes is by starting a discussion here.

morremeyer commented 1 year ago

This is already tracked in https://github.com/orgs/community/discussions/50893.

I've also contacted our account rep since we're a GitHub customer. I'll keep you all updated if I get to know anything.

kfcampbell commented 1 year ago

@morremeyer thank you for doing that!

jstuart-ut commented 12 months ago

@morremeyer any word on the outlook for this config update ?

We're looking to make some selective use of 'merge queue' as well, would love to see it surfaced (and captured) as a top-level configuration option for repos, if possible 😁

morremeyer commented 12 months ago

Nothing yet, I'll update here as soon as I know more.

mering commented 11 months ago

GitHub has GraphQL support planned (but no REST support). I guess this would be sufficient as other parts are already using the GraphQL API via https://github.com/shurcooL/githubv4?

fitz-res commented 11 months ago

@mering what roadmap issue are you referring to?

mering commented 11 months ago

@fitz-res our GitHub account rep told me. Unfortunately nothing public to follow and no ETA yet.

scruplelesswizard commented 11 months ago

Looks like Github has exposed the relevant resources on the GraphQL API now: MergeQueue MergeQueueConfiguration MergeQueueEntry MergeQueueEntryConnection MergeQueueEntryEdge AddedToMergeQueuEvent RemovedFromMergeQueueEvent

kfcampbell commented 11 months ago

That's awesome news! Pull requests are very welcome for this feature.

zhpeng811 commented 8 months ago

I'm trying to implement this feature for the provider since above comment mentioned the merge queue resources was added to the GraphQL API, but came to a realization that the CreateBranchProtectionRuleInput and UpdateBranchProtectionRuleInput input objects currently does not support merge queue configurations.

Raised a product feedback to the community at: https://github.com/orgs/community/discussions/77614 Would appreciate some upvotes to increase the awareness

siddharthab commented 4 months ago

@zhpeng811 At least Repository Rulesets now support merge queues (through, e.g. UpdateRepositoryRulesetInput -> RepositoryRuleInput -> RepositoryRuleType).

It seems like rulesets are being encouraged over branch protection in general. Might it make sense to only target rulesets for supporting merge queues?

Also, note the following bugs (possibly related) currently crash Terraform if we enable merge queues outside of Terraform and then continue to use Terraform.

https://github.com/google/go-github/issues/3098 https://github.com/integrations/terraform-provider-github/issues/2192

zhpeng811 commented 4 months ago

@siddharthab thanks for the reply (and finding the go-github bug)!

Indeed it seems like RepositoryRuleType supports merge queue as a type, but seems like RuleParametersInput don't have merge queue supported as an input. So we might be able to simply enable/disable merge queue with that but unable to change any configurations (I did not test it out so don't take my word for it), but still only for the ruleset.

Ruleset is a fairly new concept in GitHub, on GitHub's documentation page it mentioned Rulesets work alongside any branch protection rules and tag protection rules in a repository. so I think it's worth a try (pending the issue mentioned above is resolved) while we are still waiting for GitHub to generally support merge queue in both their REST and GraphQL APIs

zepeng811 commented 4 months ago

attaching a GitHub blog for configuring merge queue with ruleset (in public beta): https://github.blog/changelog/2024-02-27-repository-rules-configure-merge-queue-rule-public-beta/

they stated this limitation:

The merge queue rule cannot be configured via an API. This feature will be available in the near future.
zepeng811 commented 1 month ago

some updates as I've been following closely on GitHub's API updates:

repository rulesets - graphQL API have provided support for enabling/disabling merge queue: https://docs.github.com/en/graphql/reference/enums#repositoryruletype (search MERGE_QUEUE in RepositoryRuleType), but currently does not support different merge queue configurations.

repository rulesets - REST API currently still have no support for merge queue: https://docs.github.com/en/rest/repos/rules?apiVersion=2022-11-28#create-a-repository-ruleset

(REST API is currently what we use for this provider: https://github.com/integrations/terraform-provider-github/blob/main/github/resource_github_repository_ruleset.go)