chore: Add script to protect RC branches during the release#18660
chore: Add script to protect RC branches during the release#18660comphead merged 3 commits intoapache:mainfrom
Conversation
|
Adding you folks as you directly involved into release process |
|
Script is Clauded, but I tried to test out all scenarios:
|
| # Create a temporary file | ||
| TEMP_FILE=$(mktemp) | ||
|
|
||
| # Read the file and insert the new branch protection block |
There was a problem hiding this comment.
Have you considered using yq or similar command line YAML tool to insert the new item ?
The syntax would be something like:
yq -i ".github.protected_branches += [{\"${BRANCH_NAME}\": {\"required_pull_request_reviews\": {\"required_approving_review_count\": 1}}}]" ${ASF_YAML_FILE}It requires installing a third-party tool but would avoid the AWK script below.
There was a problem hiding this comment.
thats the reason, we have too much steps in release process, so I was trying to make it possible in pure bash. Another option is to use python, but still thinking pure bash would fit better
Co-authored-by: Martin Grigorov <martin-g@users.noreply.github.com>
|
@alamb @xudong963 please take a look |
alamb
left a comment
There was a problem hiding this comment.
I tested this locally with
./dev/release/add-branch-protection.sh 49Which output
Successfully added branch protection for branch-49 to .asf.yaml
Added block:
branch-49:
required_pull_request_reviews:
required_approving_review_count: 1
Please review the changes and commit them.
And seemingly added everything needed
(venv) andrewlamb@Andrews-MacBook-Pro-3:~/Software/datafusion$ git diff
diff --git a/.asf.yaml b/.asf.yaml
index 0588a300a5..1efcaea640 100644
--- a/.asf.yaml
+++ b/.asf.yaml
@@ -62,6 +62,9 @@ github:
branch-51:
required_pull_request_reviews:
required_approving_review_count: 1
+ branch-49:
+ required_pull_request_reviews:
+ required_approving_review_count: 1
pull_requests:
# enable updating head branches of pull requests
allow_update_branch: true
(venv) andrewlamb@Andrews-MacBook-Pro-3:~/Software/datafusion$Thanks @comphead !
|
Thanks @alamb for the review! |
…8660) ## Which issue does this PR close? <!-- We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes apache#123` indicates that this PR will close issue apache#123. --> - Closes apache#17134 ## Rationale for this change ASF Infra works in tricky way, to apply a protection for the new branch its needed to get: - branch created in repo - add rules to `.asf.yaml` in `main` - tricky part ASF reapply policies ONLY if `.asf.yaml` changed in PR, means that "future" branches won't be covered until the file changed and pushed. Adding a script to add automatically a block with new RC branch protection rules and updated documentation <!-- Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed. Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes. --> ## What changes are included in this PR? <!-- There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR. --> ## Are these changes tested? <!-- We typically require tests for all PRs in order to: 1. Prevent the code from being accidentally broken by subsequent changes 2. Serve as another way to document the expected behavior of the code If tests are not included in your PR, please explain why (for example, are they covered by existing tests)? --> ## Are there any user-facing changes? <!-- If there are user-facing changes then we may require documentation to be updated before approving the PR. --> <!-- If there are any breaking changes to public APIs, please add the `api change` label. --> --------- Co-authored-by: Martin Grigorov <martin-g@users.noreply.github.com>
Which issue does this PR close?
Rationale for this change
ASF Infra works in tricky way, to apply a protection for the new branch its needed to get:
.asf.yamlinmain.asf.yamlchanged in PR, means that "future" branches won't be covered until the file changed and pushed.Adding a script to add automatically a block with new RC branch protection rules and updated documentation
What changes are included in this PR?
Are these changes tested?
Are there any user-facing changes?