-
Notifications
You must be signed in to change notification settings - Fork 2.1k
feat!: Add merge queue parameters to repository ruleset #3253
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
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #3253 +/- ##
==========================================
- Coverage 97.72% 92.94% -4.78%
==========================================
Files 153 171 +18
Lines 13390 11663 -1727
==========================================
- Hits 13085 10840 -2245
- Misses 215 729 +514
- Partials 90 94 +4 ☔ View full report in Codecov by Sentry. |
@@ -110,6 +110,19 @@ type RuleRequiredStatusChecks struct { | |||
IntegrationID *int64 `json:"integration_id,omitempty"` | |||
} | |||
|
|||
// MergeQueueRuleParameters represents the merge_queue rule parameters. | |||
type MergeQueueRuleParameters struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zepeng811 - should any of these parameters be optional (and therefore pointers with the omitempty
JSON tag added)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gmlewis did a quick test and seems like it must be all or nothing
adding all parameters like this worked:
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $GITHUB_TOKEN" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/$ORG/$REPO/rulesets \
-d '{"name":"merge queue test ruleset","target":"branch","enforcement":"active","conditions":{"ref_name":{"include":["refs/heads/main","refs/heads/master"],"exclude":["refs/heads/dev*"]}},"rules":[{"type":"merge_queue","parameters":{"check_response_timeout_minutes":35,"grouping_strategy":"HEADGREEN","max_entries_to_build":8,"max_entries_to_merge":4,"merge_method":"SQUASH","min_entries_to_merge":2,"min_entries_to_merge_wait_minutes":13}}]}'
but if any parameter was removed, like:
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $GITHUB_TOKEN" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/$ORG/$REPO/rulesets \
-d '{"name":"merge queue test ruleset 2","target":"branch","enforcement":"active","conditions":{"ref_name":{"include":["refs/heads/main","refs/heads/master"],"exclude":["refs/heads/dev*"]}},"rules":[{"type":"merge_queue","parameters":{"check_response_timeout_minutes":35,"grouping_strategy":"HEADGREEN","max_entries_to_build":8,"max_entries_to_merge":4,"merge_method":"SQUASH","min_entries_to_merge":2}}]}'
then the API will error:
{
"message": "Invalid request.\n\nInvalid property /rules/0: data matches no possible input. See `documentation_url`.",
"documentation_url": "https://docs.github.com/rest/repos/rules#create-a-repository-ruleset",
"status": "422"
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, thanks for testing!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, @zepeng811 !
LGTM.
Awaiting second LGTM+Approval from any other contributor to this repo before merging.
Thank you, @ali-kafel and @tomleicircle ! |
Fixes: #3225.
BREAKING CHANGE:
NewMergeQueueRule
now takes one parameter:*MergeQueueRuleParameters
.Summary
closes: #3225
(I'm the same author as the assignee of the issue @zhpeng811, but submitting the
PR using my corporate account)
Details
This PR adds merge queue parameter configurations to the repository branch ruleset.
an attempt was also made for organization ruleset but was later determined that GitHub currently does not support merge queue configurations at the organizational level. Configs related to merge queue in tests was removed as the result.
Testing
General
Ran the required scripts on step 4 of the CONTRIBUTING.md file
Details
Repository Ruleset
Manual:
Tested with the following test code, both with and without including the specific parameters, and verified in the UI.
Expand to view code
Unit Test:
A unit test already exist for merge queue without parameters, 2 more tests were added (1 success case and 1 failure case with the incorrect parameter type)
Organization Ruleset
Was trying to create a org ruleset with merge queue rule using the following curl
Expand for curl
but got the following error:
I cross referenced with the UI page and did not notice a branch rule for merge queue, which conflicts with the REST API documentation for org rulesets, so seems like GitHub currently does not support merge queue configuration on the org level ruleset. Reported the issue to GitHub community: https://github.com/orgs/community/discussions/137097