Skip to content

chore: Add script to protect RC branches during the release#18660

Merged
comphead merged 3 commits intoapache:mainfrom
comphead:dev1
Nov 19, 2025
Merged

chore: Add script to protect RC branches during the release#18660
comphead merged 3 commits intoapache:mainfrom
comphead:dev1

Conversation

@comphead
Copy link
Copy Markdown
Contributor

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:

  • 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

What changes are included in this PR?

Are these changes tested?

Are there any user-facing changes?

@github-actions github-actions Bot added the development-process Related to development process of DataFusion label Nov 13, 2025
@comphead
Copy link
Copy Markdown
Contributor Author

Adding you folks as you directly involved into release process

@comphead comphead requested a review from andygrove November 13, 2025 01:33
@comphead
Copy link
Copy Markdown
Contributor Author

Script is Clauded, but I tried to test out all scenarios:

  • branch number should be set and be a positive integer
  • branch should exist in DF repo before calling the script
  • check branch block doesn't exist in .asf.yaml

# Create a temporary file
TEMP_FILE=$(mktemp)

# Read the file and insert the new branch protection block
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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

Comment thread dev/release/add-branch-protection.sh Outdated
Co-authored-by: Martin Grigorov <martin-g@users.noreply.github.com>
@comphead comphead requested a review from martin-g November 14, 2025 00:09
@comphead
Copy link
Copy Markdown
Contributor Author

@alamb @xudong963 please take a look

Copy link
Copy Markdown
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

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

I tested this locally with

./dev/release/add-branch-protection.sh 49

Which 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 !

@comphead comphead added this pull request to the merge queue Nov 19, 2025
Merged via the queue into apache:main with commit 2dd17b9 Nov 19, 2025
28 checks passed
@comphead
Copy link
Copy Markdown
Contributor Author

Thanks @alamb for the review!

logan-keede pushed a commit to logan-keede/datafusion that referenced this pull request Nov 23, 2025
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

development-process Related to development process of DataFusion

Projects

None yet

Development

Successfully merging this pull request may close these issues.

chore: Modify prerelease process to protect automatically RC branch

3 participants